spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pwendell <...@git.apache.org>
Subject [GitHub] spark pull request: [Minor] Fix style, formatting and naming in Bl...
Date Thu, 12 Jun 2014 21:36:18 GMT
Github user pwendell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1058#discussion_r13727924
  
    --- 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
    +        var returnValues: Boolean = false
    +        // The type of storage to put these values into
    +        var blockStore: BlockStore = null
    --- End diff --
    
    I looked this part over and it seemed good. Did you consider making these two things `val`'s
and just assigning them with an if statement?
    
    ```
    val (returnValues, blockStore) {
      if (level.useMemory) {
        (true, memoryStore)
      }
      ...
    }
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message