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
e5219368
Commit
e5219368
authored
Aug 03, 2015
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic column family iterator support.
parent
36b4ad62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
rocksdb.rs
src/rocksdb.rs
+22
-3
No files found.
src/rocksdb.rs
View file @
e5219368
...
...
@@ -106,6 +106,20 @@ impl DBIterator {
}
}
fn
new_cf
(
db
:
&
RocksDB
,
cf_name
:
&
str
,
readopts
:
&
ReadOptions
)
->
Result
<
DBIterator
,
String
>
{
let
cf
=
db
.cfs
.get
(
cf_name
);
if
cf
.is_none
()
{
return
Err
(
format!
(
"Invalid column family: {}"
,
cf_name
)
.to_string
());
}
unsafe
{
let
iterator
=
rocksdb_ffi
::
rocksdb_create_iterator_cf
(
db
.inner
,
readopts
.inner
,
*
cf
.unwrap
());
rocksdb_ffi
::
rocksdb_iter_seek_to_first
(
iterator
);
Ok
(
DBIterator
{
inner
:
iterator
,
direction
:
Direction
::
forward
,
just_seeked
:
true
})
}
}
pub
fn
from_start
(
&
mut
self
)
->
SubDBIterator
{
self
.just_seeked
=
true
;
unsafe
{
...
...
@@ -389,6 +403,11 @@ impl RocksDB {
DBIterator
::
new
(
&
self
,
&
opts
)
}
pub
fn
iterator_cf
(
&
self
,
cf
:
&
str
)
->
Result
<
DBIterator
,
String
>
{
let
opts
=
ReadOptions
::
new
();
DBIterator
::
new_cf
(
&
self
,
cf
,
&
opts
)
}
pub
fn
snapshot
(
&
self
)
->
Snapshot
{
Snapshot
::
new
(
self
)
}
...
...
@@ -430,7 +449,7 @@ impl Writable for RocksDB {
Ok
(())
}
}
fn
merge
(
&
self
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
let
writeopts
=
rocksdb_ffi
::
rocksdb_writeoptions_create
();
...
...
@@ -446,7 +465,7 @@ impl Writable for RocksDB {
Ok
(())
}
}
fn
merge_cf
(
&
self
,
cf_name
:
&
str
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
let
cf
=
self
.cfs
.get
(
cf_name
);
if
cf
.is_none
()
{
...
...
@@ -492,7 +511,7 @@ impl Writable for RocksDB {
let
writeopts
=
rocksdb_ffi
::
rocksdb_writeoptions_create
();
let
mut
err
:
*
const
i8
=
0
as
*
const
i8
;
let
err_ptr
:
*
mut
*
const
i8
=
&
mut
err
;
rocksdb_ffi
::
rocksdb_delete_cf
(
self
.inner
,
writeopts
.clone
(),
rocksdb_ffi
::
rocksdb_delete_cf
(
self
.inner
,
writeopts
.clone
(),
*
cf
.unwrap
(),
key
.as_ptr
(),
key
.len
()
as
size_t
,
err_ptr
);
rocksdb_ffi
::
rocksdb_writeoptions_destroy
(
writeopts
);
...
...
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