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
e585d23e
Commit
e585d23e
authored
Nov 29, 2014
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2->4 spacing
parent
3fba236e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
38 deletions
+37
-38
ffi.rs
src/ffi.rs
+0
-0
lib.rs
src/lib.rs
+2
-2
main.rs
src/main.rs
+35
-36
rocksdb.rs
src/rocksdb.rs
+0
-0
No files found.
src/ffi.rs
View file @
e585d23e
This diff is collapsed.
Click to expand it.
src/lib.rs
View file @
e585d23e
...
...
@@ -4,8 +4,8 @@
pub
use
ffi
as
rocksdb_ffi
;
pub
use
rocksdb
::{
RocksDB
,
RocksDBResult
,
RocksDB
,
RocksDBResult
,
};
pub
mod
rocksdb
;
pub
mod
ffi
;
src/main.rs
View file @
e585d23e
...
...
@@ -5,53 +5,52 @@ use test::Bencher;
#[allow(dead_code)]
fn
main
()
{
match
RocksDB
::
open_default
(
"/tmp/rust-rocksdb"
)
{
Ok
(
db
)
=>
{
assert
!
(
db
.put
(
b
"my key"
,
b
"my value"
)
.is_ok
());
match
RocksDB
::
open_default
(
"/tmp/rust-rocksdb"
)
{
Ok
(
db
)
=>
{
assert
!
(
db
.put
(
b
"my key"
,
b
"my value"
)
.is_ok
());
db
.get
(
b
"my key"
)
.map
(
|
value
|
{
match
value
.to_utf8
()
{
Some
(
v
)
=>
println!
(
"retrieved utf8 value: {}"
,
v
),
None
=>
println!
(
"did not read valid utf-8 out of the db"
),
}
})
.on_absent
(
||
{
println!
(
"value not found"
)
})
.on_error
(
|
e
|
{
println!
(
"error retrieving value: {}"
,
e
)
});
db
.get
(
b
"my key"
)
.map
(
|
value
|
{
match
value
.to_utf8
()
{
Some
(
v
)
=>
println!
(
"retrieved utf8 value: {}"
,
v
),
None
=>
println!
(
"did not read valid utf-8 out of the db"
),
}
})
.on_absent
(
||
{
println!
(
"value not found"
)
})
.on_error
(
|
e
|
{
println!
(
"error retrieving value: {}"
,
e
)
});
assert
!
(
db
.delete
(
b
"my key"
)
.is_ok
());
assert
!
(
db
.delete
(
b
"my key"
)
.is_ok
());
db
.close
();
},
Err
(
e
)
=>
panic!
(
e
),
}
db
.close
();
},
Err
(
e
)
=>
panic!
(
e
),
}
}
#[allow(dead_code)]
#[bench]
fn
writes
(
b
:
&
mut
Bencher
)
{
let
db
=
RocksDB
::
open_default
(
"testdb"
)
.unwrap
();
let
mut
i
=
0
as
u64
;
b
.iter
(||
{
db
.put
(
i
.to_string
()
.as_bytes
(),
b
"v1111"
);
i
+=
1
;
});
db
.close
();
let
db
=
RocksDB
::
open_default
(
"testdb"
)
.unwrap
();
let
mut
i
=
0
as
u64
;
b
.iter
(||
{
db
.put
(
i
.to_string
()
.as_bytes
(),
b
"v1111"
);
i
+=
1
;
});
db
.close
();
}
#[allow(dead_code)]
#[bench]
fn
reads
(
b
:
&
mut
Bencher
)
{
let
db
=
RocksDB
::
open_default
(
"testdb"
)
.unwrap
();
let
mut
i
=
0
as
u64
;
b
.iter
(||
{
db
.get
(
i
.to_string
()
.as_bytes
())
.on_error
(
|
e
|
{
println!
(
"error: {}"
,
e
);
e
});
i
+=
1
;
});
db
.close
();
let
db
=
RocksDB
::
open_default
(
"testdb"
)
.unwrap
();
let
mut
i
=
0
as
u64
;
b
.iter
(||
{
db
.get
(
i
.to_string
()
.as_bytes
())
.on_error
(
|
e
|
{
println!
(
"error: {}"
,
e
);
e
});
i
+=
1
;
});
db
.close
();
}
src/rocksdb.rs
View file @
e585d23e
This diff is collapsed.
Click to expand it.
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