Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/1978#discussion_r16732341
--- Diff: python/pyspark/tests.py ---
@@ -117,6 +119,37 @@ def test_huge_dataset(self):
m._cleanup()
+class TestSorter(unittest.TestCase):
+ def test_in_memory_sort(self):
+ l = range(1024)
+ random.shuffle(l)
+ sorter = ExternalSorter(1024)
+ self.assertEquals(sorted(l), list(sorter.sorted(l)))
+ self.assertEquals(sorted(l, reverse=True), list(sorter.sorted(l,
reverse=True)))
+ self.assertEquals(sorted(l, key=lambda x: -x),
list(sorter.sorted(l, key=lambda x: -x)))
+ self.assertEquals(sorted(l, key=lambda x: -x, reverse=True),
+ list(sorter.sorted(l, key=lambda x: -x,
reverse=True)))
+
+ def test_external_sort(self):
+ l = range(1024)
+ random.shuffle(l)
+ sorter = ExternalSorter(1)
+ self.assertEquals(sorted(l), list(sorter.sorted(l)))
+ self.assertEquals(sorted(l, reverse=True), list(sorter.sorted(l,
reverse=True)))
+ self.assertEquals(sorted(l, key=lambda x: -x),
list(sorter.sorted(l, key=lambda x: -x)))
+ self.assertEquals(sorted(l, key=lambda x: -x, reverse=True),
+ list(sorter.sorted(l, key=lambda x: -x,
reverse=True)))
+
+ def test_external_sort_in_rdd(self):
+ conf = SparkConf().set("spark.python.worker.memory", "1m")
+ sc = SparkContext(conf=conf)
+ l = range(10240)
+ random.shuffle(l)
+ rdd = sc.parallelize(l, 10)
+ self.assertEquals(sorted(l), rdd.sortBy(lambda x: x).collect())
+ sc.stop()
--- End diff --
Have you tested that this actually spills any data? I guess it does because
the bare Python interpreter already consumes more than 1 MB?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]