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
a73ebe88
Commit
a73ebe88
authored
Sep 20, 2016
by
goroutine
Committed by
GitHub
Sep 20, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from BusyJay/busyjay/clean-up
clean up test directory
parents
7363e39b
9fa33a5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
main.rs
src/main.rs
+0
-27
test_iterator.rs
test/test_iterator.rs
+28
-1
No files found.
src/main.rs
View file @
a73ebe88
...
@@ -194,33 +194,6 @@ mod tests {
...
@@ -194,33 +194,6 @@ mod tests {
DB
::
open
(
&
opts
,
path
)
.unwrap
()
DB
::
open
(
&
opts
,
path
)
.unwrap
()
}
}
#[test]
fn
read_with_upper_bound
()
{
let
path
=
"_rust_rocksdb_read_with_upper_bound_test"
;
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
{
let
db
=
DB
::
open
(
&
opts
,
path
)
.unwrap
();
let
writeopts
=
WriteOptions
::
new
();
db
.put_opt
(
b
"k1-0"
,
b
"a"
,
&
writeopts
)
.unwrap
();
db
.put_opt
(
b
"k1-1"
,
b
"b"
,
&
writeopts
)
.unwrap
();
db
.put_opt
(
b
"k2-0"
,
b
"c"
,
&
writeopts
)
.unwrap
();
let
mut
readopts
=
ReadOptions
::
new
();
readopts
.set_iterate_upper_bound
(
b
"k2"
);
let
mut
iter
=
db
.iter_opt
(
readopts
);
iter
.seek
(
SeekKey
::
Start
);
let
mut
count
=
0
;
while
iter
.valid
()
{
count
+=
1
;
if
!
iter
.next
()
{
break
;
}
}
assert_eq!
(
count
,
2
);
}
}
// TODO(tyler) unstable
// TODO(tyler) unstable
// #[bench]
// #[bench]
// fn a_writes(b: &mut Bencher) {
// fn a_writes(b: &mut Bencher) {
...
...
test/test_iterator.rs
View file @
a73ebe88
use
rocksdb
::
{
DB
,
Writable
,
SeekKey
,
DBIterator
,
Kv
}
;
use
rocksdb
::
*
;
use
tempdir
::
TempDir
;
use
tempdir
::
TempDir
;
fn
prev_collect
<
'a
>
(
iter
:
&
mut
DBIterator
<
'a
>
)
->
Vec
<
Kv
>
{
fn
prev_collect
<
'a
>
(
iter
:
&
mut
DBIterator
<
'a
>
)
->
Vec
<
Kv
>
{
...
@@ -113,3 +113,30 @@ pub fn test_iterator() {
...
@@ -113,3 +113,30 @@ pub fn test_iterator() {
iter
.prev
();
iter
.prev
();
assert
!
(
!
iter
.valid
());
assert
!
(
!
iter
.valid
());
}
}
#[test]
fn
read_with_upper_bound
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_read_with_upper_bound_test"
)
.expect
(
""
);
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
{
let
db
=
DB
::
open
(
&
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
writeopts
=
WriteOptions
::
new
();
db
.put_opt
(
b
"k1-0"
,
b
"a"
,
&
writeopts
)
.unwrap
();
db
.put_opt
(
b
"k1-1"
,
b
"b"
,
&
writeopts
)
.unwrap
();
db
.put_opt
(
b
"k2-0"
,
b
"c"
,
&
writeopts
)
.unwrap
();
let
mut
readopts
=
ReadOptions
::
new
();
readopts
.set_iterate_upper_bound
(
b
"k2"
);
let
mut
iter
=
db
.iter_opt
(
readopts
);
iter
.seek
(
SeekKey
::
Start
);
let
mut
count
=
0
;
while
iter
.valid
()
{
count
+=
1
;
if
!
iter
.next
()
{
break
;
}
}
assert_eq!
(
count
,
2
);
}
}
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