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

[RocksJava] Allow iterators to be refreshed with new data #3465

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

Conversation

sagar0
Copy link
Contributor

@sagar0 sagar0 commented Feb 5, 2018

Ported Iterator::Refresh functionality to RocksJava. This was originally introduced in the C++ API by @siying in #2621.

This should reduce GC pressure particularly in use-cases that frequently create and destroy large number of iterators just to get to the latest snapshot of data.

The API can be invoked by calling RocksIterator::refresh().
WBWIRocksIterator::refresh() is not implemented and would throw a not-supported exception for now.

Test Plan:
Added Unit tests.

*/
void Java_org_rocksdb_WBWIRocksIterator_refresh0(
JNIEnv* env, jobject jobj, jlong handle) {
auto* it = reinterpret_cast<rocksdb::Iterator*>(handle);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the cast to rocksdb::Iterator here instead of rocksdb::WBWIIterator, so that we can use the default implementation and return Status::NotSupported.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see WBWIIterator to be a child class of Iterator. I don't know how this can be casted.

Copy link
Contributor Author

@sagar0 sagar0 Feb 5, 2018

Choose a reason for hiding this comment

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

I guess you are right. This seems like a blunder on my part. Thanks for catching this.
RocksIterator and WBWIRocksIterator inherit from AbstractRocksIterator/RocksInterface on the java side, but they don't have such an inheritance chain on the C++ side, which contributed to the confusion at my end.

I need to re-think the strategy for WBWIRockIterator ... may be something like just throwing a RocksDBException from Java layer without even going to the C++ layer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds reasonable.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired.

Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status.

@adamretter
Copy link
Collaborator

Otherwise LGTM

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

return;
}

rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
Copy link
Contributor

Choose a reason for hiding this comment

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

@sagar0 if you delete line 549 to line 554, and only leave 556 with a NotSupported message, I can merge it.
We need you advice on how we should do with it.

@npepinpe
Copy link
Contributor

Any news on this? I was going to open the same exact PR but noticed this - I'd love to get access to Refresh() for iterators. Or should I open a new PR, as this has seen no activity in over a year?

facebook-github-bot pushed a commit that referenced this pull request Apr 16, 2020
Summary:
This PR exposes the `Iterator::Refresh` method to the Java API by adding it on the `RocksIteratorInterface` interface. There are three concrete implementations: `RocksIterator`, `SstFileReaderIterator`, and `WBWIRocksIterator`. For the first two cases, the JNI side simply delegates to the underlying `Iterator::Refresh` method; in the last case, as it doesn't share an ancestor, and per the discussion in #3465, a `Status::NotSupported` exception is thrown.

As the last PR had no activity in a while, I'm opening a new one - I'm completely fine with merging the previous PR if it gets completed before this is reviewed.

Let me know if there's anything missing or anything else I can do 👍
Pull Request resolved: #6573

Reviewed By: cheng-chang

Differential Revision: D20604666

Pulled By: pdillinger

fbshipit-source-id: 4de17df1180c3b87b76cfdd77b674b81fc0563f7
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.

5 participants