From 79ed4be80f4e7999b612894b974bf99b9ba70059 Mon Sep 17 00:00:00 2001 From: "muthukrishnan.s" Date: Wed, 24 Aug 2022 13:49:02 -0700 Subject: [PATCH] Add get_name, get_id for column family handle in C API (#10499) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/10499 Reviewed By: hx235 Differential Revision: D38523859 Pulled By: ajkr fbshipit-source-id: 268bba1fcce4a3e20c51e498a79d7b476f663aea --- HISTORY.md | 3 +++ db/c.cc | 12 ++++++++++++ include/rocksdb/c.h | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index b1d295a78..20e3c11ca 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,9 @@ ### Behavior Change * Updated `TestGet()` in `no_batched_op_stress` (default stress test) to check the result of Get() operations against expected state. +### Public API changes +* Add `rocksdb_column_family_handle_get_id`, `rocksdb_column_family_handle_get_name` to get name, id of column family in C API + ## 7.6.0 (08/19/2022) ### New Features * Added `prepopulate_blob_cache` to ColumnFamilyOptions. If enabled, prepopulate warm/hot blobs which are already in memory into blob cache at the time of flush. On a flush, the blob that is in memory (in memtables) get flushed to the device. If using Direct IO, additional IO is incurred to read this blob back into memory again, which is avoided by enabling this option. This further helps if the workload exhibits high temporal locality, where most of the reads go to recently written data. This also helps in case of the remote file system since it involves network traffic and higher latencies. diff --git a/db/c.cc b/db/c.cc index 00b00a130..e3a8fbb5e 100644 --- a/db/c.cc +++ b/db/c.cc @@ -1054,6 +1054,18 @@ void rocksdb_drop_column_family( SaveError(errptr, db->rep->DropColumnFamily(handle->rep)); } +uint32_t rocksdb_column_family_handle_get_id( + rocksdb_column_family_handle_t* handle) { + return handle->rep->GetID(); +} + +char* rocksdb_column_family_handle_get_name( + rocksdb_column_family_handle_t* handle, size_t* name_len) { + auto name = handle->rep->GetName(); + *name_len = name.size(); + return CopyString(name); +} + void rocksdb_column_family_handle_destroy(rocksdb_column_family_handle_t* handle) { delete handle->rep; delete handle; diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 7c8a76fa4..43f1e49c5 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -423,6 +423,12 @@ extern ROCKSDB_LIBRARY_API void rocksdb_drop_column_family( extern ROCKSDB_LIBRARY_API void rocksdb_column_family_handle_destroy( rocksdb_column_family_handle_t*); +extern ROCKSDB_LIBRARY_API uint32_t +rocksdb_column_family_handle_get_id(rocksdb_column_family_handle_t* handle); + +extern ROCKSDB_LIBRARY_API char* rocksdb_column_family_handle_get_name( + rocksdb_column_family_handle_t* handle, size_t* name_len); + extern ROCKSDB_LIBRARY_API void rocksdb_close(rocksdb_t* db); extern ROCKSDB_LIBRARY_API void rocksdb_put(