Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
e0abec15
R
rocksdb
项目概览
kvdb
/
rocksdb
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
e0abec15
编写于
12月 22, 2015
作者:
Z
Zhipeng Jia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sorting std::vector instead of using std::set
上级
33e09c0e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
14 deletion
+18
-14
db/compaction_job.cc
db/compaction_job.cc
+18
-14
未找到文件。
db/compaction_job.cc
浏览文件 @
e0abec15
...
...
@@ -334,11 +334,6 @@ struct RangeWithSize {
:
range
(
a
,
b
),
size
(
s
)
{}
};
bool
SliceCompare
(
const
Comparator
*
cmp
,
const
Slice
&
a
,
const
Slice
&
b
)
{
// Returns true if a < b
return
cmp
->
Compare
(
ExtractUserKey
(
a
),
ExtractUserKey
(
b
))
<
0
;
}
// Generates a histogram representing potential divisions of key ranges from
// the input. It adds the starting and/or ending keys of certain input files
// to the working set and then finds the approximate size of data in between
...
...
@@ -347,14 +342,13 @@ bool SliceCompare(const Comparator* cmp, const Slice& a, const Slice& b) {
void
CompactionJob
::
GenSubcompactionBoundaries
()
{
auto
*
c
=
compact_
->
compaction
;
auto
*
cfd
=
c
->
column_family_data
();
std
::
set
<
Slice
,
std
::
function
<
bool
(
const
Slice
&
a
,
const
Slice
&
b
)
>
>
bounds
(
std
::
bind
(
&
SliceCompare
,
cfd
->
user_comparator
(),
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
));
const
Comparator
*
cfd_comparator
=
cfd
->
user_comparator
();
std
::
vector
<
Slice
>
bounds
;
int
start_lvl
=
c
->
start_level
();
int
out_lvl
=
c
->
output_level
();
// Add the starting and/or ending key of certain input files as a potential
// boundary
(because we're inserting into a set, it avoids duplicates)
// boundary
for
(
size_t
lvl_idx
=
0
;
lvl_idx
<
c
->
num_input_levels
();
lvl_idx
++
)
{
int
lvl
=
c
->
level
(
lvl_idx
);
if
(
lvl
>=
start_lvl
&&
lvl
<=
out_lvl
)
{
...
...
@@ -369,27 +363,37 @@ void CompactionJob::GenSubcompactionBoundaries() {
// For level 0 add the starting and ending key of each file since the
// files may have greatly differing key ranges (not range-partitioned)
for
(
size_t
i
=
0
;
i
<
num_files
;
i
++
)
{
bounds
.
emplace
(
flevel
->
files
[
i
].
smallest_key
);
bounds
.
emplace
(
flevel
->
files
[
i
].
largest_key
);
bounds
.
emplace
_back
(
flevel
->
files
[
i
].
smallest_key
);
bounds
.
emplace
_back
(
flevel
->
files
[
i
].
largest_key
);
}
}
else
{
// For all other levels add the smallest/largest key in the level to
// encompass the range covered by that level
bounds
.
emplace
(
flevel
->
files
[
0
].
smallest_key
);
bounds
.
emplace
(
flevel
->
files
[
num_files
-
1
].
largest_key
);
bounds
.
emplace
_back
(
flevel
->
files
[
0
].
smallest_key
);
bounds
.
emplace
_back
(
flevel
->
files
[
num_files
-
1
].
largest_key
);
if
(
lvl
==
out_lvl
)
{
// For the last level include the starting keys of all files since
// the last level is the largest and probably has the widest key
// range. Since it's range partitioned, the ending key of one file
// and the starting key of the next are very close (or identical).
for
(
size_t
i
=
1
;
i
<
num_files
;
i
++
)
{
bounds
.
emplace
(
flevel
->
files
[
i
].
smallest_key
);
bounds
.
emplace
_back
(
flevel
->
files
[
i
].
smallest_key
);
}
}
}
}
}
std
::
sort
(
bounds
.
begin
(),
bounds
.
end
(),
[
cfd_comparator
]
(
const
Slice
&
a
,
const
Slice
&
b
)
->
bool
{
return
cfd_comparator
->
Compare
(
ExtractUserKey
(
a
),
ExtractUserKey
(
b
))
<
0
;
});
// Remove duplicated entries from bounds
bounds
.
erase
(
std
::
unique
(
bounds
.
begin
(),
bounds
.
end
(),
[
cfd_comparator
]
(
const
Slice
&
a
,
const
Slice
&
b
)
->
bool
{
return
cfd_comparator
->
Compare
(
ExtractUserKey
(
a
),
ExtractUserKey
(
b
))
==
0
;
}),
bounds
.
end
());
// Combine consecutive pairs of boundaries into ranges with an approximate
// size of data covered by keys in that range
uint64_t
sum
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录