Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
c8ecfaed
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8ecfaed
编写于
8月 18, 2014
作者:
I
Igor Canadi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #230 from cockroachdb/spencerkimball/send-user-keys-to-v2-filter
Pass parsed user key to prefix extractor in V2 compaction
上级
570ba5ac
bcefedeb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
36 addition
and
9 deletion
+36
-9
HISTORY.md
HISTORY.md
+1
-0
db/c_test.c
db/c_test.c
+28
-2
db/db_impl.cc
db/db_impl.cc
+7
-7
未找到文件。
HISTORY.md
浏览文件 @
c8ecfaed
...
...
@@ -13,6 +13,7 @@
*
Statistics APIs now take uint32_t as type instead of Tickers. Also make two access functions getTickerCount and histogramData const
*
Add DB property rocksdb.estimate-num-keys, estimated number of live keys in DB.
*
Add DB::GetIntProperty(), which returns DB properties that are integer as uint64_t.
*
The Prefix Extractor used with V2 compaction filters is now passed user key to SliceTransform::Transform instead of unparsed RocksDB key.
## 3.3.0 (7/10/2014)
### New Features
...
...
db/c_test.c
浏览文件 @
c8ecfaed
...
...
@@ -261,6 +261,29 @@ static void CompactionFilterV2Filter(
}
}
// Custom prefix extractor for compaction filter V2 which extracts first 3 characters.
static
void
CFV2PrefixExtractorDestroy
(
void
*
arg
)
{
}
static
char
*
CFV2PrefixExtractorTransform
(
void
*
arg
,
const
char
*
key
,
size_t
length
,
size_t
*
dst_length
)
{
// Verify keys are maximum length 4; this verifies fix for a
// prior bug which was passing the RocksDB-encoded key with
// logical timestamp suffix instead of parsed user key.
if
(
length
>
4
)
{
fprintf
(
stderr
,
"%s:%d: %s: key %s is not user key
\n
"
,
__FILE__
,
__LINE__
,
phase
,
key
);
abort
();
}
*
dst_length
=
length
<
3
?
length
:
3
;
return
(
char
*
)
key
;
}
static
unsigned
char
CFV2PrefixExtractorInDomain
(
void
*
state
,
const
char
*
key
,
size_t
length
)
{
return
1
;
}
static
unsigned
char
CFV2PrefixExtractorInRange
(
void
*
state
,
const
char
*
key
,
size_t
length
)
{
return
1
;
}
static
const
char
*
CFV2PrefixExtractorName
(
void
*
state
)
{
return
"TestCFV2PrefixExtractor"
;
}
// Custom compaction filter factory V2.
static
void
CompactionFilterFactoryV2Destroy
(
void
*
arg
)
{
rocksdb_slicetransform_destroy
((
rocksdb_slicetransform_t
*
)
arg
);
...
...
@@ -585,9 +608,12 @@ int main(int argc, char** argv) {
{
rocksdb_compactionfilterfactoryv2_t
*
factory
;
rocksdb_slicetransform_t
*
prefix_extractor
;
prefix_extractor
=
rocksdb_slicetransform_create_fixed_prefix
(
3
);
prefix_extractor
=
rocksdb_slicetransform_create
(
NULL
,
CFV2PrefixExtractorDestroy
,
CFV2PrefixExtractorTransform
,
CFV2PrefixExtractorInDomain
,
CFV2PrefixExtractorInRange
,
CFV2PrefixExtractorName
);
factory
=
rocksdb_compactionfilterfactoryv2_create
(
prefix_extractor
,
prefix_extractor
,
CompactionFilterFactoryV2Destroy
,
NULL
,
prefix_extractor
,
CompactionFilterFactoryV2Destroy
,
CompactionFilterFactoryV2Create
,
CompactionFilterFactoryV2Name
);
// Create new database
rocksdb_close
(
db
);
...
...
db/db_impl.cc
浏览文件 @
c8ecfaed
...
...
@@ -3038,19 +3038,19 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
Slice
key
=
backup_input
->
key
();
Slice
value
=
backup_input
->
value
();
const
SliceTransform
*
transformer
=
cfd
->
options
()
->
compaction_filter_factory_v2
->
GetPrefixExtractor
();
const
auto
key_prefix
=
transformer
->
Transform
(
key
);
if
(
!
prefix_initialized
)
{
compact
->
cur_prefix_
=
key_prefix
.
ToString
();
prefix_initialized
=
true
;
}
if
(
!
ParseInternalKey
(
key
,
&
ikey
))
{
// log error
Log
(
options_
.
info_log
,
"[%s] Failed to parse key: %s"
,
cfd
->
GetName
().
c_str
(),
key
.
ToString
().
c_str
());
continue
;
}
else
{
const
SliceTransform
*
transformer
=
cfd
->
options
()
->
compaction_filter_factory_v2
->
GetPrefixExtractor
();
const
auto
key_prefix
=
transformer
->
Transform
(
ikey
.
user_key
);
if
(
!
prefix_initialized
)
{
compact
->
cur_prefix_
=
key_prefix
.
ToString
();
prefix_initialized
=
true
;
}
// If the prefix remains the same, keep buffering
if
(
key_prefix
.
compare
(
Slice
(
compact
->
cur_prefix_
))
==
0
)
{
// Apply the compaction filter V2 to all the kv pairs sharing
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录