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

    https://github.com/apache/spark/pull/1165#discussion_r15270521
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/MemoryStore.scala ---
    @@ -87,9 +97,46 @@ private class MemoryStore(blockManager: BlockManager, 
maxMemory: Long)
           values: Iterator[Any],
           level: StorageLevel,
           returnValues: Boolean): PutResult = {
    -    val valueEntries = new ArrayBuffer[Any]()
    -    valueEntries ++= values
    -    putValues(blockId, valueEntries, level, returnValues)
    +    putValues(blockId, values, level, returnValues, allowPersistToDisk = 
true)
    +  }
    +
    +  /**
    +   * Attempt to put the given block in memory store.
    +   *
    +   * There may not be enough space to fully unroll the iterator in memory, 
in which case we
    +   * optionally drop the values to disk if
    +   *   (1) the block's storage level specifies useDisk, and
    +   *   (2) `allowPersistToDisk` is true.
    +   *
    +   * One scenario in which `allowPersistToDisk` is false is when the 
BlockManager reads a block
    +   * back from disk and attempts to cache it in memory. In this case, we 
should not persist the
    +   * block back on disk again, as it is already in disk store.
    +   */
    +  private[storage] def putValues(
    +      blockId: BlockId,
    +      values: Iterator[Any],
    +      level: StorageLevel,
    +      returnValues: Boolean,
    +      allowPersistToDisk: Boolean): PutResult = {
    +    val droppedBlocks = new ArrayBuffer[(BlockId, BlockStatus)]
    +    val unrolledValues = unrollSafely(blockId, values, droppedBlocks)
    +    unrolledValues match {
    +      case Left(arrayValues) =>
    +        // Values are fully unrolled in memory, so store them as an array
    +        val res = putValues(blockId, arrayValues, level, returnValues)
    +        droppedBlocks ++= res.droppedBlocks
    +        PutResult(res.size, res.data, droppedBlocks)
    +      case Right(iteratorValues) =>
    +        // Not enough space to unroll this block; drop to disk if 
applicable
    +        logWarning(s"Not enough space to store $blockId in memory! Free 
memory is ${freeMemory}B.")
    --- End diff --
    
    Same here, instead of `$key` write `partition $key`


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