@@ -86,28 +86,28 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
86
86
// Both aggregator and ordering
87
87
val sorter = new ExternalSorter [Int , Int , Int ](
88
88
Some (agg), Some (new HashPartitioner (7 )), Some (ord), None )
89
- sorter.write (elements.iterator)
89
+ sorter.insertAll (elements.iterator)
90
90
assert(sorter.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
91
91
sorter.stop()
92
92
93
93
// Only aggregator
94
94
val sorter2 = new ExternalSorter [Int , Int , Int ](
95
95
Some (agg), Some (new HashPartitioner (7 )), None , None )
96
- sorter2.write (elements.iterator)
96
+ sorter2.insertAll (elements.iterator)
97
97
assert(sorter2.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
98
98
sorter2.stop()
99
99
100
100
// Only ordering
101
101
val sorter3 = new ExternalSorter [Int , Int , Int ](
102
102
None , Some (new HashPartitioner (7 )), Some (ord), None )
103
- sorter3.write (elements.iterator)
103
+ sorter3.insertAll (elements.iterator)
104
104
assert(sorter3.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
105
105
sorter3.stop()
106
106
107
107
// Neither aggregator nor ordering
108
108
val sorter4 = new ExternalSorter [Int , Int , Int ](
109
109
None , Some (new HashPartitioner (7 )), None , None )
110
- sorter4.write (elements.iterator)
110
+ sorter4.insertAll (elements.iterator)
111
111
assert(sorter4.partitionedIterator.map(p => (p._1, p._2.toSet)).toSet === expected)
112
112
sorter4.stop()
113
113
}
@@ -124,7 +124,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
124
124
125
125
val sorter = new ExternalSorter [Int , Int , Int ](
126
126
None , Some (new HashPartitioner (7 )), None , None )
127
- sorter.write (elements)
127
+ sorter.insertAll (elements)
128
128
assert(sc.env.blockManager.diskBlockManager.getAllFiles().length > 0 ) // Make sure it spilled
129
129
val iter = sorter.partitionedIterator.map(p => (p._1, p._2.toList))
130
130
assert(iter.next() === (0 , Nil ))
@@ -287,13 +287,13 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
287
287
val diskBlockManager = SparkEnv .get.blockManager.diskBlockManager
288
288
289
289
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)))
291
291
assert(diskBlockManager.getAllFiles().length > 0 )
292
292
sorter.stop()
293
293
assert(diskBlockManager.getAllBlocks().length === 0 )
294
294
295
295
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)))
297
297
assert(diskBlockManager.getAllFiles().length > 0 )
298
298
assert(sorter2.iterator.toSet === (0 until 100000 ).map(i => (i, i)).toSet)
299
299
sorter2.stop()
@@ -309,7 +309,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
309
309
310
310
val sorter = new ExternalSorter [Int , Int , Int ](None , Some (new HashPartitioner (3 )), None , None )
311
311
intercept[SparkException ] {
312
- sorter.write ((0 until 100000 ).iterator.map(i => {
312
+ sorter.insertAll ((0 until 100000 ).iterator.map(i => {
313
313
if (i == 99990 ) {
314
314
throw new SparkException (" Intentional failure" )
315
315
}
@@ -365,7 +365,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
365
365
sc = new SparkContext (" local" , " test" , conf)
366
366
367
367
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)))
369
369
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
370
370
val expected = (0 until 3 ).map(p => {
371
371
(p, (0 until 100000 ).map(i => (i / 4 , i)).filter(_._1 % 3 == p).toSet)
@@ -381,7 +381,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
381
381
382
382
val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
383
383
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)))
385
385
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
386
386
val expected = (0 until 3 ).map(p => {
387
387
(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 {
397
397
398
398
val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
399
399
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)))
401
401
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
402
402
val expected = (0 until 3 ).map(p => {
403
403
(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 {
414
414
val agg = new Aggregator [Int , Int , Int ](i => i, (i, j) => i + j, (i, j) => i + j)
415
415
val ord = implicitly[Ordering [Int ]]
416
416
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)))
418
418
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
419
419
val expected = (0 until 3 ).map(p => {
420
420
(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 {
431
431
val ord = implicitly[Ordering [Int ]]
432
432
val sorter = new ExternalSorter [Int , Int , Int ](
433
433
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)))
435
435
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSeq)}.toSeq
436
436
val expected = (0 until 3 ).map(p => {
437
437
(p, (0 until 100 ).map(i => (i, i)).filter(_._1 % 3 == p).toSeq)
@@ -448,7 +448,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
448
448
val ord = implicitly[Ordering [Int ]]
449
449
val sorter = new ExternalSorter [Int , Int , Int ](
450
450
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)))
452
452
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSeq)}.toSeq
453
453
val expected = (0 until 3 ).map(p => {
454
454
(p, (0 until 100000 ).map(i => (i, i)).filter(_._1 % 3 == p).toSeq)
@@ -495,7 +495,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
495
495
val toInsert = (1 to 100000 ).iterator.map(_.toString).map(s => (s, s)) ++
496
496
collisionPairs.iterator ++ collisionPairs.iterator.map(_.swap)
497
497
498
- sorter.write (toInsert)
498
+ sorter.insertAll (toInsert)
499
499
500
500
// A map of collision pairs in both directions
501
501
val collisionPairsMap = (collisionPairs ++ collisionPairs.map(_.swap)).toMap
@@ -524,7 +524,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
524
524
// Insert 10 copies each of lots of objects whose hash codes are either 0 or 1. This causes
525
525
// problems if the map fails to group together the objects with the same code (SPARK-2043).
526
526
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)
528
528
529
529
val it = sorter.iterator
530
530
var count = 0
@@ -548,7 +548,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
548
548
val agg = new Aggregator [Int , Int , ArrayBuffer [Int ]](createCombiner, mergeValue, mergeCombiners)
549
549
val sorter = new ExternalSorter [Int , Int , ArrayBuffer [Int ]](Some (agg), None , None , None )
550
550
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 )))
552
552
553
553
val it = sorter.iterator
554
554
while (it.hasNext) {
@@ -572,7 +572,7 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext {
572
572
val sorter = new ExternalSorter [String , String , ArrayBuffer [String ]](
573
573
Some (agg), None , None , None )
574
574
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 (
576
576
(null .asInstanceOf [String ], " 1" ),
577
577
(" 1" , null .asInstanceOf [String ]),
578
578
(null .asInstanceOf [String ], null .asInstanceOf [String ])
0 commit comments