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

    https://github.com/apache/spark/pull/1165#discussion_r14809771
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/BlockManager.scala 
---
    @@ -463,16 +463,16 @@ private[spark] class BlockManager(
                   val values = dataDeserialize(blockId, bytes)
                   if (level.deserialized) {
                     // Cache the values before returning them
    -                // TODO: Consider creating a putValues that also takes in 
a iterator?
    -                val valuesBuffer = new ArrayBuffer[Any]
    -                valuesBuffer ++= values
    -                memoryStore.putValues(blockId, valuesBuffer, level, 
returnValues = true).data
    -                  match {
    -                    case Left(values2) =>
    -                      return Some(new BlockResult(values2, 
DataReadMethod.Disk, info.size))
    -                    case _ =>
    -                      throw new SparkException("Memory store did not 
return back an iterator")
    -                  }
    +                val putResult = memoryStore.putValues(blockId, values, 
level, returnValues = true)
    +                putResult.data match {
    +                  case Left(it) =>
    +                    return Some(new BlockResult(it, DataReadMethod.Disk, 
info.size))
    +                  case Right(b) =>
    +                    return Some(new BlockResult(
    +                      dataDeserialize(blockId, b),
    --- End diff --
    
    You can't just return `values` because `memoryStore.putValues` already 
exhausted the iterator. This is one of those places where we `put` the values 
as an iterator somewhere and read them back in order to return them.


---
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