zhijiangW commented on a change in pull request #12353:
URL: https://github.com/apache/flink/pull/12353#discussion_r439225144



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferConsumer.java
##########
@@ -118,6 +118,16 @@ public BufferConsumer copy() {
                return new BufferConsumer(buffer.retainBuffer(), 
writerPosition.positionMarker, currentReaderPosition);
        }
 
+       /**
+        * Returns a retained copy with separate indexes and syncs it with the 
current position of the given {@link BufferBuilder}.
+        * This allows to read from the same {@link MemorySegment} twice 
starting from the position of the builder.
+        *
+        * @return a retained copy of self with separate indexes
+        */
+       public BufferConsumer copyAndSync(BufferBuilder builder) {

Review comment:
       How about renaming it as `copyWithReaderPosition(int readerPosition)`? 
The semantic of this method is for copying the current consumer with setting 
any reader position which is not only limited to `builder.getCommittedBytes()`, 
and then we can pass the `builder.getCommittedBytes()` from the caller by 
different usages.
   
   Another consideration is that only build creates the respective consumer in 
single direction, so consumer will not see the builder before. 
`copyWithReaderPosition(int readerPosition)` can avoid touching builder somehow 
from public way.




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

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


Reply via email to