tisonkun commented on code in PR #7088:
URL: https://github.com/apache/opendal/pull/7088#discussion_r2640208265
##########
bindings/java/src/main/java/org/apache/opendal/OperatorInputStream.java:
##########
@@ -58,6 +58,33 @@ public int read() throws IOException {
return -1;
}
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ }
+ if (off < 0 || len < 0 || len > b.length - off) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (len == 0) {
+ return 0;
+ }
+
+ while (bytes != null && offset >= bytes.length) {
+ bytes = readNextBytes(reader.nativeHandle);
+ offset = 0;
+ }
+
+ if (bytes == null) {
+ return -1;
+ }
+
+ final int n = Math.min(len, bytes.length - offset);
+ System.arraycopy(bytes, offset, b, off, n);
+ offset += n;
+ return n;
Review Comment:
Perhaps read as much as `len` as possible?
Currently, it reads what remaining in the bytes buffer or read at most once.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]