Skip to content

Commit

Permalink
[SPARK-7181] [CORE] fix inifite loop in Externalsorter's mergeWithAgg…
Browse files Browse the repository at this point in the history
…regation

see [SPARK-7181](https://issues.apache.org/jira/browse/SPARK-7181).

Author: Qiping Li <liqiping1991@gmail.com>

Closes apache#5737 from chouqin/externalsorter and squashes the following commits:

2924b93 [Qiping Li] fix inifite loop in Externalsorter's mergeWithAggregation
  • Loading branch information
chouqin authored and nemccarthy committed Jun 19, 2015
1 parent c5ad4c2 commit 679d91c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -527,7 +527,8 @@ private[spark] class ExternalSorter[K, V, C](
val k = elem._1
var c = elem._2
while (sorted.hasNext && sorted.head._1 == k) {
c = mergeCombiners(c, sorted.head._2)
val pair = sorted.next()
c = mergeCombiners(c, pair._2)
}
(k, c)
}
Expand Down
Expand Up @@ -506,7 +506,10 @@ class ExternalSorterSuite extends FunSuite with LocalSparkContext with PrivateMe
val agg = new Aggregator[Int, Int, Int](i => i, (i, j) => i + j, (i, j) => i + j)
val ord = implicitly[Ordering[Int]]
val sorter = new ExternalSorter(Some(agg), Some(new HashPartitioner(3)), Some(ord), None)
sorter.insertAll((0 until 100000).iterator.map(i => (i / 2, i)))

// avoid combine before spill
sorter.insertAll((0 until 50000).iterator.map(i => (i , 2 * i)))
sorter.insertAll((0 until 50000).iterator.map(i => (i, 2 * i + 1)))
val results = sorter.partitionedIterator.map{case (p, vs) => (p, vs.toSet)}.toSet
val expected = (0 until 3).map(p => {
(p, (0 until 50000).map(i => (i, i * 4 + 1)).filter(_._1 % 3 == p).toSet)
Expand Down

0 comments on commit 679d91c

Please sign in to comment.