You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/04/15 14:22:34 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #11751: [FLINK-16587][network] Provide the method for getting unconsumed buffer from RecordDeserializer

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:
users@infra.apache.org


With regards,
Apache Git Services