spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zsxwing <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-8080][STREAMING] Receiver.store with It...
Date Mon, 08 Jun 2015 15:30:06 GMT
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6707#discussion_r31926597
  
    --- Diff: streaming/src/main/scala/org/apache/spark/streaming/receiver/ReceivedBlockHandler.scala
---
    @@ -64,11 +68,17 @@ private[streaming] class BlockManagerBasedBlockHandler(
       extends ReceivedBlockHandler with Logging {
     
       def storeBlock(blockId: StreamBlockId, block: ReceivedBlock): ReceivedBlockStoreResult
= {
    +    var numRecords = None: Option[Long]
    +    val countIterator = block match {
    +      case ArrayBufferBlock(arrayBuffer) => new CountingIterator(arrayBuffer.iterator)
    +      case IteratorBlock(iterator) => new CountingIterator(iterator)
    +      case _ => null
    +    }
         val putResult: Seq[(BlockId, BlockStatus)] = block match {
           case ArrayBufferBlock(arrayBuffer) =>
    -        blockManager.putIterator(blockId, arrayBuffer.iterator, storageLevel, tellMaster
= true)
    +        blockManager.putIterator(blockId, countIterator, storageLevel, tellMaster = true)
    --- End diff --
    
    Could you create `CountingIterator` here and put `numRecords = Some(countIterator.count)`
after  `putIterator`? Then you could avoid matching `block` twice.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message