@@ -86,28 +86,28 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
8686 // Both aggregator and ordering
8787 val sorter = new ExternalSorter [Int , Int , Int ](
8888 Some (agg), Some (new HashPartitioner (7 )), Some (ord), None )
89- sorter.write (elements.iterator)
89+ sorter.insertAll (elements.iterator)
9090 assert(sorter.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
9191 sorter.stop()
9292
9393 // Only aggregator
9494 val sorter2 = new ExternalSorter [Int , Int , Int ](
9595 Some (agg), Some (new HashPartitioner (7 )), None , None )
96- sorter2.write (elements.iterator)
96+ sorter2.insertAll (elements.iterator)
9797 assert(sorter2.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
9898 sorter2.stop()
9999
100100 // Only ordering
101101 val sorter3 = new ExternalSorter [Int , Int , Int ](
102102 None , Some (new HashPartitioner (7 )), Some (ord), None )
103- sorter3.write (elements.iterator)
103+ sorter3.insertAll (elements.iterator)
104104 assert(sorter3.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
105105 sorter3.stop()
106106
107107 // Neither aggregator nor ordering
108108 val sorter4 = new ExternalSorter [Int , Int , Int ](
109109 None , Some (new HashPartitioner (7 )), None , None )
110- sorter4.write (elements.iterator)
110+ sorter4.insertAll (elements.iterator)
111111 assert(sorter4.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
112112 sorter4.stop()
113113 }
@@ -124,7 +124,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
124124
125125 val sorter = new ExternalSorter [Int , Int , Int ](
126126 None , Some (new HashPartitioner (7 )), None , None )
127- sorter.write (elements)
127+ sorter.insertAll (elements)
128128 assert(sc.env.blockManager.diskBlockManager.getAllFiles().length > 0 ) // Make sure it spilled
129129 val iter = sorter.partitionedIterator.map(p => (p._1, p._2.toList))
130130 assert(iter.next() === (0 , Nil ))
@@ -287,13 +287,13 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
287287 val diskBlockManager = SparkEnv .get.blockManager.diskBlockManager
288288
289289 val sorter = new ExternalSorter [Int , Int , Int ](None , Some (new HashPartitioner (3 )), None , None )
290- sorter.write ((0 until 100000 ).iterator.map(i => (i, i)))
290+ sorter.insertAll ((0 until 100000 ).iterator.map(i => (i, i)))
291291 assert(diskBlockManager.getAllFiles().length > 0 )
292292 sorter.stop()
293293 assert(diskBlockManager.getAllBlocks().length === 0 )
294294
295295 val sorter2 = new ExternalSorter [Int , Int , Int ](None , Some (new HashPartitioner (3 )), None , None )
296- sorter2.write ((0 until 100000 ).iterator.map(i => (i, i)))
296+ sorter2.insertAll ((0 until 100000 ).iterator.map(i => (i, i)))
297297 assert(diskBlockManager.getAllFiles().length > 0 )
298298 assert(sorter2.iterator.toSet === (0 until 100000 ).map(i => (i, i)).toSet)
299299 sorter2.stop()
@@ -309,7 +309,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
309309
310310 val sorter = new ExternalSorter [Int , Int , Int ](None , Some (new HashPartitioner (3 )), None , None )
311311 intercept[SparkException ] {
312- sorter.write ((0 until 100000 ).iterator.map(i => {
312+ sorter.insertAll ((0 until 100000 ).iterator.map(i => {
313313 if (i == 99990 ) {
314314 throw new SparkException (" Intentional failure" )
315315 }
@@ -365,7 +365,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
365365 sc = new SparkContext (" local" , " test" , conf)
366366
367367 val sorter = new ExternalSorter [Int , Int , Int ](None , Some (new HashPartitioner (3 )), None , None )
368- sorter.write ((0 until 100000 ).iterator.map(i => (i / 4 , i)))
368+ sorter.insertAll ((0 until 100000 ).iterator.map(i => (i / 4 , i)))
369369 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
370370 val expected = (0 until 3 ).map(p => {
371371 (p, (0 until 100000 ).map(i => (i / 4 , i)).filter(_._1 % 3 == p).toSet)
@@ -381,7 +381,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
381381
382382 val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
383383 val sorter = new ExternalSorter (Some (agg), Some (new HashPartitioner (3 )), None , None )
384- sorter.write ((0 until 100 ).iterator.map(i => (i / 2 , i)))
384+ sorter.insertAll ((0 until 100 ).iterator.map(i => (i / 2 , i)))
385385 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
386386 val expected = (0 until 3 ).map(p => {
387387 (p, (0 until 50 ).map(i => (i, i * 4 + 1 )).filter(_._1 % 3 == p).toSet)
@@ -397,7 +397,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
397397
398398 val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
399399 val sorter = new ExternalSorter (Some (agg), Some (new HashPartitioner (3 )), None , None )
400- sorter.write ((0 until 100000 ).iterator.map(i => (i / 2 , i)))
400+ sorter.insertAll ((0 until 100000 ).iterator.map(i => (i / 2 , i)))
401401 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
402402 val expected = (0 until 3 ).map(p => {
403403 (p, (0 until 50000 ).map(i => (i, i * 4 + 1 )).filter(_._1 % 3 == p).toSet)
@@ -414,7 +414,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
414414 val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
415415 val ord = implicitly[Ordering [Int ]]
416416 val sorter = new ExternalSorter (Some (agg), Some (new HashPartitioner (3 )), Some (ord), None )
417- sorter.write ((0 until 100000 ).iterator.map(i => (i / 2 , i)))
417+ sorter.insertAll ((0 until 100000 ).iterator.map(i => (i / 2 , i)))
418418 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
419419 val expected = (0 until 3 ).map(p => {
420420 (p, (0 until 50000 ).map(i => (i, i * 4 + 1 )).filter(_._1 % 3 == p).toSet)
@@ -431,7 +431,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
431431 val ord = implicitly[Ordering [Int ]]
432432 val sorter = new ExternalSorter [Int , Int , Int ](
433433 None , Some (new HashPartitioner (3 )), Some (ord), None )
434- sorter.write ((0 until 100 ).iterator.map(i => (i, i)))
434+ sorter.insertAll ((0 until 100 ).iterator.map(i => (i, i)))
435435 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSeq)}.toSeq
436436 val expected = (0 until 3 ).map(p => {
437437 (p, (0 until 100 ).map(i => (i, i)).filter(_._1 % 3 == p).toSeq)
@@ -448,7 +448,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
448448 val ord = implicitly[Ordering [Int ]]
449449 val sorter = new ExternalSorter [Int , Int , Int ](
450450 None , Some (new HashPartitioner (3 )), Some (ord), None )
451- sorter.write ((0 until 100000 ).iterator.map(i => (i, i)))
451+ sorter.insertAll ((0 until 100000 ).iterator.map(i => (i, i)))
452452 val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSeq)}.toSeq
453453 val expected = (0 until 3 ).map(p => {
454454 (p, (0 until 100000 ).map(i => (i, i)).filter(_._1 % 3 == p).toSeq)
@@ -495,7 +495,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
495495 val toInsert = (1 to 100000 ).iterator.map(_.toString).map(s => (s, s)) ++
496496 collisionPairs.iterator ++ collisionPairs.iterator.map(_.swap)
497497
498- sorter.write (toInsert)
498+ sorter.insertAll (toInsert)
499499
500500 // A map of collision pairs in both directions
501501 val collisionPairsMap = (collisionPairs ++ collisionPairs.map(_.swap)).toMap
@@ -524,7 +524,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
524524 // Insert 10 copies each of lots of objects whose hash codes are either 0 or 1. This causes
525525 // problems if the map fails to group together the objects with the same code (SPARK-2043).
526526 val toInsert = for (i <- 1 to 10 ; j <- 1 to 10000 ) yield (FixedHashObject (j, j % 2 ), 1 )
527- sorter.write (toInsert.iterator)
527+ sorter.insertAll (toInsert.iterator)
528528
529529 val it = sorter.iterator
530530 var count = 0
@@ -548,7 +548,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
548548 val agg = new Aggregator [Int , Int , ArrayBuffer [Int ]](createCombiner, mergeValue, mergeCombiners)
549549 val sorter = new ExternalSorter [Int , Int , ArrayBuffer [Int ]](Some (agg), None , None , None )
550550
551- sorter.write ((1 to 100000 ).iterator.map(i => (i, i)) ++ Iterator ((Int .MaxValue , Int .MaxValue )))
551+ sorter.insertAll ((1 to 100000 ).iterator.map(i => (i, i)) ++ Iterator ((Int .MaxValue , Int .MaxValue )))
552552
553553 val it = sorter.iterator
554554 while (it.hasNext) {
@@ -572,7 +572,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
572572 val sorter = new ExternalSorter [String , String , ArrayBuffer [String ]](
573573 Some (agg), None , None , None )
574574
575- sorter.write ((1 to 100000 ).iterator.map(i => (i.toString, i.toString)) ++ Iterator (
575+ sorter.insertAll ((1 to 100000 ).iterator.map(i => (i.toString, i.toString)) ++ Iterator (
576576 (null .asInstanceOf [String ], " 1" ),
577577 (" 1" , null .asInstanceOf [String ]),
578578 (null .asInstanceOf [String ], null .asInstanceOf [String ])
0 commit comments