From 8f1214531e49c84a4624f1eef0a6a4b6b05eef2f Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 23 May 2016 19:19:47 +0800 Subject: [PATCH] C API: Expose DeleteFileInRange (#1132) --- db/c.cc | 25 +++++++++++++++++++++++++ include/rocksdb/c.h | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/db/c.cc b/db/c.cc index 3ed5d9c0e..c5e46217d 100644 --- a/db/c.cc +++ b/db/c.cc @@ -2388,6 +2388,31 @@ void rocksdb_get_options_from_string(const rocksdb_options_t* base_options, &new_options->rep)); } +void rocksdb_delete_file_in_range(rocksdb_t* db, const char* start_key, + size_t start_key_len, const char* limit_key, + size_t limit_key_len, char** errptr) { + Slice a, b; + SaveError( + errptr, + DeleteFilesInRange( + db->rep, db->rep->DefaultColumnFamily(), + (start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr), + (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr))); +} + +void rocksdb_delete_file_in_range_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* limit_key, + size_t limit_key_len, char** errptr) { + Slice a, b; + SaveError( + errptr, + DeleteFilesInRange( + db->rep, column_family->rep, + (start_key ? (a = Slice(start_key, start_key_len), &a) : nullptr), + (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : nullptr))); +} + void rocksdb_free(void* ptr) { free(ptr); } } // end extern "C" diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 01e2079bc..790a8beba 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -932,6 +932,15 @@ extern ROCKSDB_LIBRARY_API void rocksdb_get_options_from_string( const rocksdb_options_t* base_options, const char* opts_str, rocksdb_options_t* new_options, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range( + rocksdb_t* db, const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* limit_key, + size_t limit_key_len, char** errptr); + // referring to convention (3), this should be used by client // to free memory that was malloc()ed extern ROCKSDB_LIBRARY_API void rocksdb_free(void* ptr);