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

Add rocksdb_create_column_families_with_options to C API. #12896

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

Conversation

rhubner
Copy link
Contributor

@rhubner rhubner commented Jul 30, 2024

This method allow to create Column Families in same was as we do in C++ with ColumnFamilyDescriptor.
Fix #12887

db/c_test.c Outdated
CheckNoError(err);

char** list_const_cf_names = (char**)malloc(2 * sizeof(char*));
list_const_cf_names[0] = "cf_with_options";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make the names more distinct ?

db/c_test.c Outdated
list_const_cf_names[0] = "cf_with_options";
list_const_cf_names[1] = "cf_with_option";
size_t cflen;
const rocksdb_options_t* create_cf_options[2] = {db_options, db_options};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you

  • create the 2x CF with different options
  • do basic write/read tests just to validate that the correct distinct CFs have been returned by the new API
  • confirm that each has received these distinct options i.e. something in the use of CF that differs by option
    Maybe some of this can be copied from the tests that exist already ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for expanding the tests. Is there anything that demonstrates the correct (different) options have been sent to the different CFs ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently get_options(cfh) is not implemented in the 'C' API. We really should add it, and use it to verify the correct options go to the correct CF on this creation. In the meantime, let's proceed with this PR.

@@ -1145,6 +1145,34 @@ rocksdb_column_family_handle_t** rocksdb_create_column_families(
return c_handles;
}

rocksdb_column_family_handle_t** rocksdb_create_column_families_with_options(
Copy link
Contributor

Choose a reason for hiding this comment

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

I approve of changing the parameter order so as not to allow confusion of options[] and options* ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry @alanpaxton, I don't understand what are you saying. Can you please describe it more?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are different rocksdb_create_column_famil[y|ies] methods with different orders of parameters. I was confused by the different orders of parameters. But I think your function has the "correct" order of parameters for what it does.

@@ -1145,6 +1145,34 @@ rocksdb_column_family_handle_t** rocksdb_create_column_families(
return c_handles;
}

rocksdb_column_family_handle_t** rocksdb_create_column_families_with_options(
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the other APIs don't have method comments, but maybe we could start ? In particular state that this method takes a set of options per CF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but wasn't be better to add doc comments to c.h file?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are correct, at least in this case where we are documenting the API. Thanks for doing that.

@@ -1145,6 +1145,34 @@ rocksdb_column_family_handle_t** rocksdb_create_column_families(
return c_handles;
}

rocksdb_column_family_handle_t** rocksdb_create_column_families_with_options(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we implement a TTL variant, or is that enough scope ? I prefer to restrict the scope but worth thinking about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the first C API. I would like to start small and then we can add more later. Once API is out, it's hard to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

@rhubner rhubner force-pushed the eb/cf-with-options branch 2 times, most recently from 5e7039e to e134e79 Compare August 5, 2024 11:53
@rhubner rhubner marked this pull request as ready for review August 5, 2024 12:23
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.

CreateColumnFamilies with column family descriptors is not available via the C API
3 participants