wgtmac commented on code in PR #3041: URL: https://github.com/apache/parquet-java/pull/3041#discussion_r1827206140
########## parquet-common/src/main/java/org/apache/parquet/bytes/BytesInput.java: ########## @@ -376,7 +377,11 @@ void writeInto(ByteBuffer buffer) { ByteBuffer workBuf = buffer.duplicate(); int pos = buffer.position(); workBuf.limit(pos + byteCount); - Channels.newChannel(in).read(workBuf); + ReadableByteChannel channel = Channels.newChannel(in); + int remaining = byteCount; + while (remaining > 0) { + remaining -= channel.read(workBuf); Review Comment: Is `remaining` reliable? Should we check the return value of `channel.read(workBuf)`? ########## parquet-common/src/test/java/org/apache/parquet/bytes/TestBytesInput.java: ########## @@ -140,6 +140,20 @@ public void testFromInputStream() throws IOException { validate(data, factory); } + @Test + public void testFromLargeAvailableAgnosticInputStream() throws IOException { + // allocate a bytes that large than + // java.nio.channel.Channels.ReadableByteChannelImpl.TRANSFER_SIZE = 8192 + byte[] data = new byte[9 * 1024]; + RANDOM.nextBytes(data); + byte[] input = new byte[data.length + 10]; + RANDOM.nextBytes(input); + System.arraycopy(data, 0, input, 0, data.length); + Supplier<BytesInput> factory = () -> BytesInput.from(new AvailableAgnosticInputStream(input), 9 * 1024); Review Comment: What about using an anonymous class here instead of adding a new file? -- 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...@parquet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@parquet.apache.org For additional commands, e-mail: issues-h...@parquet.apache.org