StephanEwen commented on a change in pull request #8895:
[FLINK-12536][Runtime/Network]Make BufferOrEventSequence#getNext non blocking
URL: https://github.com/apache/flink/pull/8895#discussion_r299343554
##########
File path: flink-core/src/main/java/org/apache/flink/util/IOUtils.java
##########
@@ -139,6 +141,24 @@ public static void readFully(final InputStream in, final
byte[] buf, int off, fi
}
}
+ /**
+ * Reads bytes into ByteBuffer, blocking until all ByteBuffer is full.
+ *
+ * @param fileChannel The source where we read from
+ * @param buffer The target we'll write the bytes to.
+ * @throws IOException If we could not read requested number of bytes
for any reason (including EOF)
+ */
+ public static void readFully(FileChannel fileChannel, ByteBuffer
buffer) throws IOException {
+ int toRead = buffer.limit() - buffer.position();
+ while (toRead > 0) {
Review comment:
This can be simplified to `while (buffer.hasRemaining())`
----------------------------------------------------------------
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