Adding prefix_extractor string config parameter

Summary:
This diff enables to configure prefix_extractor
string parameter as a CF option.

Test Plan: make all check, ./options_test

Reviewers: sdong, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D31653
main
Yoshinori Matsunobu 10 years ago
parent 3d628f8f22
commit ceaea2b72d
  1. 10
      util/options_helper.cc
  2. 6
      util/options_test.cc

@ -9,6 +9,7 @@
#include "rocksdb/cache.h"
#include "rocksdb/filter_policy.h"
#include "rocksdb/options.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/table.h"
#include "rocksdb/utilities/convenience.h"
#include "util/options_helper.h"
@ -508,6 +509,15 @@ Status GetColumnFamilyOptionsFromMap(
new_options->min_partial_merge_operands = ParseUint32(o.second);
} else if (o.first == "inplace_update_support") {
new_options->inplace_update_support = ParseBoolean(o.first, o.second);
} else if (o.first == "prefix_extractor") {
const std::string kName = "fixed:";
if (o.second.compare(0, kName.size(), kName) != 0) {
return Status::InvalidArgument("Invalid Prefix Extractor type: "
+ o.second);
}
int prefix_length = ParseInt(trim(o.second.substr(kName.size())));
new_options->prefix_extractor.reset(
NewFixedPrefixTransform(prefix_length));
} else {
return Status::InvalidArgument("Unrecognized option: " + o.first);
}

@ -129,7 +129,8 @@ TEST(OptionsTest, GetOptionsFromMapTest) {
{"memtable_prefix_bloom_huge_page_tlb_size", "28"},
{"bloom_locality", "29"},
{"max_successive_merges", "30"},
{"min_partial_merge_operands", "31"}
{"min_partial_merge_operands", "31"},
{"prefix_extractor", "fixed:31"}
};
std::unordered_map<std::string, std::string> db_options_map = {
@ -220,6 +221,9 @@ TEST(OptionsTest, GetOptionsFromMapTest) {
ASSERT_EQ(new_cf_opt.bloom_locality, 29U);
ASSERT_EQ(new_cf_opt.max_successive_merges, 30U);
ASSERT_EQ(new_cf_opt.min_partial_merge_operands, 31U);
ASSERT_TRUE(new_cf_opt.prefix_extractor != nullptr);
ASSERT_EQ(std::string(new_cf_opt.prefix_extractor->Name()),
"rocksdb.FixedPrefix.31");
cf_options_map["write_buffer_size"] = "hello";
ASSERT_NOK(GetColumnFamilyOptionsFromMap(

Loading…
Cancel
Save