Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rust-rocksdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
rust-rocksdb
Commits
5906f6e1
Commit
5906f6e1
authored
Apr 12, 2019
by
zhangjinpeng1987
Committed by
Yi Wu
Jun 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Vec parameter for ReadOptions' bound APIs. (#287)
parent
09c52781
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
rocksdb_options.rs
src/rocksdb_options.rs
+12
-4
test_iterator.rs
tests/cases/test_iterator.rs
+3
-1
test_rocksdb_options.rs
tests/cases/test_rocksdb_options.rs
+2
-2
No files found.
src/rocksdb_options.rs
View file @
5906f6e1
...
...
@@ -311,8 +311,8 @@ impl ReadOptions {
crocksdb_ffi
::
crocksdb_readoptions_set_snapshot
(
self
.inner
,
snapshot
.inner
);
}
pub
fn
set_iterate_lower_bound
(
&
mut
self
,
key
:
&
[
u8
]
)
{
self
.lower_bound
=
Vec
::
from
(
key
)
;
pub
fn
set_iterate_lower_bound
(
&
mut
self
,
key
:
Vec
<
u8
>
)
{
self
.lower_bound
=
key
;
unsafe
{
crocksdb_ffi
::
crocksdb_readoptions_set_iterate_lower_bound
(
self
.inner
,
...
...
@@ -322,8 +322,12 @@ impl ReadOptions {
}
}
pub
fn
set_iterate_upper_bound
(
&
mut
self
,
key
:
&
[
u8
])
{
self
.upper_bound
=
Vec
::
from
(
key
);
pub
fn
iterate_lower_bound
(
&
self
)
->
&
[
u8
]
{
&
self
.lower_bound
}
pub
fn
set_iterate_upper_bound
(
&
mut
self
,
key
:
Vec
<
u8
>
)
{
self
.upper_bound
=
key
;
unsafe
{
crocksdb_ffi
::
crocksdb_readoptions_set_iterate_upper_bound
(
self
.inner
,
...
...
@@ -333,6 +337,10 @@ impl ReadOptions {
}
}
pub
fn
iterate_upper_bound
(
&
self
)
->
&
[
u8
]
{
&
self
.upper_bound
}
pub
fn
set_read_tier
(
&
mut
self
,
tier
:
c_int
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_readoptions_set_read_tier
(
self
.inner
,
tier
);
...
...
tests/cases/test_iterator.rs
View file @
5906f6e1
...
...
@@ -278,7 +278,9 @@ fn read_with_upper_bound() {
db
.put_opt
(
b
"k2-0"
,
b
"c"
,
&
writeopts
)
.unwrap
();
let
mut
readopts
=
ReadOptions
::
new
();
readopts
.set_iterate_upper_bound
(
b
"k2"
);
let
upper_bound
=
b
"k2"
.to_vec
();
readopts
.set_iterate_upper_bound
(
upper_bound
);
assert_eq!
(
readopts
.iterate_upper_bound
(),
b
"k2"
);
let
mut
iter
=
db
.iter_opt
(
readopts
);
iter
.seek
(
SeekKey
::
Start
);
let
vec
=
next_collect
(
&
mut
iter
);
...
...
tests/cases/test_rocksdb_options.rs
View file @
5906f6e1
...
...
@@ -656,8 +656,8 @@ fn test_readoptions_lower_bound() {
db
.put
(
b
"k3"
,
b
"a"
)
.unwrap
();
let
mut
read_opts
=
ReadOptions
::
new
();
let
lower_bound
=
b
"k2"
;
read_opts
.set_iterate_lower_bound
(
lower_bound
.as_ref
()
);
let
lower_bound
=
b
"k2"
.to_vec
()
;
read_opts
.set_iterate_lower_bound
(
lower_bound
);
let
mut
iter
=
db
.iter_opt
(
read_opts
);
iter
.seek
(
SeekKey
::
Key
(
b
"k3"
));
let
mut
count
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment