Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/16114#discussion_r91184750
--- Diff:
external/kinesis-asl/src/main/scala/org/apache/spark/streaming/kinesis/KinesisRecordProcessor.scala
---
@@ -68,9 +69,16 @@ private[kinesis] class
KinesisRecordProcessor[T](receiver: KinesisReceiver[T], w
override def processRecords(batch: List[Record], checkpointer:
IRecordProcessorCheckpointer) {
if (!receiver.isStopped()) {
try {
- receiver.addRecords(shardId, batch)
- logDebug(s"Stored: Worker $workerId stored ${batch.size} records
for shardId $shardId")
- receiver.setCheckpointer(shardId, checkpointer)
+ // Limit the number of processed records from Kinesis stream. This
is because the KCL cannot
+ // control the number of aggregated records to be fetched even if
we set `MaxRecords`
+ // in `KinesisClientLibConfiguration`. For example, if we set 10
to the number of max
+ // records in a worker and a producer aggregates two records into
one message, the worker
+ // possibly 20 records every callback function called.
+ batch.asScala.grouped(receiver.getCurrentLimit).foreach { batch =>
--- End diff --
Sorry, one last comment -- `batch` is used for the overall data set and
each subset. They should be named differently for clarity.
It's also my fault for not realizing the collections here were Java not
Scala, and you have to convert to use the nice Scala idiom. I think it's OK as
it's just going to wrap and not copy the class, but it does bear being careful
about performance here.
---
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]