C API: Expose DeleteFileInRange (#1132)

This commit is contained in:
siddontang 2016-05-23 19:19:47 +08:00 committed by dhruba borthakur
parent 11f329bd40
commit 8f1214531e
2 changed files with 34 additions and 0 deletions

25
db/c.cc
View File

@ -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"

View File

@ -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);