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

Refactor ColumnFamilyDescriptor to be RocksObject #12505

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

Conversation

rhubner
Copy link
Contributor

@rhubner rhubner commented Apr 4, 2024

Fix memory leak, see #12224 for details

@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch 2 times, most recently from 9a2c8af to 624b2ae Compare April 5, 2024 05:40
@adamretter adamretter self-requested a review April 5, 2024 07:56
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.

Some initial feedback...

java/rocksjni/columncamilydescriptor.cc Outdated Show resolved Hide resolved
java/rocksjni/portal.h Show resolved Hide resolved
java/rocksjni/rocksjni.cc Outdated Show resolved Hide resolved
java/src/main/java/org/rocksdb/ColumnFamilyDescriptor.java Outdated Show resolved Hide resolved
@adamretter
Copy link
Collaborator

@rhubner Do you also need to update the src.mk file for the Make build?

@rhubner
Copy link
Contributor Author

rhubner commented Apr 5, 2024

@rhubner Do you also need to update the src.mk file for the Make build?

I did

src.mk Outdated Show resolved Hide resolved
@rhubner rhubner marked this pull request as ready for review July 10, 2024 08:40
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.

I have suggested some minor changes.
I have chimed in on the issue raised by Adam about constructing new Java objects in the portal, I think you are basically correct there, and that option (2) is right. But see the details.

this.implicitlyCreatedColumnFamilyOptions = implicitlyCreatedColumnFamilyOptions;
}

private static long createNativeInstance(final byte[] columnFamilyName,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to call this "createNativeDescriptor" - I think that makes it clearer.

*/
jbyteArray Java_org_rocksdb_ColumnFamilyDescriptor_getName(
JNIEnv* env, jclass, jlong jcf_descriptor_handle) {
auto cf_options =
Copy link
Contributor

Choose a reason for hiding this comment

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

Name should be cf_descriptor

*/
void Java_org_rocksdb_ColumnFamilyDescriptor_disposeJni(
JNIEnv*, jclass, jlong jcf_descriptor_handle) {
auto cf_options =
Copy link
Contributor

Choose a reason for hiding this comment

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

name cf_descriptor

jlong* jco = env->GetLongArrayElements(jcolumn_options, nullptr);
if (jco == nullptr) {
// exception thrown: OutOfMemoryError
const jsize len_cols = env->GetArrayLength(jcf_descriptors);
Copy link
Contributor

Choose a reason for hiding this comment

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

This little code snippet (jcf_descriptors to std::vector) occurs in 3 or 4 places. Could it be a helper function in columnfamilydescriptor.cc ?

@@ -498,14 +497,13 @@ public static RocksDB openReadOnly(final DBOptions options, final String path,
// in RocksDB can prevent Java to GC during the life-time of
// the currently-created RocksDB.

final byte[][] cfNames = new byte[columnFamilyDescriptors.size()][];
final long[] cfOptionHandles = new long[columnFamilyDescriptors.size()];
final long[] cfDescriptorHandles = new long[columnFamilyDescriptors.size()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion from List to
final long[] cfDescriptorHandles = new long[columnFamilyDescriptors.size()];

seems to happen in several places. Another candidate for a helper ?

java/rocksjni/portal.h Show resolved Hide resolved
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.

None yet

4 participants