Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/11502#discussion_r55107596
--- Diff: core/src/main/scala/org/apache/spark/storage/BlockManager.scala
---
@@ -801,43 +798,45 @@ private[spark] class BlockManager(
}
var blockWasSuccessfullyStored = false
- var result: PutResult = null
+ var iteratorFromFailedMemoryStorePut: Option[Iterator[Any]] = None
putBlockInfo.synchronized {
logTrace("Put for block %s took %s to get into synchronized block"
.format(blockId, Utils.getUsedTimeMs(startTimeMs)))
try {
- // returnValues - Whether to return the values put
- // blockStore - The type of storage to put these values into
- val (returnValues, blockStore: BlockStore) = {
- if (putLevel.useMemory) {
- // Put it in memory first, even if it also has useDisk set to
true;
- // We will drop it to disk later if the memory store can't
hold it.
- (true, memoryStore)
- } else if (putLevel.useDisk) {
- // Don't get back the bytes from put unless we replicate them
- (putLevel.replication > 1, diskStore)
- } else {
- assert(putLevel == StorageLevel.NONE)
- throw new BlockException(
- blockId, s"Attempted to put block $blockId without
specifying storage level!")
+ if (putLevel.useMemory) {
+ // Put it in memory first, even if it also has useDisk set to
true;
+ // We will drop it to disk later if the memory store can't hold
it.
+ data match {
+ case IteratorValues(iterator) =>
+ memoryStore.putIterator(blockId, iterator(), putLevel) match
{
+ case Right(s) =>
+ size = s
+ case Left(iter) =>
+ iteratorFromFailedMemoryStorePut = Some(iter)
+ }
+ case ByteBufferValues(bytes) =>
+ bytes.rewind()
+ size = bytes.limit()
+ memoryStore.putBytes(blockId, bytes, putLevel)
}
- }
-
- // Actually put the values
- result = data match {
- case IteratorValues(iterator) =>
- blockStore.putIterator(blockId, iterator(), putLevel,
returnValues)
- case ByteBufferValues(bytes) =>
- bytes.rewind()
- blockStore.putBytes(blockId, bytes, putLevel)
- }
- size = result.size
- result.data match {
- case Left (newIterator) if putLevel.useMemory => valuesAfterPut
= newIterator
- case Right (newBytes) => bytesAfterPut = newBytes
- case _ =>
+ } else if (putLevel.useDisk) {
+ data match {
+ case IteratorValues(iterator) =>
+ diskStore.putIterator(blockId, iterator(), putLevel) match {
+ case Right(s) =>
+ size = s
--- End diff --
Nope, it can't; the return type of `putIterator` is actually `Right` (check
the signature). That's why this isn't complaining about a partial match.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]