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

Implement missing compactrangeoptions from Java API #10880

Closed

Conversation

alanpaxton
Copy link
Contributor

@alanpaxton alanpaxton commented Oct 26, 2022

Add the following missing options to src/main/java/org/rocksdb/CompactRangeOptions.java and in java/rocksjni/options.cc in RocksJava.

For the descriptions and API see the C++ file include/rocksdb/options.h, specifically the struct CompactRangeOptions

  • full_history_ts_low
  • canceled

We changed the handle to return an object (of class Java_org_rocksdb_CompactRangeOptions) containing a ROCKSDB_NAMESPACE::CompactRangeOptions at (almost certainly) 0-offset, rather than a raw ROCKSDB_NAMESPACE::CompactRangeOptions.

The Java_org_rocksdb_CompactRangeOptions contains as supplementary fields objects (std::string, std::atomic) which are passed as pointers to the ROCKSDB_NAMESPACE::CompactRangeOptions and which must therefore live for as long as the ROCKSDB_NAMESPACE::CompactRangeOptions. By placing them in a Java_org_rocksdb_CompactRangeOptions we achieve this.

Because the field offset of the ROCKSDB_NAMESPACE::CompactRangeOptions member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change.

Testing

We added unit tests for getting and setting the newly implemented fields to CompactRangeOptionsTest

@alanpaxton alanpaxton marked this pull request as draft October 26, 2022 16:19
@alanpaxton alanpaxton force-pushed the eb-776-missing-compactrangeoptions branch from 23c8213 to 6620498 Compare October 27, 2022 11:12
@alanpaxton alanpaxton marked this pull request as ready for review October 27, 2022 11:15
@alanpaxton alanpaxton force-pushed the eb-776-missing-compactrangeoptions branch from 6620498 to 3acc39c Compare November 7, 2022 08:59
@adamretter adamretter self-requested a review November 22, 2022 11:03
Copy link
Collaborator

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

LGTM

@adamretter
Copy link
Collaborator

@jay-zhuang (cc @ajkr) could we get this one merged please?

@alanpaxton alanpaxton changed the title Eb 776 missing compactrangeoptions Implement missing compactrangeoptions from Java API Nov 22, 2022
@facebook-github-bot
Copy link
Contributor

@siying has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@adamretter
Copy link
Collaborator

Hi @ajkr @siying, just a polite enquiry - is there any progress towards getting this merged please?

@alanpaxton alanpaxton force-pushed the eb-776-missing-compactrangeoptions branch from f11be9b to 2b69eae Compare December 16, 2022 10:02
@facebook-github-bot
Copy link
Contributor

@alanpaxton has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@alanpaxton alanpaxton force-pushed the eb-776-missing-compactrangeoptions branch from 2b69eae to 99c9b4f Compare March 6, 2023 11:01
@facebook-github-bot
Copy link
Contributor

@alanpaxton has updated the pull request. You must reimport the pull request before landing.

@anand1976
Copy link
Contributor

@alanpaxton Please rebase

deal with “not set” values
and finish tests
Add CompactRangeOptions$Timestamp support in portal.h to construct new timestamp to return.
Adapt JNI method signature to form returning Timestamp.

Rename timestamp param for consistency.

# Conflicts:
#	java/rocksjni/portal.h
We changed the handle to return an object containing ROCKSDB_NAMESPACE::CompactRangeOptions at (probably) 0-offset, rather than a ROCKSDB_NAMESPACE::CompactRangeOptions.

Casting handle to ROCKSDB_NAMESPACE::CompactRangeOptions worked (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that.

# Conflicts:
#	java/rocksjni/compact_range_options.cc
@alanpaxton alanpaxton force-pushed the eb-776-missing-compactrangeoptions branch from 99c9b4f to 2bccb06 Compare May 23, 2023 09:28
@facebook-github-bot
Copy link
Contributor

@alanpaxton has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@anand1976 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@anand1976 merged this pull request in 93e0715.

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