pnowojski commented on a change in pull request #11751: [FLINK-16587][network]
Provide the method for getting unconsumed buffer from RecordDeserializer
URL: https://github.com/apache/flink/pull/11751#discussion_r408881376
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/serialization/SpillingAdaptiveSpanningRecordDeserializer.java
##########
@@ -95,13 +96,14 @@ public Buffer getCurrentBuffer () {
}
@Override
- public Optional<Buffer> getUnconsumedBuffer() {
+ public Optional<Buffer> getUnconsumedBuffer() throws IOException {
+ Optional<MemorySegment> target;
if (nonSpanningWrapper.remaining() > 0) {
- return Optional.of(new
NetworkBuffer(nonSpanningWrapper.copyToTargetSegment(),
FreeingBufferRecycler.INSTANCE));
+ target = nonSpanningWrapper.getUnconsumedSegment();
} else {
- MemorySegment target =
spanningWrapper.copyToTargetSegment();
- return target != null ? Optional.of(new
NetworkBuffer(target, FreeingBufferRecycler.INSTANCE)) : Optional.empty();
+ target = spanningWrapper.getUnconsumedSegment();
}
+ return target.map(memorySegment -> new
NetworkBuffer(memorySegment, FreeingBufferRecycler.INSTANCE, true,
memorySegment.size()));
Review comment:
:)
----------------------------------------------------------------
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]
With regards,
Apache Git Services