exceptionfactory commented on code in PR #10769:
URL: https://github.com/apache/nifi/pull/10769#discussion_r2765695453


##########
nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-service-shared/src/main/java/org/apache/nifi/kafka/service/consumer/Kafka3ConsumerService.java:
##########
@@ -209,6 +239,12 @@ public boolean hasNext() {
         @Override
         public ByteRecord next() {
             final ConsumerRecord<byte[], byte[]> consumerRecord = 
consumerRecords.next();
+
+            // Track the offset for potential commit during rebalance
+            // Store offset + 1 because Kafka commits the next offset to 
consume
+            final TopicPartition topicPartition = new 
TopicPartition(consumerRecord.topic(), consumerRecord.partition());

Review Comment:
   This approach still involves creating a new `TopicPartition` for every 
record processed. Optimizing this approach would help avoid the creation of 
many duplicative objects. One option is to have a `currentTopicPartition`, 
check the topic and partition values of the `consumerRecord`, and only create a 
new instance of `TopicPartition` if the values are different. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to