Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
0991cee6
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,发现更多精彩内容 >>
提交
0991cee6
编写于
12月 09, 2015
作者:
Y
Yueh-Hsuan Chiang
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #815 from SherlockNoMad/CounterFix
Fix EstimateNumKeys Counter Inaccurate Issue
上级
0836d265
355fa943
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
11 deletion
+36
-11
db/version_builder.cc
db/version_builder.cc
+2
-1
db/version_set.cc
db/version_set.cc
+25
-8
db/version_set.h
db/version_set.h
+9
-2
未找到文件。
db/version_builder.cc
浏览文件 @
0991cee6
...
...
@@ -338,7 +338,8 @@ class VersionBuilder::Rep {
void
MaybeAddFile
(
VersionStorageInfo
*
vstorage
,
int
level
,
FileMetaData
*
f
)
{
if
(
levels_
[
level
].
deleted_files
.
count
(
f
->
fd
.
GetNumber
())
>
0
)
{
// File is deleted: do nothing
// f is to-be-delected table file
vstorage
->
RemoveCurrentStats
(
f
);
}
else
{
vstorage
->
AddFile
(
level
,
f
,
info_log_
);
}
...
...
db/version_set.cc
浏览文件 @
0991cee6
...
...
@@ -738,24 +738,24 @@ uint64_t VersionStorageInfo::GetEstimatedActiveKeys() const {
// (2) keys are directly overwritten
// (3) deletion on non-existing keys
// (4) low number of samples
if
(
num_samples_
==
0
)
{
if
(
current_
num_samples_
==
0
)
{
return
0
;
}
if
(
accumulated_num_non_deletions_
<=
accumulated
_num_deletions_
)
{
if
(
current_num_non_deletions_
<=
current
_num_deletions_
)
{
return
0
;
}
uint64_t
est
=
accumulated_num_non_deletions_
-
accumulated
_num_deletions_
;
uint64_t
est
=
current_num_non_deletions_
-
current
_num_deletions_
;
uint64_t
file_count
=
0
;
for
(
int
level
=
0
;
level
<
num_levels_
;
++
level
)
{
file_count
+=
files_
[
level
].
size
();
}
if
(
num_samples_
<
file_count
)
{
if
(
current_
num_samples_
<
file_count
)
{
// casting to avoid overflowing
return
(
est
*
static_cast
<
double
>
(
file_count
)
/
num_samples_
);
return
(
est
*
static_cast
<
double
>
(
file_count
)
/
current_
num_samples_
);
}
else
{
return
est
;
}
...
...
@@ -826,7 +826,9 @@ VersionStorageInfo::VersionStorageInfo(
accumulated_raw_value_size_
(
0
),
accumulated_num_non_deletions_
(
0
),
accumulated_num_deletions_
(
0
),
num_samples_
(
0
),
current_num_non_deletions_
(
0
),
current_num_deletions_
(
0
),
current_num_samples_
(
0
),
estimated_compaction_needed_bytes_
(
0
),
finalized_
(
false
)
{
if
(
ref_vstorage
!=
nullptr
)
{
...
...
@@ -836,7 +838,9 @@ VersionStorageInfo::VersionStorageInfo(
accumulated_num_non_deletions_
=
ref_vstorage
->
accumulated_num_non_deletions_
;
accumulated_num_deletions_
=
ref_vstorage
->
accumulated_num_deletions_
;
num_samples_
=
ref_vstorage
->
num_samples_
;
current_num_non_deletions_
=
ref_vstorage
->
current_num_non_deletions_
;
current_num_deletions_
=
ref_vstorage
->
current_num_deletions_
;
current_num_samples_
=
ref_vstorage
->
current_num_samples_
;
}
}
...
...
@@ -993,7 +997,20 @@ void VersionStorageInfo::UpdateAccumulatedStats(FileMetaData* file_meta) {
accumulated_num_non_deletions_
+=
file_meta
->
num_entries
-
file_meta
->
num_deletions
;
accumulated_num_deletions_
+=
file_meta
->
num_deletions
;
num_samples_
++
;
current_num_non_deletions_
+=
file_meta
->
num_entries
-
file_meta
->
num_deletions
;
current_num_deletions_
+=
file_meta
->
num_deletions
;
current_num_samples_
++
;
}
void
VersionStorageInfo
::
RemoveCurrentStats
(
FileMetaData
*
file_meta
)
{
if
(
file_meta
->
init_stats_from_file
)
{
current_num_non_deletions_
-=
file_meta
->
num_entries
-
file_meta
->
num_deletions
;
current_num_deletions_
-=
file_meta
->
num_deletions
;
current_num_samples_
--
;
}
}
void
Version
::
UpdateAccumulatedStats
(
bool
update_stats
)
{
...
...
db/version_set.h
浏览文件 @
0991cee6
...
...
@@ -111,6 +111,9 @@ class VersionStorageInfo {
// Update the accumulated stats from a file-meta.
void
UpdateAccumulatedStats
(
FileMetaData
*
file_meta
);
// Decrease the current stat form a to-be-delected file-meta
void
RemoveCurrentStats
(
FileMetaData
*
file_meta
);
void
ComputeCompensatedSizes
();
// Updates internal structures that keep track of compaction scores
...
...
@@ -400,8 +403,12 @@ class VersionStorageInfo {
uint64_t
accumulated_num_non_deletions_
;
// total number of deletion entries
uint64_t
accumulated_num_deletions_
;
// the number of samples
uint64_t
num_samples_
;
// current number of non_deletion entries
uint64_t
current_num_non_deletions_
;
// current number of delection entries
uint64_t
current_num_deletions_
;
// current number of file samples
uint64_t
current_num_samples_
;
// Estimated bytes needed to be compacted until all levels' size is down to
// target sizes.
uint64_t
estimated_compaction_needed_bytes_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录