Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/1978#discussion_r16687577
--- Diff: python/pyspark/tests.py ---
@@ -117,6 +118,28 @@ 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)))
+
--- End diff --
Would be good to add a test that calls sortByKey on a large dataset here
too, in addition to just testing the ExternalSorter separately.
---
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]