diff --git a/python/pyspark/conf.py b/python/pyspark/conf.py index 8eff4a242a529..ea20c49c114da 100644 --- a/python/pyspark/conf.py +++ b/python/pyspark/conf.py @@ -99,6 +99,12 @@ def set(self, key, value): self._jconf.set(key, unicode(value)) return self + def setIfMissing(self, key, value): + """Set a configuration property, if not already set.""" + if self.get(key) is None: + self.set(key, value) + return self + def setMaster(self, value): """Set master URL to connect to.""" self._jconf.setMaster(value) diff --git a/python/pyspark/context.py b/python/pyspark/context.py index 062bec2381a8f..29d37fc15483a 100644 --- a/python/pyspark/context.py +++ b/python/pyspark/context.py @@ -102,7 +102,7 @@ def __init__(self, master=None, appName=None, sparkHome=None, pyFiles=None, else: self.serializer = BatchedSerializer(self._unbatched_serializer, batchSize) - + self._conf.setIfMissing("spark.rdd.compress", "true") # Set any parameters passed directly to us on the conf if master: self._conf.setMaster(master) diff --git a/python/pyspark/rdd.py b/python/pyspark/rdd.py index 9c69c79236edc..b9414b2ca5c20 100644 --- a/python/pyspark/rdd.py +++ b/python/pyspark/rdd.py @@ -194,10 +194,10 @@ def context(self): def cache(self): """ - Persist this RDD with the default storage level (C{MEMORY_ONLY}). + Persist this RDD with the default storage level (C{MEMORY_ONLY_SER}). """ self.is_cached = True - self._jrdd.cache() + self.persist(StorageLevel.MEMORY_ONLY_SER) return self def persist(self, storageLevel):