From 5c1c90487707408c8fb47a322d0012e162ca496d Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Tue, 10 May 2016 16:33:47 -0700 Subject: [PATCH] ldb option for compression dictionary size Summary: Expose the option so it's easy to run offline tests of compression dictionary feature. Test Plan: verified compression dictionary is loaded into lz4 for below command: $ ./ldb compact --compression_type=lz4 --compression_max_dict_bytes=16384 --db=/tmp/feed-compression-test/ Reviewers: IslamAbdelRahman, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D57441 --- include/rocksdb/utilities/ldb_cmd.h | 1 + tools/ldb_cmd.cc | 14 ++++++++++++++ tools/ldb_tool.cc | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/rocksdb/utilities/ldb_cmd.h b/include/rocksdb/utilities/ldb_cmd.h index a3a260097..48bbedfed 100644 --- a/include/rocksdb/utilities/ldb_cmd.h +++ b/include/rocksdb/utilities/ldb_cmd.h @@ -44,6 +44,7 @@ class LDBCommand { static const std::string ARG_BLOOM_BITS; static const std::string ARG_FIX_PREFIX_LEN; static const std::string ARG_COMPRESSION_TYPE; + static const std::string ARG_COMPRESSION_MAX_DICT_BYTES; static const std::string ARG_BLOCK_SIZE; static const std::string ARG_AUTO_COMPACTION; static const std::string ARG_DB_WRITE_BUFFER_SIZE; diff --git a/tools/ldb_cmd.cc b/tools/ldb_cmd.cc index e6c1e6bfb..d1adb52ce 100644 --- a/tools/ldb_cmd.cc +++ b/tools/ldb_cmd.cc @@ -58,6 +58,8 @@ const string LDBCommand::ARG_MAX_KEYS = "max_keys"; const string LDBCommand::ARG_BLOOM_BITS = "bloom_bits"; const string LDBCommand::ARG_FIX_PREFIX_LEN = "fix_prefix_len"; const string LDBCommand::ARG_COMPRESSION_TYPE = "compression_type"; +const string LDBCommand::ARG_COMPRESSION_MAX_DICT_BYTES = + "compression_max_dict_bytes"; const string LDBCommand::ARG_BLOCK_SIZE = "block_size"; const string LDBCommand::ARG_AUTO_COMPACTION = "auto_compaction"; const string LDBCommand::ARG_DB_WRITE_BUFFER_SIZE = "db_write_buffer_size"; @@ -363,6 +365,7 @@ vector LDBCommand::BuildCmdLineOptions(vector options) { ARG_BLOCK_SIZE, ARG_AUTO_COMPACTION, ARG_COMPRESSION_TYPE, + ARG_COMPRESSION_MAX_DICT_BYTES, ARG_WRITE_BUFFER_SIZE, ARG_FILE_SIZE, ARG_FIX_PREFIX_LEN, @@ -483,6 +486,17 @@ Options LDBCommand::PrepareOptionsForOpenDB() { } } + int compression_max_dict_bytes; + if (ParseIntOption(option_map_, ARG_COMPRESSION_MAX_DICT_BYTES, + compression_max_dict_bytes, exec_state_)) { + if (compression_max_dict_bytes >= 0) { + opt.compression_opts.max_dict_bytes = compression_max_dict_bytes; + } else { + exec_state_ = LDBCommandExecuteResult::Failed( + ARG_COMPRESSION_MAX_DICT_BYTES + " must be >= 0."); + } + } + int db_write_buffer_size; if (ParseIntOption(option_map_, ARG_DB_WRITE_BUFFER_SIZE, db_write_buffer_size, exec_state_)) { diff --git a/tools/ldb_tool.cc b/tools/ldb_tool.cc index 90581699e..5e31d38dd 100644 --- a/tools/ldb_tool.cc +++ b/tools/ldb_tool.cc @@ -45,7 +45,9 @@ public: ret.append(" --" + LDBCommand::ARG_BLOOM_BITS + "=\n"); ret.append(" --" + LDBCommand::ARG_FIX_PREFIX_LEN + "=\n"); ret.append(" --" + LDBCommand::ARG_COMPRESSION_TYPE + - "=\n"); + "=\n"); + ret.append(" --" + LDBCommand::ARG_COMPRESSION_MAX_DICT_BYTES + + "=\n"); ret.append(" --" + LDBCommand::ARG_BLOCK_SIZE + "=\n"); ret.append(" --" + LDBCommand::ARG_AUTO_COMPACTION + "=\n");