diff options
-rw-r--r-- | python/pyspark/rdd.py | 3 | ||||
-rw-r--r-- | python/pyspark/storagelevel.py | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/python/pyspark/rdd.py b/python/pyspark/rdd.py index ddd22850a8..bb4d035edc 100644 --- a/python/pyspark/rdd.py +++ b/python/pyspark/rdd.py @@ -1448,9 +1448,12 @@ class RDD(object): def getStorageLevel(self): """ Get the RDD's current storage level. + >>> rdd1 = sc.parallelize([1,2]) >>> rdd1.getStorageLevel() StorageLevel(False, False, False, False, 1) + >>> print(rdd1.getStorageLevel()) + Serialized 1x Replicated """ java_storage_level = self._jrdd.getStorageLevel() storage_level = StorageLevel(java_storage_level.useDisk(), diff --git a/python/pyspark/storagelevel.py b/python/pyspark/storagelevel.py index 7b6660eab2..3a18ea54ea 100644 --- a/python/pyspark/storagelevel.py +++ b/python/pyspark/storagelevel.py @@ -36,6 +36,15 @@ class StorageLevel: return "StorageLevel(%s, %s, %s, %s, %s)" % ( self.useDisk, self.useMemory, self.useOffHeap, self.deserialized, self.replication) + def __str__(self): + result = "" + result += "Disk " if self.useDisk else "" + result += "Memory " if self.useMemory else "" + result += "Tachyon " if self.useOffHeap else "" + result += "Deserialized " if self.deserialized else "Serialized " + result += "%sx Replicated" % self.replication + return result + StorageLevel.DISK_ONLY = StorageLevel(True, False, False, False) StorageLevel.DISK_ONLY_2 = StorageLevel(True, False, False, False, 2) StorageLevel.MEMORY_ONLY = StorageLevel(False, True, False, True) |