From 3a30b5b0be5e3ba395c098b55e0532855b93af2e Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 3 Apr 2014 08:59:01 +0200 Subject: [PATCH] [C-API] added "rocksdb_options_set_plain_table_factory" to make it possible to use plain table factory --- db/c.cc | 13 +++++++++++++ db/c_test.c | 1 + include/rocksdb/c.h | 1 + 3 files changed, 15 insertions(+) diff --git a/db/c.cc b/db/c.cc index 2e55c0ea1..2b3e5e538 100644 --- a/db/c.cc +++ b/db/c.cc @@ -25,6 +25,7 @@ #include "rocksdb/universal_compaction.h" #include "rocksdb/statistics.h" #include "rocksdb/slice_transform.h" +#include "rocksdb/table.h" using rocksdb::Cache; using rocksdb::Comparator; @@ -1003,6 +1004,18 @@ void rocksdb_options_set_hash_link_list_rep( opt->rep.memtable_factory.reset(factory); } +void rocksdb_options_set_plain_table_factory( + rocksdb_options_t *opt, uint32_t user_key_len, int bloom_bits_per_key, + double hash_table_ratio, size_t index_sparseness) { + static rocksdb::TableFactory* factory = 0; + if (!factory) { + factory = rocksdb::NewPlainTableFactory( + user_key_len, bloom_bits_per_key, + hash_table_ratio, index_sparseness); + } + opt->rep.table_factory.reset(factory); +} + void rocksdb_options_set_max_successive_merges( rocksdb_options_t* opt, size_t v) { opt->rep.max_successive_merges = v; diff --git a/db/c_test.c b/db/c_test.c index 4a7957b14..e6c5a9e67 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -443,6 +443,7 @@ int main(int argc, char** argv) { rocksdb_options_set_filter_policy(options, policy); rocksdb_options_set_prefix_extractor(options, rocksdb_slicetransform_create_fixed_prefix(3)); rocksdb_options_set_hash_skip_list_rep(options, 50000, 4, 4); + rocksdb_options_set_plain_table_factory(options, 4, 10, 0.75, 16); db = rocksdb_open(options, dbname, &err); CheckNoError(err); diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index a6bc90085..74ed6a340 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -348,6 +348,7 @@ extern void rocksdb_options_prepare_for_bulk_load(rocksdb_options_t*); extern void rocksdb_options_set_memtable_vector_rep(rocksdb_options_t*); extern void rocksdb_options_set_hash_skip_list_rep(rocksdb_options_t*, size_t, int32_t, int32_t); extern void rocksdb_options_set_hash_link_list_rep(rocksdb_options_t*, size_t); +extern void rocksdb_options_set_plain_table_factory(rocksdb_options_t*, uint32_t, int, double, size_t); extern void rocksdb_options_set_max_bytes_for_level_base(rocksdb_options_t* opt, uint64_t n); extern void rocksdb_options_set_stats_dump_period_sec(rocksdb_options_t* opt, unsigned int sec);