RyanSkraba commented on code in PR #24632:
URL: https://github.com/apache/flink/pull/24632#discussion_r1572359539


##########
flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/fs/hdfs/HadoopDataInputStream.java:
##########
@@ -140,4 +144,56 @@ public void skipFully(long bytes) throws IOException {
             bytes -= fsDataInputStream.skip(bytes);
         }
     }
+
+    @Override
+    public int read(ByteBuffer byteBuffer) throws IOException {
+        // Not all internal stream supports ByteBufferReadable
+        if 
(fsDataInputStream.hasCapability(StreamCapabilities.READBYTEBUFFER)) {
+            return fsDataInputStream.read(byteBuffer);
+        } else {
+            if (byteBuffer.hasArray()) {
+                int len = byteBuffer.remaining();
+                fsDataInputStream.readFully(byteBuffer.array(), 
byteBuffer.arrayOffset(), len);
+                return len;
+            } else {
+                // Fallback to read byte then put
+                int c = read();
+                if (c == -1) {
+                    return -1;
+                }
+                byteBuffer.put((byte) c);
+
+                int n = 1, len = byteBuffer.remaining() + 1;
+                for (; n < len; n++) {
+                    c = read();
+                    if (c == -1) {
+                        break;
+                    }
+                    byteBuffer.put((byte) c);
+                }
+                return n;
+            }
+        }
+    }
+
+    @Override
+    public int read(long position, ByteBuffer byteBuffer) throws IOException {
+        // Not all internal stream supports ByteBufferPositionedReadable
+        if 
(fsDataInputStream.hasCapability(StreamCapabilities.PREADBYTEBUFFER)) {

Review Comment:
   Hello!  Unfortunately this causes a compile error when using Hadoop 3.2.3 
(found in the nightly builds).  I created  FLINK-35175 to address this.



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to