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

    https://github.com/apache/spark/pull/7825#discussion_r36258722
  
    --- Diff: 
extras/kinesis-asl/src/main/scala/org/apache/spark/streaming/kinesis/KinesisReceiver.scala
 ---
    @@ -165,6 +199,81 @@ private[kinesis] class KinesisReceiver(
         workerId = null
       }
     
    +  /** Add records of the given shard to the current block being generated 
*/
    +  private[kinesis] def addRecords(shardId: String, records: 
java.util.List[Record]): Unit = {
    +    if (records.size > 0) {
    +      val dataIterator = records.iterator().map { record =>
    +        val byteBuffer = record.getData()
    +        val byteArray = new Array[Byte](byteBuffer.remaining())
    +        byteBuffer.get(byteArray)
    +        byteArray
    +      }
    +      val metadata = SequenceNumberRange(streamName, shardId,
    +        records.get(0).getSequenceNumber(), records.get(records.size() - 
1).getSequenceNumber())
    +      blockGenerator.addMultipleDataWithCallback(dataIterator, metadata)
    +
    +    }
    +  }
    +
    +  /** Get the latest sequence number for the given shard that can be 
checkpointed through KCL */
    +  private[kinesis] def getLatestSeqNumToCheckpoint(shardId: String): 
Option[String] = {
    +    shardIdToLatestStoredSeqNum.get(shardId)
    +  }
    +
    +  /**
    +   * Remember the range of sequence numbers that was added to the 
currently active block.
    +   * Internally, this is synchronized with 
`finalizeRangesForCurrentBlock()`.
    +   */
    +  private def rememberAddedRange(range: SequenceNumberRange): Unit = {
    +    seqNumRangesInCurrentBlock += range
    +  }
    +
    +  /**
    +   * Finalize the ranges added to the block that was active and prepare 
the ranges buffer
    +   * for next block. Internally, this is synchronized with 
`rememberAddedRange()`.
    +   */
    +  private def finalizeRangesForCurrentBlock(blockId: StreamBlockId): Unit 
= {
    +    blockIdToSeqNumRanges(blockId) = 
SequenceNumberRanges(seqNumRangesInCurrentBlock.toSeq)
    --- End diff --
    
    I think you should call `toIndexedSeq`. `toSeq` just returns itself for 
ArrayBuffer. E.g.:
    
    ```
    scala> val x = new scala.collection.mutable.ArrayBuffer[Int]
    x: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer()
    
    scala> x eq x.toSeq
    res0: Boolean = true
    
    scala> x eq x.toIndexedSeq
    res1: Boolean = false
    ```
    



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

Reply via email to