xintongsong commented on a change in pull request #14904: URL: https://github.com/apache/flink/pull/14904#discussion_r575744928
########## File path: flink-core/src/main/java/org/apache/flink/core/memory/HybridMemorySegment.java ########## @@ -357,4 +385,9 @@ public final void put(int offset, ByteBuffer source, int numBytes) { } } } + + @Override + public <T> T processAsByteBuffer(Function<ByteBuffer, T> processFunction) { + return Preconditions.checkNotNull(processFunction).apply(wrapInternal(0, size)); + } Review comment: > Which calls to wrap cannot be replaced with this call? Technically, I don't think there are `wrap` calls that CANNOT be replaced. Some of the calls only wrap part of the segment, which can be solved by simply adding `offset` and `length` as arguments. I have not replaced all calls to `wrap` with this `processAsByteBuffer`, mostly because the remaining calls are on direct segment, thus it's not necessary to migrate them. > Do we know what the performance penalty for the additional Function is? We don't have a measurement. However, given that this method is for the per-segment operation (by default 32KB), I don't expect a significant performance penalty from using the `Function`. ---------------------------------------------------------------- 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: us...@infra.apache.org