rkhachatryan commented on a change in pull request #12120:
URL: https://github.com/apache/flink/pull/12120#discussion_r425065870
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/serialization/NonSpanningWrapper.java
##########
@@ -290,4 +313,55 @@ public int read(byte[] b, int off, int len) {
public int read(byte[] b) {
return read(b, 0, b.length);
}
+
+ Tuple2<ByteBuffer, Integer> wrapIntoByteBuffer() {
+ int numBytes = remaining();
+ return Tuple2.of(segment.wrap(position, numBytes), numBytes);
+ }
+
+ int copyTo(byte[] dst) {
+ final int numBytesChunk = remaining();
+ segment.get(position, dst, 0, numBytesChunk);
+ return numBytesChunk;
+ }
+
+ /**
+ * We have an incomplete length add our part of the length to the
length buffer.
+ */
+ void transferTo(ByteBuffer dst) {
+ segment.get(position, dst, remaining());
+ clear();
+ }
Review comment:
`copyTo` only copies data, while `transferTo` transfers "ownership" (and
that's why it calls `clear()`). Added Javadoc for this method.
----------------------------------------------------------------
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]