Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
1aeafecc
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,发现更多精彩内容 >>
提交
1aeafecc
编写于
3月 01, 2014
作者:
K
kailiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the Create() function comform the convention
Summary: Moved "Return multiple values" a more conventional way.
上级
16d4e45c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
29 deletion
+22
-29
table/block_based_table_reader.cc
table/block_based_table_reader.cc
+21
-28
table/block_based_table_reader.h
table/block_based_table_reader.h
+1
-1
未找到文件。
table/block_based_table_reader.cc
浏览文件 @
1aeafecc
...
...
@@ -148,26 +148,20 @@ class BinarySearchIndexReader : public IndexReader {
public:
// Read index from the file and create an intance for
// `BinarySearchIndexReader`.
// The return value is a pair, where
// * first element is the status indicating if the operation succeeded.
// * second element is the index reader to be created. On failure, this
// element will be nullptr
static
std
::
pair
<
Status
,
IndexReader
*>
Create
(
RandomAccessFile
*
file
,
const
BlockHandle
&
index_handle
,
Env
*
env
,
const
Comparator
*
comparator
)
{
// On success, index_reader will be populated; otherwise it will remain
// unmodified.
static
Status
Create
(
RandomAccessFile
*
file
,
const
BlockHandle
&
index_handle
,
Env
*
env
,
const
Comparator
*
comparator
,
IndexReader
**
index_reader
)
{
Block
*
index_block
=
nullptr
;
auto
s
=
ReadBlockFromFile
(
file
,
ReadOptions
(),
index_handle
,
&
index_block
,
env
);
auto
s
=
ReadBlockFromFile
(
file
,
ReadOptions
(),
index_handle
,
&
index_block
,
env
);
if
(
!
s
.
ok
())
{
// Logically, index_block shouldn't have been populated if any error
// occurred.
assert
(
index_block
==
nullptr
);
return
{
s
,
nullptr
};
if
(
s
.
ok
())
{
*
index_reader
=
new
BinarySearchIndexReader
(
comparator
,
index_block
);
}
return
{
s
,
new
BinarySearchIndexReader
(
comparator
,
index_block
)}
;
return
s
;
}
virtual
Iterator
*
NewIterator
()
override
{
...
...
@@ -190,12 +184,12 @@ class BinarySearchIndexReader : public IndexReader {
// key.
class
HashIndexReader
:
public
IndexReader
{
public:
static
std
::
pair
<
Status
,
IndexReader
*>
Create
(
RandomAccessFile
*
file
,
const
BlockHandle
&
index_handle
,
Env
*
env
,
const
Comparator
*
comparator
,
BlockBasedTable
*
table
,
const
SliceTransform
*
prefix_extractor
)
{
return
{
Status
::
NotSupported
(
"not implemented yet!"
),
nullptr
};
// not finished
static
Status
Create
(
RandomAccessFile
*
file
,
const
BlockHandle
&
index_handle
,
Env
*
env
,
const
Comparator
*
comparator
,
BlockBasedTable
*
table
,
const
SliceTransform
*
prefix_extractor
,
IndexReader
**
index_reader
)
{
return
Status
::
NotSupported
(
"not implemented yet!"
);
}
};
...
...
@@ -367,7 +361,7 @@ Status BlockBasedTable::Open(const Options& options, const EnvOptions& soptions,
// and with a same life-time as this table object.
IndexReader
*
index_reader
=
nullptr
;
// TODO: we never really verify check sum for index block
s
td
::
tie
(
s
,
index_reader
)
=
new_table
->
CreateIndexReader
(
);
s
=
new_table
->
CreateIndexReader
(
&
index_reader
);
if
(
s
.
ok
())
{
rep
->
index_reader
.
reset
(
index_reader
);
...
...
@@ -779,7 +773,7 @@ Iterator* BlockBasedTable::NewIndexIterator(const ReadOptions& read_options)
}
else
{
// Create index reader and put it in the cache.
Status
s
;
s
td
::
tie
(
s
,
index_reader
)
=
CreateIndexReader
(
);
s
=
CreateIndexReader
(
&
index_reader
);
if
(
!
s
.
ok
())
{
// make sure if something goes wrong, index_reader shall remain intact.
...
...
@@ -979,7 +973,7 @@ bool BlockBasedTable::TEST_KeyInCache(const ReadOptions& options,
// 3. options
// 4. internal_comparator
// 5. index_type
std
::
pair
<
Status
,
IndexReader
*>
BlockBasedTable
::
CreateIndexReader
(
)
const
{
Status
BlockBasedTable
::
CreateIndexReader
(
IndexReader
**
index_reader
)
const
{
// Some old version of block-based tables don't have index type present in
// table properties. If that's the case we can safely use the kBinarySearch.
auto
index_type
=
BlockBasedTableOptions
::
kBinarySearch
;
...
...
@@ -994,15 +988,14 @@ std::pair<Status, IndexReader*> BlockBasedTable::CreateIndexReader() const {
case
BlockBasedTableOptions
::
kBinarySearch
:
{
return
BinarySearchIndexReader
::
Create
(
rep_
->
file
.
get
(),
rep_
->
index_handle
,
rep_
->
options
.
env
,
&
rep_
->
internal_comparator
);
&
rep_
->
internal_comparator
,
index_reader
);
}
default:
{
std
::
string
error_message
=
"Unrecognized index type: "
+
std
::
to_string
(
rep_
->
index_type
);
// equivalent to assert(false), but more informative.
assert
(
!
error_message
.
c_str
());
return
{
Status
::
InvalidArgument
(
error_message
.
c_str
()),
nullptr
};
// cannot reach here
return
Status
::
InvalidArgument
(
error_message
.
c_str
());
}
}
}
...
...
table/block_based_table_reader.h
浏览文件 @
1aeafecc
...
...
@@ -164,7 +164,7 @@ class BlockBasedTable : public TableReader {
void
ReadMeta
(
const
Footer
&
footer
);
void
ReadFilter
(
const
Slice
&
filter_handle_value
);
std
::
pair
<
Status
,
IndexReader
*>
CreateIndexReader
(
)
const
;
Status
CreateIndexReader
(
IndexReader
**
index_reader
)
const
;
// Read the meta block from sst.
static
Status
ReadMetaBlock
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录