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

    https://github.com/apache/spark/pull/1058#discussion_r13724792
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/BlockManager.scala 
---
    @@ -637,76 +633,63 @@ private[spark] class BlockManager(
     
         // If we're storing bytes, then initiate the replication before 
storing them locally.
         // This is faster as data is already serialized and ready to send.
    -    val replicationFuture = if (data.isInstanceOf[ByteBufferValues] && 
level.replication > 1) {
    -      // Duplicate doesn't copy the bytes, just creates a wrapper
    -      val bufferView = 
data.asInstanceOf[ByteBufferValues].buffer.duplicate()
    -      Future {
    -        replicate(blockId, bufferView, level)
    -      }
    -    } else {
    -      null
    +    val replicationFuture = data match {
    +      case b: ByteBufferValues if level.replication > 1 =>
    +        // Duplicate doesn't copy the bytes, but just creates a wrapper
    +        val bufferView = b.buffer.duplicate()
    +        Future { replicate(blockId, bufferView, level) }
    +      case _ => null
         }
     
         putBlockInfo.synchronized {
    -      logTrace("Put for block " + blockId + " took " + 
Utils.getUsedTimeMs(startTimeMs)
    -        + " to get into synchronized block")
    +      logTrace(s"Putting block $blockId took 
${Utils.getUsedTimeMs(startTimeMs)} " +
    +        "to get into synchronized block")
     
           var marked = false
           try {
    +        // Whether to return the values put
    --- End diff --
    
    This is the only non-trivial part about this PR. I basically factored out 
the matching of `data` to the appropriate value type, so we don't need to do 
this for each case (i.e. `useMemory`, `useOffHeap`, `useDisk`)


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

Reply via email to