|
|
|
@ -48,21 +48,21 @@ using std::shared_ptr; |
|
|
|
|
|
|
|
|
|
extern "C" { |
|
|
|
|
|
|
|
|
|
struct leveldb_t { DB* rep; }; |
|
|
|
|
struct leveldb_iterator_t { Iterator* rep; }; |
|
|
|
|
struct leveldb_writebatch_t { WriteBatch rep; }; |
|
|
|
|
struct leveldb_snapshot_t { const Snapshot* rep; }; |
|
|
|
|
struct leveldb_readoptions_t { ReadOptions rep; }; |
|
|
|
|
struct leveldb_writeoptions_t { WriteOptions rep; }; |
|
|
|
|
struct leveldb_options_t { Options rep; }; |
|
|
|
|
struct leveldb_seqfile_t { SequentialFile* rep; }; |
|
|
|
|
struct leveldb_randomfile_t { RandomAccessFile* rep; }; |
|
|
|
|
struct leveldb_writablefile_t { WritableFile* rep; }; |
|
|
|
|
struct leveldb_filelock_t { FileLock* rep; }; |
|
|
|
|
struct leveldb_logger_t { shared_ptr<Logger> rep; }; |
|
|
|
|
struct leveldb_cache_t { shared_ptr<Cache> rep; }; |
|
|
|
|
|
|
|
|
|
struct leveldb_comparator_t : public Comparator { |
|
|
|
|
struct rocksdb_t { DB* rep; }; |
|
|
|
|
struct rocksdb_iterator_t { Iterator* rep; }; |
|
|
|
|
struct rocksdb_writebatch_t { WriteBatch rep; }; |
|
|
|
|
struct rocksdb_snapshot_t { const Snapshot* rep; }; |
|
|
|
|
struct rocksdb_readoptions_t { ReadOptions rep; }; |
|
|
|
|
struct rocksdb_writeoptions_t { WriteOptions rep; }; |
|
|
|
|
struct rocksdb_options_t { Options rep; }; |
|
|
|
|
struct rocksdb_seqfile_t { SequentialFile* rep; }; |
|
|
|
|
struct rocksdb_randomfile_t { RandomAccessFile* rep; }; |
|
|
|
|
struct rocksdb_writablefile_t { WritableFile* rep; }; |
|
|
|
|
struct rocksdb_filelock_t { FileLock* rep; }; |
|
|
|
|
struct rocksdb_logger_t { shared_ptr<Logger> rep; }; |
|
|
|
|
struct rocksdb_cache_t { shared_ptr<Cache> rep; }; |
|
|
|
|
|
|
|
|
|
struct rocksdb_comparator_t : public Comparator { |
|
|
|
|
void* state_; |
|
|
|
|
void (*destructor_)(void*); |
|
|
|
|
int (*compare_)( |
|
|
|
@ -71,7 +71,7 @@ struct leveldb_comparator_t : public Comparator { |
|
|
|
|
const char* b, size_t blen); |
|
|
|
|
const char* (*name_)(void*); |
|
|
|
|
|
|
|
|
|
virtual ~leveldb_comparator_t() { |
|
|
|
|
virtual ~rocksdb_comparator_t() { |
|
|
|
|
(*destructor_)(state_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ struct leveldb_comparator_t : public Comparator { |
|
|
|
|
virtual void FindShortSuccessor(std::string* key) const { } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct leveldb_filterpolicy_t : public FilterPolicy { |
|
|
|
|
struct rocksdb_filterpolicy_t : public FilterPolicy { |
|
|
|
|
void* state_; |
|
|
|
|
void (*destructor_)(void*); |
|
|
|
|
const char* (*name_)(void*); |
|
|
|
@ -102,7 +102,7 @@ struct leveldb_filterpolicy_t : public FilterPolicy { |
|
|
|
|
const char* key, size_t length, |
|
|
|
|
const char* filter, size_t filter_length); |
|
|
|
|
|
|
|
|
|
virtual ~leveldb_filterpolicy_t() { |
|
|
|
|
virtual ~rocksdb_filterpolicy_t() { |
|
|
|
|
(*destructor_)(state_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -129,7 +129,7 @@ struct leveldb_filterpolicy_t : public FilterPolicy { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct leveldb_env_t { |
|
|
|
|
struct rocksdb_env_t { |
|
|
|
|
Env* rep; |
|
|
|
|
bool is_default; |
|
|
|
|
}; |
|
|
|
@ -154,27 +154,27 @@ static char* CopyString(const std::string& str) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_t* leveldb_open( |
|
|
|
|
const leveldb_options_t* options, |
|
|
|
|
rocksdb_t* rocksdb_open( |
|
|
|
|
const rocksdb_options_t* options, |
|
|
|
|
const char* name, |
|
|
|
|
char** errptr) { |
|
|
|
|
DB* db; |
|
|
|
|
if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) { |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
leveldb_t* result = new leveldb_t; |
|
|
|
|
rocksdb_t* result = new rocksdb_t; |
|
|
|
|
result->rep = db; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_close(leveldb_t* db) { |
|
|
|
|
void rocksdb_close(rocksdb_t* db) { |
|
|
|
|
delete db->rep; |
|
|
|
|
delete db; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_put( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_writeoptions_t* options, |
|
|
|
|
void rocksdb_put( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_writeoptions_t* options, |
|
|
|
|
const char* key, size_t keylen, |
|
|
|
|
const char* val, size_t vallen, |
|
|
|
|
char** errptr) { |
|
|
|
@ -182,26 +182,26 @@ void leveldb_put( |
|
|
|
|
db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_delete( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_writeoptions_t* options, |
|
|
|
|
void rocksdb_delete( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_writeoptions_t* options, |
|
|
|
|
const char* key, size_t keylen, |
|
|
|
|
char** errptr) { |
|
|
|
|
SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void leveldb_write( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_writeoptions_t* options, |
|
|
|
|
leveldb_writebatch_t* batch, |
|
|
|
|
void rocksdb_write( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_writeoptions_t* options, |
|
|
|
|
rocksdb_writebatch_t* batch, |
|
|
|
|
char** errptr) { |
|
|
|
|
SaveError(errptr, db->rep->Write(options->rep, &batch->rep)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char* leveldb_get( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_readoptions_t* options, |
|
|
|
|
char* rocksdb_get( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_readoptions_t* options, |
|
|
|
|
const char* key, size_t keylen, |
|
|
|
|
size_t* vallen, |
|
|
|
|
char** errptr) { |
|
|
|
@ -220,30 +220,30 @@ char* leveldb_get( |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_iterator_t* leveldb_create_iterator( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_readoptions_t* options) { |
|
|
|
|
leveldb_iterator_t* result = new leveldb_iterator_t; |
|
|
|
|
rocksdb_iterator_t* rocksdb_create_iterator( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_readoptions_t* options) { |
|
|
|
|
rocksdb_iterator_t* result = new rocksdb_iterator_t; |
|
|
|
|
result->rep = db->rep->NewIterator(options->rep); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const leveldb_snapshot_t* leveldb_create_snapshot( |
|
|
|
|
leveldb_t* db) { |
|
|
|
|
leveldb_snapshot_t* result = new leveldb_snapshot_t; |
|
|
|
|
const rocksdb_snapshot_t* rocksdb_create_snapshot( |
|
|
|
|
rocksdb_t* db) { |
|
|
|
|
rocksdb_snapshot_t* result = new rocksdb_snapshot_t; |
|
|
|
|
result->rep = db->rep->GetSnapshot(); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_release_snapshot( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
const leveldb_snapshot_t* snapshot) { |
|
|
|
|
void rocksdb_release_snapshot( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const rocksdb_snapshot_t* snapshot) { |
|
|
|
|
db->rep->ReleaseSnapshot(snapshot->rep); |
|
|
|
|
delete snapshot; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char* leveldb_property_value( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
char* rocksdb_property_value( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const char* propname) { |
|
|
|
|
std::string tmp; |
|
|
|
|
if (db->rep->GetProperty(Slice(propname), &tmp)) { |
|
|
|
@ -254,8 +254,8 @@ char* leveldb_property_value( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_approximate_sizes( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
void rocksdb_approximate_sizes( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
int num_ranges, |
|
|
|
|
const char* const* range_start_key, const size_t* range_start_key_len, |
|
|
|
|
const char* const* range_limit_key, const size_t* range_limit_key_len, |
|
|
|
@ -269,8 +269,8 @@ void leveldb_approximate_sizes( |
|
|
|
|
delete[] ranges; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_compact_range( |
|
|
|
|
leveldb_t* db, |
|
|
|
|
void rocksdb_compact_range( |
|
|
|
|
rocksdb_t* db, |
|
|
|
|
const char* start_key, size_t start_key_len, |
|
|
|
|
const char* limit_key, size_t limit_key_len) { |
|
|
|
|
Slice a, b; |
|
|
|
@ -280,92 +280,92 @@ void leveldb_compact_range( |
|
|
|
|
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_destroy_db( |
|
|
|
|
const leveldb_options_t* options, |
|
|
|
|
void rocksdb_destroy_db( |
|
|
|
|
const rocksdb_options_t* options, |
|
|
|
|
const char* name, |
|
|
|
|
char** errptr) { |
|
|
|
|
SaveError(errptr, DestroyDB(name, options->rep)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_repair_db( |
|
|
|
|
const leveldb_options_t* options, |
|
|
|
|
void rocksdb_repair_db( |
|
|
|
|
const rocksdb_options_t* options, |
|
|
|
|
const char* name, |
|
|
|
|
char** errptr) { |
|
|
|
|
SaveError(errptr, RepairDB(name, options->rep)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_destroy(leveldb_iterator_t* iter) { |
|
|
|
|
void rocksdb_iter_destroy(rocksdb_iterator_t* iter) { |
|
|
|
|
delete iter->rep; |
|
|
|
|
delete iter; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { |
|
|
|
|
unsigned char rocksdb_iter_valid(const rocksdb_iterator_t* iter) { |
|
|
|
|
return iter->rep->Valid(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_seek_to_first(leveldb_iterator_t* iter) { |
|
|
|
|
void rocksdb_iter_seek_to_first(rocksdb_iterator_t* iter) { |
|
|
|
|
iter->rep->SeekToFirst(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_seek_to_last(leveldb_iterator_t* iter) { |
|
|
|
|
void rocksdb_iter_seek_to_last(rocksdb_iterator_t* iter) { |
|
|
|
|
iter->rep->SeekToLast(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_seek(leveldb_iterator_t* iter, const char* k, size_t klen) { |
|
|
|
|
void rocksdb_iter_seek(rocksdb_iterator_t* iter, const char* k, size_t klen) { |
|
|
|
|
iter->rep->Seek(Slice(k, klen)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_next(leveldb_iterator_t* iter) { |
|
|
|
|
void rocksdb_iter_next(rocksdb_iterator_t* iter) { |
|
|
|
|
iter->rep->Next(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_prev(leveldb_iterator_t* iter) { |
|
|
|
|
void rocksdb_iter_prev(rocksdb_iterator_t* iter) { |
|
|
|
|
iter->rep->Prev(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char* leveldb_iter_key(const leveldb_iterator_t* iter, size_t* klen) { |
|
|
|
|
const char* rocksdb_iter_key(const rocksdb_iterator_t* iter, size_t* klen) { |
|
|
|
|
Slice s = iter->rep->key(); |
|
|
|
|
*klen = s.size(); |
|
|
|
|
return s.data(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char* leveldb_iter_value(const leveldb_iterator_t* iter, size_t* vlen) { |
|
|
|
|
const char* rocksdb_iter_value(const rocksdb_iterator_t* iter, size_t* vlen) { |
|
|
|
|
Slice s = iter->rep->value(); |
|
|
|
|
*vlen = s.size(); |
|
|
|
|
return s.data(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_iter_get_error(const leveldb_iterator_t* iter, char** errptr) { |
|
|
|
|
void rocksdb_iter_get_error(const rocksdb_iterator_t* iter, char** errptr) { |
|
|
|
|
SaveError(errptr, iter->rep->status()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_writebatch_t* leveldb_writebatch_create() { |
|
|
|
|
return new leveldb_writebatch_t; |
|
|
|
|
rocksdb_writebatch_t* rocksdb_writebatch_create() { |
|
|
|
|
return new rocksdb_writebatch_t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writebatch_destroy(leveldb_writebatch_t* b) { |
|
|
|
|
void rocksdb_writebatch_destroy(rocksdb_writebatch_t* b) { |
|
|
|
|
delete b; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writebatch_clear(leveldb_writebatch_t* b) { |
|
|
|
|
void rocksdb_writebatch_clear(rocksdb_writebatch_t* b) { |
|
|
|
|
b->rep.Clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writebatch_put( |
|
|
|
|
leveldb_writebatch_t* b, |
|
|
|
|
void rocksdb_writebatch_put( |
|
|
|
|
rocksdb_writebatch_t* b, |
|
|
|
|
const char* key, size_t klen, |
|
|
|
|
const char* val, size_t vlen) { |
|
|
|
|
b->rep.Put(Slice(key, klen), Slice(val, vlen)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writebatch_delete( |
|
|
|
|
leveldb_writebatch_t* b, |
|
|
|
|
void rocksdb_writebatch_delete( |
|
|
|
|
rocksdb_writebatch_t* b, |
|
|
|
|
const char* key, size_t klen) { |
|
|
|
|
b->rep.Delete(Slice(key, klen)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writebatch_iterate( |
|
|
|
|
leveldb_writebatch_t* b, |
|
|
|
|
void rocksdb_writebatch_iterate( |
|
|
|
|
rocksdb_writebatch_t* b, |
|
|
|
|
void* state, |
|
|
|
|
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), |
|
|
|
|
void (*deleted)(void*, const char* k, size_t klen)) { |
|
|
|
@ -388,132 +388,132 @@ void leveldb_writebatch_iterate( |
|
|
|
|
b->rep.Iterate(&handler); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_options_t* leveldb_options_create() { |
|
|
|
|
return new leveldb_options_t; |
|
|
|
|
rocksdb_options_t* rocksdb_options_create() { |
|
|
|
|
return new rocksdb_options_t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_destroy(leveldb_options_t* options) { |
|
|
|
|
void rocksdb_options_destroy(rocksdb_options_t* options) { |
|
|
|
|
delete options; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_comparator( |
|
|
|
|
leveldb_options_t* opt, |
|
|
|
|
leveldb_comparator_t* cmp) { |
|
|
|
|
void rocksdb_options_set_comparator( |
|
|
|
|
rocksdb_options_t* opt, |
|
|
|
|
rocksdb_comparator_t* cmp) { |
|
|
|
|
opt->rep.comparator = cmp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_filter_policy( |
|
|
|
|
leveldb_options_t* opt, |
|
|
|
|
leveldb_filterpolicy_t* policy) { |
|
|
|
|
void rocksdb_options_set_filter_policy( |
|
|
|
|
rocksdb_options_t* opt, |
|
|
|
|
rocksdb_filterpolicy_t* policy) { |
|
|
|
|
opt->rep.filter_policy = policy; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_create_if_missing( |
|
|
|
|
leveldb_options_t* opt, unsigned char v) { |
|
|
|
|
void rocksdb_options_set_create_if_missing( |
|
|
|
|
rocksdb_options_t* opt, unsigned char v) { |
|
|
|
|
opt->rep.create_if_missing = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_error_if_exists( |
|
|
|
|
leveldb_options_t* opt, unsigned char v) { |
|
|
|
|
void rocksdb_options_set_error_if_exists( |
|
|
|
|
rocksdb_options_t* opt, unsigned char v) { |
|
|
|
|
opt->rep.error_if_exists = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_paranoid_checks( |
|
|
|
|
leveldb_options_t* opt, unsigned char v) { |
|
|
|
|
void rocksdb_options_set_paranoid_checks( |
|
|
|
|
rocksdb_options_t* opt, unsigned char v) { |
|
|
|
|
opt->rep.paranoid_checks = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_env(leveldb_options_t* opt, leveldb_env_t* env) { |
|
|
|
|
void rocksdb_options_set_env(rocksdb_options_t* opt, rocksdb_env_t* env) { |
|
|
|
|
opt->rep.env = (env ? env->rep : NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_info_log(leveldb_options_t* opt, leveldb_logger_t* l) { |
|
|
|
|
void rocksdb_options_set_info_log(rocksdb_options_t* opt, rocksdb_logger_t* l) { |
|
|
|
|
if (l) { |
|
|
|
|
opt->rep.info_log = l->rep; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_write_buffer_size(leveldb_options_t* opt, size_t s) { |
|
|
|
|
void rocksdb_options_set_write_buffer_size(rocksdb_options_t* opt, size_t s) { |
|
|
|
|
opt->rep.write_buffer_size = s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_max_open_files(leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_max_open_files(rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.max_open_files = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_cache(leveldb_options_t* opt, leveldb_cache_t* c) { |
|
|
|
|
void rocksdb_options_set_cache(rocksdb_options_t* opt, rocksdb_cache_t* c) { |
|
|
|
|
if (c) { |
|
|
|
|
opt->rep.block_cache = c->rep; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_block_size(leveldb_options_t* opt, size_t s) { |
|
|
|
|
void rocksdb_options_set_block_size(rocksdb_options_t* opt, size_t s) { |
|
|
|
|
opt->rep.block_size = s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_block_restart_interval(leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_block_restart_interval(rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.block_restart_interval = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_target_file_size_base( |
|
|
|
|
leveldb_options_t* opt, uint64_t n) { |
|
|
|
|
void rocksdb_options_set_target_file_size_base( |
|
|
|
|
rocksdb_options_t* opt, uint64_t n) { |
|
|
|
|
opt->rep.target_file_size_base = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_target_file_size_multiplier( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_target_file_size_multiplier( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.target_file_size_multiplier = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_max_bytes_for_level_base( |
|
|
|
|
leveldb_options_t* opt, uint64_t n) { |
|
|
|
|
void rocksdb_options_set_max_bytes_for_level_base( |
|
|
|
|
rocksdb_options_t* opt, uint64_t n) { |
|
|
|
|
opt->rep.max_bytes_for_level_base = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_max_bytes_for_level_multiplier( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_max_bytes_for_level_multiplier( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.max_bytes_for_level_multiplier = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_expanded_compaction_factor( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_expanded_compaction_factor( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.expanded_compaction_factor = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_max_grandparent_overlap_factor( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_max_grandparent_overlap_factor( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.max_grandparent_overlap_factor = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_num_levels(leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_num_levels(rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.num_levels = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_level0_file_num_compaction_trigger( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_level0_file_num_compaction_trigger( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.level0_file_num_compaction_trigger = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_level0_slowdown_writes_trigger( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_level0_slowdown_writes_trigger( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.level0_slowdown_writes_trigger = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_level0_stop_writes_trigger( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_level0_stop_writes_trigger( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.level0_stop_writes_trigger = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_max_mem_compaction_level( |
|
|
|
|
leveldb_options_t* opt, int n) { |
|
|
|
|
void rocksdb_options_set_max_mem_compaction_level( |
|
|
|
|
rocksdb_options_t* opt, int n) { |
|
|
|
|
opt->rep.max_mem_compaction_level = n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_compression(leveldb_options_t* opt, int t) { |
|
|
|
|
void rocksdb_options_set_compression(rocksdb_options_t* opt, int t) { |
|
|
|
|
opt->rep.compression = static_cast<CompressionType>(t); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_compression_per_level(leveldb_options_t* opt, |
|
|
|
|
void rocksdb_options_set_compression_per_level(rocksdb_options_t* opt, |
|
|
|
|
int* level_values, |
|
|
|
|
size_t num_levels) { |
|
|
|
|
opt->rep.compression_per_level.resize(num_levels); |
|
|
|
@ -523,43 +523,43 @@ void leveldb_options_set_compression_per_level(leveldb_options_t* opt, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_compression_options( |
|
|
|
|
leveldb_options_t* opt, int w_bits, int level, int strategy) { |
|
|
|
|
void rocksdb_options_set_compression_options( |
|
|
|
|
rocksdb_options_t* opt, int w_bits, int level, int strategy) { |
|
|
|
|
opt->rep.compression_opts.window_bits = w_bits; |
|
|
|
|
opt->rep.compression_opts.level = level; |
|
|
|
|
opt->rep.compression_opts.strategy = strategy; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_disable_data_sync( |
|
|
|
|
leveldb_options_t* opt, bool disable_data_sync) { |
|
|
|
|
void rocksdb_options_set_disable_data_sync( |
|
|
|
|
rocksdb_options_t* opt, bool disable_data_sync) { |
|
|
|
|
opt->rep.disableDataSync = disable_data_sync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_use_fsync( |
|
|
|
|
leveldb_options_t* opt, bool use_fsync) { |
|
|
|
|
void rocksdb_options_set_use_fsync( |
|
|
|
|
rocksdb_options_t* opt, bool use_fsync) { |
|
|
|
|
opt->rep.use_fsync = use_fsync; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_db_stats_log_interval( |
|
|
|
|
leveldb_options_t* opt, int db_stats_log_interval) { |
|
|
|
|
void rocksdb_options_set_db_stats_log_interval( |
|
|
|
|
rocksdb_options_t* opt, int db_stats_log_interval) { |
|
|
|
|
opt->rep.db_stats_log_interval = db_stats_log_interval; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_db_log_dir( |
|
|
|
|
leveldb_options_t* opt, const char* db_log_dir) { |
|
|
|
|
void rocksdb_options_set_db_log_dir( |
|
|
|
|
rocksdb_options_t* opt, const char* db_log_dir) { |
|
|
|
|
opt->rep.db_log_dir = db_log_dir; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_WAL_ttl_seconds(leveldb_options_t* opt, uint64_t ttl) { |
|
|
|
|
void rocksdb_options_set_WAL_ttl_seconds(rocksdb_options_t* opt, uint64_t ttl) { |
|
|
|
|
opt->rep.WAL_ttl_seconds = ttl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_options_set_WAL_size_limit_MB( |
|
|
|
|
leveldb_options_t* opt, uint64_t limit) { |
|
|
|
|
void rocksdb_options_set_WAL_size_limit_MB( |
|
|
|
|
rocksdb_options_t* opt, uint64_t limit) { |
|
|
|
|
opt->rep.WAL_size_limit_MB = limit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_comparator_t* leveldb_comparator_create( |
|
|
|
|
rocksdb_comparator_t* rocksdb_comparator_create( |
|
|
|
|
void* state, |
|
|
|
|
void (*destructor)(void*), |
|
|
|
|
int (*compare)( |
|
|
|
@ -567,7 +567,7 @@ leveldb_comparator_t* leveldb_comparator_create( |
|
|
|
|
const char* a, size_t alen, |
|
|
|
|
const char* b, size_t blen), |
|
|
|
|
const char* (*name)(void*)) { |
|
|
|
|
leveldb_comparator_t* result = new leveldb_comparator_t; |
|
|
|
|
rocksdb_comparator_t* result = new rocksdb_comparator_t; |
|
|
|
|
result->state_ = state; |
|
|
|
|
result->destructor_ = destructor; |
|
|
|
|
result->compare_ = compare; |
|
|
|
@ -575,11 +575,11 @@ leveldb_comparator_t* leveldb_comparator_create( |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_comparator_destroy(leveldb_comparator_t* cmp) { |
|
|
|
|
void rocksdb_comparator_destroy(rocksdb_comparator_t* cmp) { |
|
|
|
|
delete cmp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_filterpolicy_t* leveldb_filterpolicy_create( |
|
|
|
|
rocksdb_filterpolicy_t* rocksdb_filterpolicy_create( |
|
|
|
|
void* state, |
|
|
|
|
void (*destructor)(void*), |
|
|
|
|
char* (*create_filter)( |
|
|
|
@ -592,7 +592,7 @@ leveldb_filterpolicy_t* leveldb_filterpolicy_create( |
|
|
|
|
const char* key, size_t length, |
|
|
|
|
const char* filter, size_t filter_length), |
|
|
|
|
const char* (*name)(void*)) { |
|
|
|
|
leveldb_filterpolicy_t* result = new leveldb_filterpolicy_t; |
|
|
|
|
rocksdb_filterpolicy_t* result = new rocksdb_filterpolicy_t; |
|
|
|
|
result->state_ = state; |
|
|
|
|
result->destructor_ = destructor; |
|
|
|
|
result->create_ = create_filter; |
|
|
|
@ -601,15 +601,15 @@ leveldb_filterpolicy_t* leveldb_filterpolicy_create( |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_filterpolicy_destroy(leveldb_filterpolicy_t* filter) { |
|
|
|
|
void rocksdb_filterpolicy_destroy(rocksdb_filterpolicy_t* filter) { |
|
|
|
|
delete filter; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom(int bits_per_key) { |
|
|
|
|
// Make a leveldb_filterpolicy_t, but override all of its methods so
|
|
|
|
|
rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(int bits_per_key) { |
|
|
|
|
// Make a rocksdb_filterpolicy_t, but override all of its methods so
|
|
|
|
|
// they delegate to a NewBloomFilterPolicy() instead of user
|
|
|
|
|
// supplied C functions.
|
|
|
|
|
struct Wrapper : public leveldb_filterpolicy_t { |
|
|
|
|
struct Wrapper : public rocksdb_filterpolicy_t { |
|
|
|
|
const FilterPolicy* rep_; |
|
|
|
|
~Wrapper() { delete rep_; } |
|
|
|
|
const char* Name() const { return rep_->Name(); } |
|
|
|
@ -628,62 +628,62 @@ leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom(int bits_per_key) { |
|
|
|
|
return wrapper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_readoptions_t* leveldb_readoptions_create() { |
|
|
|
|
return new leveldb_readoptions_t; |
|
|
|
|
rocksdb_readoptions_t* rocksdb_readoptions_create() { |
|
|
|
|
return new rocksdb_readoptions_t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { |
|
|
|
|
void rocksdb_readoptions_destroy(rocksdb_readoptions_t* opt) { |
|
|
|
|
delete opt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_readoptions_set_verify_checksums( |
|
|
|
|
leveldb_readoptions_t* opt, |
|
|
|
|
void rocksdb_readoptions_set_verify_checksums( |
|
|
|
|
rocksdb_readoptions_t* opt, |
|
|
|
|
unsigned char v) { |
|
|
|
|
opt->rep.verify_checksums = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_readoptions_set_fill_cache( |
|
|
|
|
leveldb_readoptions_t* opt, unsigned char v) { |
|
|
|
|
void rocksdb_readoptions_set_fill_cache( |
|
|
|
|
rocksdb_readoptions_t* opt, unsigned char v) { |
|
|
|
|
opt->rep.fill_cache = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_readoptions_set_snapshot( |
|
|
|
|
leveldb_readoptions_t* opt, |
|
|
|
|
const leveldb_snapshot_t* snap) { |
|
|
|
|
void rocksdb_readoptions_set_snapshot( |
|
|
|
|
rocksdb_readoptions_t* opt, |
|
|
|
|
const rocksdb_snapshot_t* snap) { |
|
|
|
|
opt->rep.snapshot = (snap ? snap->rep : NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_writeoptions_t* leveldb_writeoptions_create() { |
|
|
|
|
return new leveldb_writeoptions_t; |
|
|
|
|
rocksdb_writeoptions_t* rocksdb_writeoptions_create() { |
|
|
|
|
return new rocksdb_writeoptions_t; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { |
|
|
|
|
void rocksdb_writeoptions_destroy(rocksdb_writeoptions_t* opt) { |
|
|
|
|
delete opt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_writeoptions_set_sync( |
|
|
|
|
leveldb_writeoptions_t* opt, unsigned char v) { |
|
|
|
|
void rocksdb_writeoptions_set_sync( |
|
|
|
|
rocksdb_writeoptions_t* opt, unsigned char v) { |
|
|
|
|
opt->rep.sync = v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_cache_t* leveldb_cache_create_lru(size_t capacity) { |
|
|
|
|
leveldb_cache_t* c = new leveldb_cache_t; |
|
|
|
|
rocksdb_cache_t* rocksdb_cache_create_lru(size_t capacity) { |
|
|
|
|
rocksdb_cache_t* c = new rocksdb_cache_t; |
|
|
|
|
c->rep = NewLRUCache(capacity); |
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_cache_destroy(leveldb_cache_t* cache) { |
|
|
|
|
void rocksdb_cache_destroy(rocksdb_cache_t* cache) { |
|
|
|
|
delete cache; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
leveldb_env_t* leveldb_create_default_env() { |
|
|
|
|
leveldb_env_t* result = new leveldb_env_t; |
|
|
|
|
rocksdb_env_t* rocksdb_create_default_env() { |
|
|
|
|
rocksdb_env_t* result = new rocksdb_env_t; |
|
|
|
|
result->rep = Env::Default(); |
|
|
|
|
result->is_default = true; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void leveldb_env_destroy(leveldb_env_t* env) { |
|
|
|
|
void rocksdb_env_destroy(rocksdb_env_t* env) { |
|
|
|
|
if (!env->is_default) delete env->rep; |
|
|
|
|
delete env; |
|
|
|
|
} |
|
|
|
|