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

    https://github.com/apache/flink/pull/3314#discussion_r102900986
  
    --- Diff: 
flink-connectors/flink-connector-kafka-0.9/src/main/java/org/apache/flink/streaming/connectors/kafka/internal/Kafka09Fetcher.java
 ---
    @@ -142,25 +141,38 @@ public void runFetchLoop() throws Exception {
                                final ConsumerRecords<byte[], byte[]> records = 
handover.pollNext();
     
                                // get the records for each topic partition
    -                           for (KafkaTopicPartitionState<TopicPartition> 
partition : subscribedPartitions()) {
    +                           for (final 
KafkaTopicPartitionState<TopicPartition> partition : subscribedPartitions()) {
     
                                        List<ConsumerRecord<byte[], byte[]>> 
partitionRecords =
                                                        
records.records(partition.getKafkaPartitionHandle());
     
    -                                   for (ConsumerRecord<byte[], byte[]> 
record : partitionRecords) {
    -                                           final T value = 
deserializer.deserialize(
    -                                                           record.key(), 
record.value(),
    -                                                           record.topic(), 
record.partition(), record.offset());
    -
    -                                           if 
(deserializer.isEndOfStream(value)) {
    -                                                   // end of stream 
signaled
    -                                                   running = false;
    -                                                   break;
    -                                           }
    -
    -                                           // emit the actual record. this 
also updates offset state atomically
    -                                           // and deals with timestamps 
and watermark generation
    -                                           emitRecord(value, partition, 
record.offset(), record);
    +                                   for (final ConsumerRecord<byte[], 
byte[]> record : partitionRecords) {
    +                                           final Collector<T> collector = 
new Collector<T>() {
    +                                                   @Override
    +                                                   public void collect(T 
value) {
    +                                                           if 
(deserializer.isEndOfStream(value)) {
    +                                                                   // end 
of stream signaled
    +                                                                   running 
= false;
    +                                                           } else {
    +                                                                   // emit 
the actual record. this also updates offset state atomically
    +                                                                   // and 
deals with timestamps and watermark generation
    +                                                                   try {
    +                                                                           
emitRecord(value, partition, record.offset(), record);
    +                                                                   } catch 
(Exception e) {
    +                                                                           
throw new RuntimeException(e);
    +                                                                   }
    +                                                           }
    +                                                   }
    +
    +                                                   @Override
    +                                                   public void close() {
    +
    +                                                   }
    +                                           };
    +
    +                                           deserializer.deserialize(
    +                                                   record.key(), 
record.value(),
    +                                                   record.topic(), 
record.partition(), record.offset(), collector);
    --- End diff --
    
    The formatting for the list of arguments here could be nicer. Perhaps one 
argument per line?


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

Reply via email to