Skip to content

Commit

Permalink
SPARK-22713__ExternalAppendOnlyMap_effective_spill: address styling i…
Browse files Browse the repository at this point in the history
…ssues commented by @cloud-fan .
  • Loading branch information
Eyal Farago committed Aug 13, 2018
1 parent 25be99b commit 855854a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Expand Up @@ -117,10 +117,7 @@ class ExternalAppendOnlyMap[K, V, C](
private val keyComparator = new HashComparator[K]
private val ser = serializer.newInstance()

/**
* Exposed for testing
*/
@volatile private[collection] var readingIterator: SpillableIterator = null
@volatile private var readingIterator: SpillableIterator = null

/**
* Number of files this map has spilled so far.
Expand Down Expand Up @@ -573,10 +570,7 @@ class ExternalAppendOnlyMap[K, V, C](
context.addTaskCompletionListener[Unit](context => cleanup())
}

/**
* Exposed for testing
*/
private[collection] class SpillableIterator(var upstream: Iterator[(K, C)])
private class SpillableIterator(var upstream: Iterator[(K, C)])
extends Iterator[(K, C)] {

private val SPILL_LOCK = new Object()
Expand All @@ -599,13 +593,13 @@ class ExternalAppendOnlyMap[K, V, C](
}
}

private def destroy() : Unit = {
private def destroy(): Unit = {
freeCurrentMap()
upstream = Iterator.empty
}

def toCompletionIterator: CompletionIterator[(K, C), SpillableIterator] = {
CompletionIterator[(K, C), SpillableIterator](this, this.destroy )
CompletionIterator[(K, C), SpillableIterator](this, this.destroy)
}

def readNext(): (K, C) = SPILL_LOCK.synchronized {
Expand Down
Expand Up @@ -459,7 +459,7 @@ class ExternalAppendOnlyMapSuite extends SparkFunSuite
// https://github.com/scala/scala/blob/2.13.x/test/junit/scala/tools/testing/AssertUtil.scala
// (lines 69-89)
// assert(map.currentMap == null)
eventually{
eventually {
System.gc()
// direct asserts introduced some macro generated code that held a reference to the map
val tmpIsNull = null == underlyingMapRef.get.orNull
Expand Down Expand Up @@ -518,7 +518,7 @@ class ExternalAppendOnlyMapSuite extends SparkFunSuite
// (lines 69-89)
assert(map.currentMap == null)

eventually{
eventually {
Thread.sleep(500)
System.gc()
// direct asserts introduced some macro generated code that held a reference to the map
Expand Down

0 comments on commit 855854a

Please sign in to comment.