Skip to content

Commit

Permalink
Expand Rocksdb methods in C API. Added: rocksdb_drop_column_families,…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
jurmous committed Jan 5, 2025
1 parent c429342 commit eca1763
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
31 changes: 31 additions & 0 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ColumnFamilyHandle*> 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();
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit eca1763

Please sign in to comment.