Github user andrewor14 commented on a diff in the pull request: https://github.com/apache/spark/pull/1165#discussion_r14809836 --- Diff: core/src/main/scala/org/apache/spark/storage/MemoryStore.scala --- @@ -87,9 +97,32 @@ 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) + val droppedBlocks = new ArrayBuffer[(BlockId, BlockStatus)] + val unfoldedValues = unfoldSafely(blockId, values, droppedBlocks) + unfoldedValues match { + case Left(arrayValues) => + // Values are fully unfolded in memory, so store them as an array + val result = putValues(blockId, arrayValues, level, returnValues) + droppedBlocks ++= result.droppedBlocks + PutResult(result.size, result.data, droppedBlocks) + case Right(iteratorValues) => + // Not enough space to unfold this block; drop to disk if applicable + logWarning(s"Not enough space to store $blockId in memory! Free memory is ${freeMemory}B.") + if (level.useDisk) { + logWarning(s"Persisting $blockId to disk instead.") + val newLevel = StorageLevel( + useDisk = true, + useMemory = false, + useOffHeap = false, + deserialized = false, + level.replication) + val result = blockManager.diskStore.putValues( --- End diff -- If there is, do we kick out the old one?
--- 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. ---