Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java API for Merge Operator v2 #12122

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

rhubner
Copy link
Contributor

@rhubner rhubner commented Dec 6, 2023

This is the first implementation of the merge operator API, where merge operators can be implemented in Java without any C++ code. It prefers simplicity and community feedback is appreciated.

Copy link
Contributor

@alanpaxton alanpaxton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things to tidy up. Looks good apart from those.

java/src/test/java/org/rocksdb/MergeOperatorV2Test.java Outdated Show resolved Hide resolved
java/src/main/java/org/rocksdb/MergeOperatorV2.java Outdated Show resolved Hide resolved
java/src/test/java/org/rocksdb/MergeOperatorV2Test.java Outdated Show resolved Hide resolved
java/src/main/java/org/rocksdb/InBuiltMergeOperator.java Outdated Show resolved Hide resolved
java/src/main/java/org/rocksdb/MergeOperator.java Outdated Show resolved Hide resolved
java/src/main/java/org/rocksdb/MergeOperatorV2.java Outdated Show resolved Hide resolved
java/rocksjni/jni_merge_operator_v2.cc Show resolved Hide resolved
if (j_merge_class == nullptr) {
return; // Exception
}
j_merge_class = static_cast<jclass>(env->NewGlobalRef(j_merge_class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JNI manual says NewGlobalRef() can return nullptr WITHOUT an exception, e.g. if the system is out of memory. So we should throw a Java exception here. Can you also check the other JNI methods you call, to confirm that they always set an exception on nullptr, and if they don't we should set one in each case.

Then fix the comments to say "XYZException has been thrown", or whatever is appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I check existing code and we don't throw exceptions when we can't create global references.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really ? That seems wrong, and may be an omission. If NewGlobalRef() is returning null, surely the right thing to do is to throw an exception, unless we somehow cope with j_merge_class as null ? So let us do it correctly here for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanpaxton Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'm happy.

@rhubner rhubner force-pushed the eb/merge-operator-v2 branch 3 times, most recently from 80ea516 to b6dc8f8 Compare December 19, 2023 07:42
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from b6dc8f8 to 32d42b3 Compare January 10, 2024 11:39
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch 3 times, most recently from 82606aa to 2b4c318 Compare February 7, 2024 12:26
@rhubner rhubner marked this pull request as ready for review February 7, 2024 13:28
@adamretter adamretter changed the title Java API for merge operator Java API for Merge Operator v2 Feb 7, 2024
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 2b4c318 to cc0bb1a Compare February 8, 2024 05:55
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from cc0bb1a to 96642ee Compare March 15, 2024 07:14
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 96642ee to 02fcc10 Compare March 28, 2024 07:26
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 02fcc10 to 41a2331 Compare June 19, 2024 13:55
INSTALL.md Outdated Show resolved Hide resolved
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 41a2331 to c9194d2 Compare July 2, 2024 12:37
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 3aa81ea to ff5b251 Compare July 9, 2024 16:08
@alanpaxton
Copy link
Contributor

@rhubner LGTM now in respect of changes I requested on previous review.

@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from ff5b251 to 5e0e913 Compare July 26, 2024 06:10
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 5e0e913 to 9947574 Compare August 29, 2024 13:13
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 9947574 to 971f57a Compare September 27, 2024 05:23
This is the first implementation of the merge operator API,
where merge operators can be implemented in Java without any C++ code.
It prefers simplicity and community feedback is appreciated.
@rhubner rhubner force-pushed the eb/merge-operator-v2 branch from 971f57a to a6c5c60 Compare September 30, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants