]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Update RocksDBStore to match new RockDB config API
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Tue, 24 Mar 2015 02:04:17 +0000 (10:04 +0800)
committerSage Weil <sage@redhat.com>
Tue, 24 Mar 2015 15:27:48 +0000 (08:27 -0700)
RockDB configuration api was changed, updated RockDBStore
to use it.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/common/config_opts.h
src/os/RocksDBStore.cc
src/os/RocksDBStore.h

index f3634349871cc06dc3c780dcc9d53fd9d0a11dc4..3169ee87662577fba807f317eba383ac6af929ce 100644 (file)
@@ -703,7 +703,7 @@ OPTION(rocksdb_write_buffer_size, OPT_U64, 0) // rocksdb write buffer size
 OPTION(rocksdb_target_file_size_base, OPT_U64, 0) // target file size for compaction
 OPTION(rocksdb_cache_size, OPT_U64, 0) // rocksdb cache size
 OPTION(rocksdb_block_size, OPT_U64, 0) // rocksdb block size
-OPTION(rocksdb_bloom_size, OPT_INT, 0) // rocksdb bloom bits per entry
+OPTION(rocksdb_bloom_bits_per_key, OPT_INT, 10) // rocksdb bloom bits per entry
 OPTION(rocksdb_write_buffer_num, OPT_INT, 0) // rocksdb bloom bits per entry
 OPTION(rocksdb_background_compactions, OPT_INT, 0) // number for background compaction jobs
 OPTION(rocksdb_background_flushes, OPT_INT, 0) // number for background flush jobs
index dc5e8e6f22ebaa81de92575d879380853f52f8db..237b098905f54e3ecbcbe99f8bd471ff51dec3f4 100644 (file)
@@ -8,6 +8,7 @@
 #include <errno.h>
 
 #include "rocksdb/db.h"
+#include "rocksdb/table.h"
 #include "rocksdb/env.h"
 #include "rocksdb/write_batch.h"
 #include "rocksdb/slice.h"
@@ -25,7 +26,7 @@ int RocksDBStore::init()
   options.write_buffer_size = g_conf->rocksdb_write_buffer_size;
   options.cache_size = g_conf->rocksdb_cache_size;
   options.block_size = g_conf->rocksdb_block_size;
-  options.bloom_size = g_conf->rocksdb_bloom_size;
+  options.bloom_bits_per_key = g_conf->rocksdb_bloom_bits_per_key;
   options.compression_type = g_conf->rocksdb_compression;
   options.paranoid_checks = g_conf->rocksdb_paranoid;
   options.max_open_files = g_conf->rocksdb_max_open_files;
@@ -48,6 +49,7 @@ int RocksDBStore::init()
 int RocksDBStore::do_open(ostream &out, bool create_if_missing)
 {
   rocksdb::Options ldoptions;
+  rocksdb::BlockBasedTableOptions table_options;
 
   if (options.write_buffer_size)
     ldoptions.write_buffer_size = options.write_buffer_size;
@@ -62,15 +64,12 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
   if (options.max_open_files)
     ldoptions.max_open_files = options.max_open_files;
   if (options.cache_size) {
-    ldoptions.block_cache = rocksdb::NewLRUCache(options.cache_size);
+    table_options.block_cache = rocksdb::NewLRUCache(options.cache_size);
   }
   if (options.block_size)
-    ldoptions.block_size = options.block_size;
-  if (options.bloom_size) {
-    const rocksdb::FilterPolicy *_filterpolicy =
-       rocksdb::NewBloomFilterPolicy(options.bloom_size);
-    ldoptions.filter_policy = _filterpolicy;
-    filterpolicy = _filterpolicy;
+    table_options.block_size = options.block_size;
+  if (options.bloom_bits_per_key) {
+    table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(options.bloom_bits_per_key, true));
   }
   if (options.compression_type.length() == 0)
     ldoptions.compression = rocksdb::kNoCompression;
@@ -83,7 +82,7 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
   else
     ldoptions.compression = rocksdb::kNoCompression;
   if (options.block_restart_interval)
-    ldoptions.block_restart_interval = options.block_restart_interval;
+    table_options.block_restart_interval = options.block_restart_interval;
 
   ldoptions.error_if_exists = options.error_if_exists;
   ldoptions.paranoid_checks = options.paranoid_checks;
@@ -108,6 +107,8 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
   if(options.wal_dir.length())
     ldoptions.wal_dir = options.wal_dir;
 
+  //apply table_options
+  ldoptions.table_factory.reset(NewBlockBasedTableFactory(table_options));
 
   //rocksdb::DB *_db;
   rocksdb::Status status = rocksdb::DB::Open(ldoptions, path, &db);
index 87c59de8cbd6460cbb973c5f76f47854865b16a4..71c0854c82fcc0384eed709fd00aa75eaee70ceb 100644 (file)
@@ -117,7 +117,7 @@ public:
     int max_open_files; /// maximum number of files RocksDB can open at once
     uint64_t cache_size; /// size of extra decompressed cache to use
     uint64_t block_size; /// user data per block
-    int bloom_size; /// number of bits per entry to put in a bloom filter
+    int bloom_bits_per_key; /// number of bits per entry to put in a bloom filter
     string compression_type; /// whether to use libsnappy compression or not
 
     // don't change these ones. No, seriously
@@ -140,7 +140,7 @@ public:
       max_open_files(0), //< 0 means default
       cache_size(0), //< 0 means no cache (default)
       block_size(0), //< 0 means default
-      bloom_size(0), //< 0 means no bloom filter (default)
+      bloom_bits_per_key(10), //< 10 is the default value which yields ~1% false positive rate.
       compression_type("none"), //< set to false for no compression
       block_restart_interval(0), //< 0 means default
       error_if_exists(false), //< set to true if you want to check nonexistence