Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/7825#discussion_r36263794
--- 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 --
Very good catch. I replaced with toArray. Would probably be more efficient
when serialized. That's why I wanted to keep `ranges` as array to ensure
efficient serialization. Probably not a big deal.
---
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]