Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
a486352e
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,发现更多精彩内容 >>
提交
a486352e
编写于
11月 26, 2014
作者:
I
Igor Canadi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #423 from zerebubuth/c_iterate_upper_bound
C iterate upper bound
上级
a9731421
26109d48
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
72 addition
and
3 deletion
+72
-3
db/c.cc
db/c.cc
+12
-3
db/c_test.c
db/c_test.c
+60
-0
未找到文件。
db/c.cc
浏览文件 @
a486352e
...
...
@@ -80,7 +80,10 @@ struct rocksdb_writebatch_t { WriteBatch rep; };
struct
rocksdb_snapshot_t
{
const
Snapshot
*
rep
;
};
struct
rocksdb_flushoptions_t
{
FlushOptions
rep
;
};
struct
rocksdb_fifo_compaction_options_t
{
CompactionOptionsFIFO
rep
;
};
struct
rocksdb_readoptions_t
{
ReadOptions
rep
;
};
struct
rocksdb_readoptions_t
{
ReadOptions
rep
;
Slice
upper_bound
;
// stack variable to set pointer to in ReadOptions
};
struct
rocksdb_writeoptions_t
{
WriteOptions
rep
;
};
struct
rocksdb_options_t
{
Options
rep
;
};
struct
rocksdb_block_based_table_options_t
{
BlockBasedTableOptions
rep
;
};
...
...
@@ -1891,8 +1894,14 @@ void rocksdb_readoptions_set_snapshot(
void
rocksdb_readoptions_set_iterate_upper_bound
(
rocksdb_readoptions_t
*
opt
,
const
char
*
key
,
size_t
keylen
)
{
Slice
prefix
=
Slice
(
key
,
keylen
);
opt
->
rep
.
iterate_upper_bound
=
&
prefix
;
if
(
key
==
nullptr
)
{
opt
->
upper_bound
=
Slice
();
opt
->
rep
.
iterate_upper_bound
=
nullptr
;
}
else
{
opt
->
upper_bound
=
Slice
(
key
,
keylen
);
opt
->
rep
.
iterate_upper_bound
=
&
opt
->
upper_bound
;
}
}
void
rocksdb_readoptions_set_read_tier
(
...
...
db/c_test.c
浏览文件 @
a486352e
...
...
@@ -823,6 +823,66 @@ int main(int argc, char** argv) {
rocksdb_cuckoo_options_destroy
(
cuckoo_options
);
}
StartPhase
(
"iterate_upper_bound"
);
{
// Create new empty database
rocksdb_close
(
db
);
rocksdb_destroy_db
(
options
,
dbname
,
&
err
);
CheckNoError
(
err
);
rocksdb_options_set_prefix_extractor
(
options
,
NULL
);
db
=
rocksdb_open
(
options
,
dbname
,
&
err
);
CheckNoError
(
err
);
rocksdb_put
(
db
,
woptions
,
"a"
,
1
,
"0"
,
1
,
&
err
);
CheckNoError
(
err
);
rocksdb_put
(
db
,
woptions
,
"foo"
,
3
,
"bar"
,
3
,
&
err
);
CheckNoError
(
err
);
rocksdb_put
(
db
,
woptions
,
"foo1"
,
4
,
"bar1"
,
4
,
&
err
);
CheckNoError
(
err
);
rocksdb_put
(
db
,
woptions
,
"g1"
,
2
,
"0"
,
1
,
&
err
);
CheckNoError
(
err
);
// testing basic case with no iterate_upper_bound and no prefix_extractor
{
rocksdb_readoptions_set_iterate_upper_bound
(
roptions
,
NULL
,
0
);
rocksdb_iterator_t
*
iter
=
rocksdb_create_iterator
(
db
,
roptions
);
rocksdb_iter_seek
(
iter
,
"foo"
,
3
);
CheckCondition
(
rocksdb_iter_valid
(
iter
));
CheckIter
(
iter
,
"foo"
,
"bar"
);
rocksdb_iter_next
(
iter
);
CheckCondition
(
rocksdb_iter_valid
(
iter
));
CheckIter
(
iter
,
"foo1"
,
"bar1"
);
rocksdb_iter_next
(
iter
);
CheckCondition
(
rocksdb_iter_valid
(
iter
));
CheckIter
(
iter
,
"g1"
,
"0"
);
rocksdb_iter_destroy
(
iter
);
}
// testing iterate_upper_bound and forward iterator
// to make sure it stops at bound
{
// iterate_upper_bound points beyond the last expected entry
rocksdb_readoptions_set_iterate_upper_bound
(
roptions
,
"foo2"
,
4
);
rocksdb_iterator_t
*
iter
=
rocksdb_create_iterator
(
db
,
roptions
);
rocksdb_iter_seek
(
iter
,
"foo"
,
3
);
CheckCondition
(
rocksdb_iter_valid
(
iter
));
CheckIter
(
iter
,
"foo"
,
"bar"
);
rocksdb_iter_next
(
iter
);
CheckCondition
(
rocksdb_iter_valid
(
iter
));
CheckIter
(
iter
,
"foo1"
,
"bar1"
);
rocksdb_iter_next
(
iter
);
// should stop here...
CheckCondition
(
!
rocksdb_iter_valid
(
iter
));
rocksdb_iter_destroy
(
iter
);
}
}
StartPhase
(
"cleanup"
);
rocksdb_close
(
db
);
rocksdb_options_destroy
(
options
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录