From f8966ffc11773a4c090dcf359e3892027992ed98 Mon Sep 17 00:00:00 2001 From: Matei Zaharia Date: Fri, 12 Nov 2010 16:18:45 -0800 Subject: [PATCH] Added a shuffle test with negative hash codes for some keys (this was a bug earlier) --- src/test/spark/ShuffleSuite.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/spark/ShuffleSuite.scala b/src/test/spark/ShuffleSuite.scala index 2898bd09c8..a5773614e8 100644 --- a/src/test/spark/ShuffleSuite.scala +++ b/src/test/spark/ShuffleSuite.scala @@ -31,6 +31,17 @@ class ShuffleSuite extends FunSuite { assert(valuesFor2.toList.sorted === List(1)) } + test("groupByKey with negative key hash codes") { + val sc = new SparkContext("local", "test") + val pairs = sc.parallelize(Array((-1, 1), (-1, 2), (-1, 3), (2, 1))) + val groups = pairs.groupByKey().collect() + assert(groups.size === 2) + val valuesForMinus1 = groups.find(_._1 == -1).get._2 + assert(valuesForMinus1.toList.sorted === List(1, 2, 3)) + val valuesFor2 = groups.find(_._1 == 2).get._2 + assert(valuesFor2.toList.sorted === List(1)) + } + test("groupByKey with many output partitions") { val sc = new SparkContext("local", "test") val pairs = sc.parallelize(Array((1, 1), (1, 2), (1, 3), (2, 1)))