This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new d78b5e568 feat(bindings/java): Speed up the performance of
`OperatorInputStream` (#7088)
d78b5e568 is described below
commit d78b5e568991050c24a4f1c0e2fb7c8d6746f5de
Author: Xuanwo <[email protected]>
AuthorDate: Tue Dec 23 00:01:14 2025 +0800
feat(bindings/java): Speed up the performance of `OperatorInputStream`
(#7088)
* Add benckmark for read
* refactor
* Fix build
* Cleanup
* Remove jmh
---
bindings/java/.gitignore | 6 ++++-
bindings/java/src/executor.rs | 2 +-
.../org/apache/opendal/OperatorInputStream.java | 27 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/bindings/java/.gitignore b/bindings/java/.gitignore
index 07a2ebae0..45ec3b63c 100644
--- a/bindings/java/.gitignore
+++ b/bindings/java/.gitignore
@@ -1,4 +1,8 @@
+bin/
.mvn/wrapper/maven-wrapper.jar
Cargo.lock
-
+.project
+.factorypath
*.log
+.settings/
+.classpath
diff --git a/bindings/java/src/executor.rs b/bindings/java/src/executor.rs
index af0dd13f5..caa8263ae 100644
--- a/bindings/java/src/executor.rs
+++ b/bindings/java/src/executor.rs
@@ -129,7 +129,7 @@ pub(crate) fn make_tokio_executor(env: &mut JNIEnv, cores:
usize) -> Result<Exec
move || {
ENV.with(|cell| {
let mut env = vm
- .attach_current_thread_permanently()
+ .attach_current_thread_as_daemon()
.expect("attach thread must succeed");
set_current_thread_name(&mut env)
diff --git
a/bindings/java/src/main/java/org/apache/opendal/OperatorInputStream.java
b/bindings/java/src/main/java/org/apache/opendal/OperatorInputStream.java
index edb11d26b..0bf774c8f 100644
--- a/bindings/java/src/main/java/org/apache/opendal/OperatorInputStream.java
+++ b/bindings/java/src/main/java/org/apache/opendal/OperatorInputStream.java
@@ -58,6 +58,33 @@ public class OperatorInputStream extends InputStream {
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;
+ }
+
@Override
public void close() throws IOException {
reader.close();