Skip to content

Commit

Permalink
Fix deprecated options in RocksDB 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ls4154 committed Mar 25, 2023
1 parent a3862e5 commit 3e0bbe6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rocksdb/rocksdb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ rocksdb.use_direct_reads=false
rocksdb.allow_mmap_writes=false
rocksdb.allow_mmap_reads=false
rocksdb.cache_size=8388608
rocksdb.compressed_cache_size=0
rocksdb.bloom_bits=0

# deprecated since rocksdb 8.0
rocksdb.compressed_cache_size=0

rocksdb.increase_parallelism=false
rocksdb.optimize_level_style_compaction=false
10 changes: 9 additions & 1 deletion rocksdb/rocksdb_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ namespace {

static std::shared_ptr<rocksdb::Env> env_guard;
static std::shared_ptr<rocksdb::Cache> block_cache;
#if ROCKSDB_MAJOR < 8
static std::shared_ptr<rocksdb::Cache> block_cache_compressed;
#endif
} // anonymous

namespace ycsbc {
Expand Down Expand Up @@ -241,7 +243,11 @@ void RocksdbDB::GetOptions(const utils::Properties &props, rocksdb::Options *opt

const std::string options_file = props.GetProperty(PROP_OPTIONS_FILE, PROP_OPTIONS_FILE_DEFAULT);
if (options_file != "") {
rocksdb::Status s = rocksdb::LoadOptionsFromFile(options_file, env, opt, cf_descs);
rocksdb::ConfigOptions config_options;
config_options.ignore_unknown_options = false;
config_options.input_strings_escaped = true;
config_options.env = env;
rocksdb::Status s = rocksdb::LoadOptionsFromFile(config_options, options_file, opt, cf_descs);
if (!s.ok()) {
throw utils::Exception(std::string("RocksDB LoadOptionsFromFile: ") + s.ToString());
}
Expand Down Expand Up @@ -333,12 +339,14 @@ void RocksdbDB::GetOptions(const utils::Properties &props, rocksdb::Options *opt
block_cache = rocksdb::NewLRUCache(cache_size);
table_options.block_cache = block_cache;
}
#if ROCKSDB_MAJOR < 8
size_t compressed_cache_size = std::stoul(props.GetProperty(PROP_COMPRESSED_CACHE_SIZE,
PROP_COMPRESSED_CACHE_SIZE_DEFAULT));
if (compressed_cache_size > 0) {
block_cache_compressed = rocksdb::NewLRUCache(compressed_cache_size);
table_options.block_cache_compressed = block_cache_compressed;
}
#endif
int bloom_bits = std::stoul(props.GetProperty(PROP_BLOOM_BITS, PROP_BLOOM_BITS_DEFAULT));
if (bloom_bits > 0) {
table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(bloom_bits));
Expand Down

0 comments on commit 3e0bbe6

Please sign in to comment.