Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/50#discussion_r10238815
  
    --- Diff: core/src/main/scala/org/apache/spark/CacheManager.scala ---
    @@ -71,10 +71,21 @@ private[spark] class CacheManager(blockManager: 
BlockManager) extends Logging {
               val computedValues = rdd.computeOrReadCheckpoint(split, context)
               // Persist the result, so long as the task is not running locally
               if (context.runningLocally) { return computedValues }
    -          val elements = new ArrayBuffer[Any]
    -          elements ++= computedValues
    -          blockManager.put(key, elements, storageLevel, tellMaster = true)
    -          elements.iterator.asInstanceOf[Iterator[T]]
    +          if (storageLevel.useDisk && !storageLevel.useMemory) {
    +            blockManager.put(key, computedValues, storageLevel, tellMaster 
= true)
    +            return blockManager.get(key) match {
    +              case Some(values) =>
    +                return new InterruptibleIterator(context, 
values.asInstanceOf[Iterator[T]])
    +              case None =>
    +                logInfo("Failure to store %s".format(key))
    +                return null
    +            }
    +          } else {
    +            val elements = new ArrayBuffer[Any]
    +            elements ++= computedValues
    +            blockManager.put(key, elements, storageLevel, tellMaster = 
true)
    +            return elements.iterator.asInstanceOf[Iterator[T]]
    +          }
    --- End diff --
    
    Is there any reason why we still want to keep around the legacy case? It 
seems that the IteratorValues and ArrayBufferValues are handled in very similar 
ways downstream (e.g. in BlockManager.doPut, and memoryStore.putValues), and it 
would be nice if we could somehow merge these two code paths into a simpler one.
    
    The other thing is that computeValues in L71 is already an iterator anyway, 
so we can just feed this directly into BlockManager. The existing way of making 
it an ArrayBuffer arbitrarily and back into an Iterator seems a little 
unnecessary.
    
    (That said, there might be a performance reason that I haven't thought of.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to