From eca1763b5def3fc2858514535bdd900d7aec7584 Mon Sep 17 00:00:00 2001 From: Jurriaan Mous Date: Sun, 5 Jan 2025 16:39:54 +0100 Subject: [PATCH] Expand Rocksdb methods in C API. Added: rocksdb_drop_column_families, rocksdb_reset_stats, rocksdb_number_levels_cf, rocksdb_max_mem_compaction_level_cf, rocksdb_number_levels_cf, rocksdb_level0_stop_write_trigger_cf, rocksdb_options_statistics_reset --- db/c.cc | 31 +++++++++++++++++++++++++++++++ include/rocksdb/c.h | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/db/c.cc b/db/c.cc index e4f6960a8250..cf17dfcda753 100644 --- a/db/c.cc +++ b/db/c.cc @@ -1250,6 +1250,17 @@ void rocksdb_drop_column_family(rocksdb_t* db, SaveError(errptr, db->rep->DropColumnFamily(handle->rep)); } +void rocksdb_drop_column_families(rocksdb_t* db, + rocksdb_column_family_handle_t** handles, + size_t num_handles, + char** errptr) { + std::vector cf_handles; + for (size_t i = 0; i < num_handles; i++) { + cf_handles.push_back(handles[i]->rep); + } + SaveError(errptr, db->rep->DropColumnFamilies(cf_handles)); +} + uint32_t rocksdb_column_family_handle_get_id( rocksdb_column_family_handle_t* handle) { return handle->rep->GetID(); @@ -2057,18 +2068,34 @@ void rocksdb_verify_checksum(rocksdb_t* db, char** errptr) { SaveError(errptr, db->rep->VerifyChecksum()); } +void rocksdb_reset_stats(rocksdb_t* db, char** errptr) { + SaveError(errptr, db->rep->ResetStats()); +} + int32_t rocksdb_number_levels(rocksdb_t* db) { return db->rep->NumberLevels(); } +int32_t rocksdb_number_levels_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family) { + return db->rep->NumberLevels(column_family->rep); +} + int32_t rocksdb_max_mem_compaction_level(rocksdb_t* db) { return db->rep->MaxMemCompactionLevel(); } +int32_t rocksdb_max_mem_compaction_level_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family) { + return db->rep->MaxMemCompactionLevel(column_family->rep); +} + int32_t rocksdb_level0_stop_write_trigger(rocksdb_t* db) { return db->rep->Level0StopWriteTrigger(); } +int32_t rocksdb_level0_stop_write_trigger_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family) { + return db->rep->Level0StopWriteTrigger(column_family->rep); +} + void rocksdb_disable_file_deletions(rocksdb_t* db, char** errptr) { SaveError(errptr, db->rep->DisableFileDeletions()); } @@ -4375,6 +4402,10 @@ void rocksdb_options_statistics_get_histogram_data( } } +void rocksdb_options_statistics_reset(rocksdb_options_t* opt) { + opt->rep.statistics->Reset(); +} + void rocksdb_options_set_ratelimiter(rocksdb_options_t* opt, rocksdb_ratelimiter_t* limiter) { if (limiter) { diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index bcb1b37a8160..772edd77ee8c 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -460,6 +460,10 @@ rocksdb_create_column_family_with_ttl( extern ROCKSDB_LIBRARY_API void rocksdb_drop_column_family( rocksdb_t* db, rocksdb_column_family_handle_t* handle, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_drop_column_families( + rocksdb_t* db, rocksdb_column_family_handle_t** handles, size_t num_handles, + char** errptr); + extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* rocksdb_get_default_column_family_handle(rocksdb_t* db); @@ -750,12 +754,27 @@ extern ROCKSDB_LIBRARY_API void rocksdb_promote_l0(rocksdb_t* db, extern ROCKSDB_LIBRARY_API void rocksdb_verify_checksum(rocksdb_t* db, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_reset_stats(rocksdb_t* db, + char** errptr); + extern ROCKSDB_LIBRARY_API int32_t rocksdb_number_levels(rocksdb_t* db); +extern ROCKSDB_LIBRARY_API int32_t rocksdb_number_levels_cf(rocksdb_t* db, + rocksdb_column_family_handle_t* column_family); + extern ROCKSDB_LIBRARY_API int32_t rocksdb_max_mem_compaction_level(rocksdb_t* db); +extern ROCKSDB_LIBRARY_API int32_t rocksdb_max_mem_compaction_level_cf(rocksdb_t* db, + rocksdb_column_family_handle_t* column_family); + +extern ROCKSDB_LIBRARY_API int32_t rocksdb_number_levels_cf(rocksdb_t* db, + rocksdb_column_family_handle_t* column_family); + extern ROCKSDB_LIBRARY_API int32_t rocksdb_level0_stop_write_trigger(rocksdb_t* db); +extern ROCKSDB_LIBRARY_API int32_t rocksdb_level0_stop_write_trigger_cf(rocksdb_t* db, + rocksdb_column_family_handle_t* column_family); + extern ROCKSDB_LIBRARY_API void rocksdb_disable_file_deletions(rocksdb_t* db, char** errptr); @@ -1540,6 +1559,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_statistics_get_histogram_data( rocksdb_options_t* opt, uint32_t histogram_type, rocksdb_statistics_histogram_data_t* const data); +extern ROCKSDB_LIBRARY_API void rocksdb_options_statistics_reset(rocksdb_options_t* opt); + extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_write_buffer_number( rocksdb_options_t*, int); extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_write_buffer_number(