Fixed the bug that shuffle serializer is ignored by the new shuffle

block iterators for local blocks. Also added a unit test for that.
This commit is contained in:
Reynold Xin 2013-05-24 14:08:37 -07:00
parent dbbedfc535
commit 6ea085169d
2 changed files with 19 additions and 4 deletions

View file

@ -163,7 +163,7 @@ object BlockFetcherIterator {
// these all at once because they will just memory-map some files, so they won't consume // these all at once because they will just memory-map some files, so they won't consume
// any memory that might exceed our maxBytesInFlight // any memory that might exceed our maxBytesInFlight
for (id <- localBlockIds) { for (id <- localBlockIds) {
getLocal(id) match { getLocalFromDisk(id, serializer) match {
case Some(iter) => { case Some(iter) => {
// Pass 0 as size since it's not in flight // Pass 0 as size since it's not in flight
results.put(new FetchResult(id, 0, () => iter)) results.put(new FetchResult(id, 0, () => iter))

View file

@ -305,11 +305,26 @@ class ShuffleSuite extends FunSuite with ShouldMatchers with LocalSparkContext {
assert(c.partitioner.get === p) assert(c.partitioner.get === p)
} }
test("shuffle serializer") {
// Use a local cluster with 2 processes to make sure there are both local and remote blocks
sc = new SparkContext("local-cluster[1,2,512]", "test")
val a = sc.parallelize(1 to 10, 2)
val b = a.map { x =>
(x, new ShuffleSuite.NonJavaSerializableClass(x * 2))
}
// If the Kryo serializer is not used correctly, the shuffle would fail because the
// default Java serializer cannot handle the non serializable class.
val c = new ShuffledRDD(b, new HashPartitioner(3), classOf[spark.KryoSerializer].getName)
assert(c.count === 10)
}
} }
object ShuffleSuite { object ShuffleSuite {
def mergeCombineException(x: Int, y: Int): Int = { def mergeCombineException(x: Int, y: Int): Int = {
throw new SparkException("Exception for map-side combine.") throw new SparkException("Exception for map-side combine.")
x + y x + y
} }
class NonJavaSerializableClass(val value: Int)
} }