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
#include <errno.h>
#include "rocksdb/db.h"
+#include "rocksdb/table.h"
#include "rocksdb/env.h"
#include "rocksdb/write_batch.h"
#include "rocksdb/slice.h"
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;
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;
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;
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;
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);
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
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