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

    https://github.com/apache/flink/pull/3314#discussion_r102881092
  
    --- Diff: 
flink-connectors/flink-connector-kafka-0.8/src/main/java/org/apache/flink/streaming/connectors/kafka/internals/SimpleConsumerThread.java
 ---
    @@ -373,16 +370,28 @@ else if (partitionsRemoved) {
                                                                
keyPayload.get(keyBytes);
                                                        }
     
    -                                                   final T value = 
deserializer.deserialize(keyBytes, valueBytes, 
    -                                                                   
currentPartition.getTopic(), currentPartition.getPartition(), offset);
    -                                                   
    -                                                   if 
(deserializer.isEndOfStream(value)) {
    -                                                           // remove 
partition from subscribed partitions.
    -                                                           
partitionsIterator.remove();
    -                                                           continue 
partitionsLoop;
    -                                                   }
    -                                                   
    -                                                   owner.emitRecord(value, 
currentPartition, offset);
    +                                                   final Collector<T> 
collector = new Collector<T>() {
    --- End diff --
    
    @haohui hmm this seems a bit odd to me. I think it should be achievable.
    
    ```
    // the buffer; this can be shared
    final List<T> bufferedElements = new LinkedList<>();
    // BufferCollector is an implementation of Collector that adds collected 
elements to bufferedElements; this can be shared
    final BufferCollector collector = new BufferCollector<T>(bufferedElements);
    
    ...
    
    for (final ConsumerRecord<byte[], byte[]> record : partitionRecords) {
        deserializer.deserialize(
            record.key(), record.value(), record.topic(),
            record.partition(), record.offset(), collector);
    
        emitRecords(bufferedElements, partitionState, record.offset(), record);
    
        bufferedElements.clear(); // after the elements for the record have 
been emitted, empty out the buffer
    }
    ```
    
    Doesn't this work? I haven't really tried this hands-on, so I might be 
overlooking something. Let me know what you think :)


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