Skip to content

Refactor ColumnFamilyDescriptor to be RocksObject#12505

Open
rhubner wants to merge 11 commits into
facebook:mainfrom
evolvedbinary:eb/cf-descriptor-refactor
Open

Refactor ColumnFamilyDescriptor to be RocksObject#12505
rhubner wants to merge 11 commits into
facebook:mainfrom
evolvedbinary:eb/cf-descriptor-refactor

Conversation

@rhubner

@rhubner rhubner commented Apr 4, 2024

Copy link
Copy Markdown
Contributor

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

@adamretter adamretter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some initial feedback...

Comment thread java/rocksjni/columncamilydescriptor.cc Outdated
Comment thread java/rocksjni/portal.h
Comment thread java/rocksjni/rocksjni.cc Outdated
Comment thread java/src/main/java/org/rocksdb/ColumnFamilyDescriptor.java Outdated
Comment thread java/src/test/java/org/rocksdb/ColumnFamilyDescriptorTest.java Outdated
Comment thread java/src/test/java/org/rocksdb/ColumnFamilyDescriptorTest.java Outdated
Comment thread java/src/test/java/org/rocksdb/ColumnFamilyDescriptorTest.java Outdated
Comment thread java/src/test/java/org/rocksdb/ColumnFamilyDescriptorTest.java Outdated
Comment thread java/src/test/java/org/rocksdb/ColumnFamilyDescriptorTest.java Outdated
@adamretter

Copy link
Copy Markdown
Collaborator

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

@rhubner

rhubner commented Apr 5, 2024

Copy link
Copy Markdown
Contributor Author

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

I did

Comment thread src.mk Outdated
@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch from 624b2ae to 5cc529a Compare April 9, 2024 09:05
@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch from 5cc529a to b0e5449 Compare June 19, 2024 11:58
@rhubner rhubner marked this pull request as ready for review July 10, 2024 08:40

@alanpaxton alanpaxton left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread java/rocksjni/columnfamilydescriptor.cc Outdated
*/
jbyteArray Java_org_rocksdb_ColumnFamilyDescriptor_getName(
JNIEnv* env, jclass, jlong jcf_descriptor_handle) {
auto cf_options =

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

name cf_descriptor

Comment thread java/rocksjni/rocksjni.cc
jlong* jco = env->GetLongArrayElements(jcolumn_options, nullptr);
if (jco == nullptr) {
// exception thrown: OutOfMemoryError
const jsize len_cols = env->GetArrayLength(jcf_descriptors);

Copy link
Copy Markdown
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 ?


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

Copy link
Copy Markdown
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 ?

Comment thread java/rocksjni/portal.h
@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch 3 times, most recently from 9fb719a to cda2067 Compare July 16, 2024 19:00
@alanpaxton

Copy link
Copy Markdown
Contributor

@rhubner I reviewed your latest batch of changes, LGTM now. Line 6846 of portal.h needs the text fixed, it says
"Returns an empty vector if exception occure"
/\

@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch from 84f8a67 to a1137f1 Compare August 29, 2024 13:10
@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch 2 times, most recently from 1647f6a to 734f7e2 Compare September 30, 2024 17:22
@alanpaxton alanpaxton force-pushed the eb/cf-descriptor-refactor branch 2 times, most recently from 50f5d71 to 21b242a Compare May 19, 2025 13:31
@rhubner rhubner force-pushed the eb/cf-descriptor-refactor branch from 8b4adb9 to d6b268d Compare September 3, 2025 20:21
rhubner and others added 4 commits November 24, 2025 20:22
do what CI says `make format` should have done,
rather than what `make format` does for me…
@Chessray Chessray force-pushed the eb/cf-descriptor-refactor branch from d6b268d to 4892d76 Compare November 24, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment