Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
bd7be035
R
rocksdb
项目概览
kvdb
/
rocksdb
11 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rocksdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd7be035
编写于
11月 17, 2015
作者:
S
SherlockNoMad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support Memtable Factory Parse in option_helper.cc
上级
605a24d9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
135 addition
and
5 deletion
+135
-5
include/rocksdb/convenience.h
include/rocksdb/convenience.h
+4
-0
util/options_helper.cc
util/options_helper.cc
+79
-0
util/options_test.cc
util/options_test.cc
+52
-5
未找到文件。
include/rocksdb/convenience.h
浏览文件 @
bd7be035
...
...
@@ -85,6 +85,10 @@ Status GetPlainTableOptionsFromString(
const
std
::
string
&
opts_str
,
PlainTableOptions
*
new_table_options
);
Status
GetMemTableRepFactoryFromString
(
const
std
::
string
&
opts_str
,
std
::
unique_ptr
<
MemTableRepFactory
>*
new_mem_factory
);
Status
GetOptionsFromString
(
const
Options
&
base_options
,
const
std
::
string
&
opts_str
,
Options
*
new_options
);
...
...
util/options_helper.cc
浏览文件 @
bd7be035
...
...
@@ -865,6 +865,15 @@ Status ParseColumnFamilyOption(const std::string& name,
"unable to parse the specified CF option "
+
name
);
}
new_options
->
table_factory
.
reset
(
NewPlainTableFactory
(
table_opt
));
}
else
if
(
name
==
"memtable"
)
{
std
::
unique_ptr
<
MemTableRepFactory
>
new_mem_factory
;
Status
mem_factory_s
=
GetMemTableRepFactoryFromString
(
value
,
&
new_mem_factory
);
if
(
!
mem_factory_s
.
ok
())
{
return
Status
::
InvalidArgument
(
"unable to parse the specified CF option "
+
name
);
}
new_options
->
memtable_factory
.
reset
(
new_mem_factory
.
release
());
}
else
if
(
name
==
"compression_opts"
)
{
size_t
start
=
0
;
size_t
end
=
value
.
find
(
':'
);
...
...
@@ -1243,6 +1252,76 @@ Status GetPlainTableOptionsFromString(
new_table_options
);
}
Status
GetMemTableRepFactoryFromString
(
const
std
::
string
&
opts_str
,
std
::
unique_ptr
<
MemTableRepFactory
>*
new_mem_factory
)
{
std
::
vector
<
std
::
string
>
opts_list
=
StringSplit
(
opts_str
,
':'
);
size_t
len
=
opts_list
.
size
();
if
(
opts_list
.
size
()
<=
0
||
opts_list
.
size
()
>
2
)
{
return
Status
::
InvalidArgument
(
"Can't parse memtable_factory option "
,
opts_str
);
}
MemTableRepFactory
*
mem_factory
=
nullptr
;
if
(
opts_list
[
0
]
==
"skip_list"
)
{
// Expecting format
// skip_list:<lookahead>
if
(
2
==
len
)
{
size_t
lookahead
=
ParseSizeT
(
opts_list
[
1
]);
mem_factory
=
new
SkipListFactory
(
lookahead
);
}
else
if
(
1
==
len
)
{
mem_factory
=
new
SkipListFactory
();
}
}
else
if
(
opts_list
[
0
]
==
"prefix_hash"
)
{
// Expecting format
// prfix_hash:<hash_bucket_count>
if
(
2
==
len
)
{
size_t
hash_bucket_count
=
ParseSizeT
(
opts_list
[
1
]);
mem_factory
=
NewHashSkipListRepFactory
(
hash_bucket_count
);
}
else
if
(
1
==
len
)
{
mem_factory
=
NewHashSkipListRepFactory
();
}
}
else
if
(
opts_list
[
0
]
==
"hash_linkedlist"
)
{
// Expecting format
// hash_linkedlist:<hash_bucket_count>
if
(
2
==
len
)
{
size_t
hash_bucket_count
=
ParseSizeT
(
opts_list
[
1
]);
mem_factory
=
NewHashLinkListRepFactory
(
hash_bucket_count
);
}
else
if
(
1
==
len
)
{
mem_factory
=
NewHashLinkListRepFactory
();
}
}
else
if
(
opts_list
[
0
]
==
"vector"
)
{
// Expecting format
// vector:<count>
if
(
2
==
len
)
{
size_t
count
=
ParseSizeT
(
opts_list
[
1
]);
mem_factory
=
new
VectorRepFactory
(
count
);
}
else
if
(
1
==
len
)
{
mem_factory
=
new
VectorRepFactory
();
}
}
else
if
(
opts_list
[
0
]
==
"cuckoo"
)
{
// Expecting format
// cuckoo:<write_buffer_size>
if
(
2
==
len
)
{
size_t
write_buffer_size
=
ParseSizeT
(
opts_list
[
1
]);
mem_factory
=
NewHashCuckooRepFactory
(
write_buffer_size
);
}
else
if
(
1
==
len
)
{
return
Status
::
InvalidArgument
(
"Can't parse memtable_factory option "
,
opts_str
);
}
}
else
{
return
Status
::
InvalidArgument
(
"Unrecognized memtable_factory option "
,
opts_str
);
}
if
(
mem_factory
!=
nullptr
){
new_mem_factory
->
reset
(
mem_factory
);
}
return
Status
::
OK
();
}
Status
GetColumnFamilyOptionsFromMap
(
const
ColumnFamilyOptions
&
base_options
,
const
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
opts_map
,
...
...
util/options_test.cc
浏览文件 @
bd7be035
...
...
@@ -17,6 +17,7 @@
#include "rocksdb/cache.h"
#include "rocksdb/convenience.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/utilities/leveldb_options.h"
#include "util/options_helper.h"
#include "util/options_parser.h"
...
...
@@ -448,6 +449,14 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
&
new_cf_opt
));
ASSERT_TRUE
(
new_cf_opt
.
table_factory
!=
nullptr
);
ASSERT_EQ
(
std
::
string
(
new_cf_opt
.
table_factory
->
Name
()),
"PlainTable"
);
// memtable factory
ASSERT_OK
(
GetColumnFamilyOptionsFromString
(
base_cf_opt
,
"write_buffer_size=10;max_write_buffer_number=16;"
"memtable=skip_list:10;arena_block_size=1024"
,
&
new_cf_opt
));
ASSERT_TRUE
(
new_cf_opt
.
memtable_factory
!=
nullptr
);
ASSERT_EQ
(
std
::
string
(
new_cf_opt
.
memtable_factory
->
Name
()),
"SkipListFactory"
);
}
#endif // !ROCKSDB_LITE
...
...
@@ -535,11 +544,49 @@ TEST_F(OptionsTest, GetPlainTableOptionsFromString) {
&
new_opt
));
// unrecognized EncodingType
ASSERT_NOK
(
GetPlainTableOptionsFromString
(
table_opt
,
"user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;"
"encoding_type=kPrefixXX"
,
&
new_opt
));
ASSERT_NOK
(
GetPlainTableOptionsFromString
(
table_opt
,
"user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;"
"encoding_type=kPrefixXX"
,
&
new_opt
));
}
#endif // !ROCKSDB_LITE
#ifndef ROCKSDB_LITE // GetMemTableRepFactoryFromString is not supported
TEST_F
(
OptionsTest
,
GetMemTableRepFactoryFromString
)
{
std
::
unique_ptr
<
MemTableRepFactory
>
new_mem_factory
=
nullptr
;
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"skip_list"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"skip_list:16"
,
&
new_mem_factory
));
ASSERT_EQ
(
std
::
string
(
new_mem_factory
->
Name
()),
"SkipListFactory"
);
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"skip_list:16:invalid_opt"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"prefix_hash"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"prefix_hash:1000"
,
&
new_mem_factory
));
ASSERT_EQ
(
std
::
string
(
new_mem_factory
->
Name
()),
"HashSkipListRepFactory"
);
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"prefix_hash:1000:invalid_opt"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"hash_linkedlist"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"hash_linkedlist:1000"
,
&
new_mem_factory
));
ASSERT_EQ
(
std
::
string
(
new_mem_factory
->
Name
()),
"HashLinkListRepFactory"
);
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"hash_linkedlist:1000:invalid_opt"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"vector"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"vector:1024"
,
&
new_mem_factory
));
ASSERT_EQ
(
std
::
string
(
new_mem_factory
->
Name
()),
"VectorRepFactory"
);
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"vector:1024:invalid_opt"
,
&
new_mem_factory
));
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"cuckoo"
,
&
new_mem_factory
));
ASSERT_OK
(
GetMemTableRepFactoryFromString
(
"cuckoo:1024"
,
&
new_mem_factory
));
ASSERT_EQ
(
std
::
string
(
new_mem_factory
->
Name
()),
"HashCuckooRepFactory"
);
ASSERT_NOK
(
GetMemTableRepFactoryFromString
(
"bad_factory"
,
&
new_mem_factory
));
}
#endif // !ROCKSDB_LITE
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录