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
This commit is contained in:
Yoshinori Matsunobu 2015-01-15 15:33:12 -08:00
parent 3d628f8f22
commit ceaea2b72d
2 changed files with 15 additions and 1 deletions

View file

@ -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);
}

View file

@ -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(