Skip to content
Prev Previous commit
Next Next commit
refractor code
  • Loading branch information
lianhuiwang committed Jun 29, 2015
commit eb04478ca1f10fb1d40a3c4114aef681d4fa7289
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@ class ExternalAppendOnlyMap[K, V, C](
spilledMaps.append(spillMemoryToDisk(it))
}

def diskBytesSpilled: Long = _diskBytesSpilled

/**
* Return an iterator that merges the in-memory map with the spilled maps.
* If no spill has occurred, simply return the in-memory map's iterator.
*/
override def iterator: Iterator[(K, C)] = {
shuffleMemoryManager.addSpillableToReservedList(this)
if (spilledMaps.isEmpty) {
memoryOrDiskIter = Some(MemoryOrDiskIterator(currentMap.iterator))
memoryOrDiskIter.get
} else {
new ExternalIterator()
}
}

/**
* spill contents of the in-memory map to a temporary file on disk.
*/
Expand Down Expand Up @@ -231,6 +215,22 @@ class ExternalAppendOnlyMap[K, V, C](
new DiskMapIterator(file, blockId, batchSizes)
}

def diskBytesSpilled: Long = _diskBytesSpilled

/**
* Return an iterator that merges the in-memory map with the spilled maps.
* If no spill has occurred, simply return the in-memory map's iterator.
*/
override def iterator: Iterator[(K, C)] = {
shuffleMemoryManager.addSpillableToReservedList(this)
if (spilledMaps.isEmpty) {
memoryOrDiskIter = Some(MemoryOrDiskIterator(currentMap.iterator))
memoryOrDiskIter.get
} else {
new ExternalIterator()
}
}

/**
* spill contents of memory map to disk
*/
Expand Down