tisonkun commented on code in PR #7097:
URL: https://github.com/apache/opendal/pull/7097#discussion_r2646727725
##########
bindings/java/src/test/java/org/apache/opendal/test/OperatorInputOutputStreamTest.java:
##########
@@ -62,4 +64,44 @@ void testReadWriteWithStream() throws Exception {
}
}
}
+
+ @Test
+ void testCreateInputStreamWithOptions() {
+ final ServiceConfig.Fs fs =
+ ServiceConfig.Fs.builder().root(tempDir.toString()).build();
+ try (final Operator op = Operator.of(fs)) {
+ final String path = "testCreateInputStreamWithOptions.txt";
+ final String content = "0123456789";
+ op.write(path, content);
+
+ try (final OperatorInputStream is = op.createInputStream(
+ path,
ReadOptions.builder().offset(4L).length(5L).build())) {
+ final byte[] buffer = new byte[5];
+ final int read = is.read(buffer, 0, 5);
+ assertThat(read).isEqualTo(5);
+ assertThat(new String(buffer)).isEqualTo("45678");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
Review Comment:
Interesting. What if we read once more?
That is, while I generally understand supporting ReadOptions to the input
stream, I'm not quite sure what OpenDAL's reader should do if a range is
specified - will it ends as finished? cc @Xuanwo
--
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]