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
9f55661e
Commit
9f55661e
authored
Jul 27, 2015
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkpointing cf work
parent
4db17230
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
3 deletions
+76
-3
rocksdb.rs
src/rocksdb.rs
+68
-3
test_column_family.rs
test/test_column_family.rs
+8
-0
No files found.
src/rocksdb.rs
View file @
9f55661e
...
...
@@ -250,9 +250,7 @@ impl RocksDB {
db
=
rocksdb_ffi
::
rocksdb_open_column_families
(
opts
.inner
,
cpath_ptr
,
nfam
as
libc
::
c_int
,
names
.as_ptr
(),
copts
,
handles
,
err_ptr
);
copts
,
handles
,
err_ptr
);
}
for
handle
in
cfhandles
.iter
()
{
...
...
@@ -377,6 +375,24 @@ impl RocksDB {
Ok
(())
}
pub
fn
drop_cf
(
&
mut
self
,
name
:
&
str
)
->
Result
<
(),
String
>
{
let
cf
=
self
.cfs
.get
(
name
);
if
cf
.is_none
()
{
return
Err
(
format!
(
"Invalid column family: {}"
,
name
)
.to_string
());
}
let
mut
err
:
*
const
i8
=
0
as
*
const
i8
;
let
err_ptr
:
*
mut
*
const
i8
=
&
mut
err
;
unsafe
{
rocksdb_ffi
::
rocksdb_drop_column_family
(
self
.inner
,
cf
.unwrap
(),
err_ptr
);
}
if
!
err
.is_null
()
{
return
Err
(
error_message
(
err
));
}
Ok
(())
}
pub
fn
iterator
(
&
self
)
->
DBIterator
{
let
opts
=
ReadOptions
::
new
();
DBIterator
::
new
(
&
self
,
&
opts
)
...
...
@@ -698,3 +714,52 @@ fn iterator_test() {
let
opts
=
Options
::
new
();
assert
!
(
RocksDB
::
destroy
(
&
opts
,
path
)
.is_ok
());
}
#[test]
pub
fn
test_column_family
()
{
let
path
=
"_rust_rocksdb_cftest"
;
// should be able to create column families
{
let
mut
db
=
RocksDB
::
open_default
(
path
)
.unwrap
();
let
opts
=
Options
::
new
();
match
db
.create_cf
(
"cf1"
,
&
opts
)
{
Ok
(
_
)
=>
println!
(
"cf1 created successfully"
),
Err
(
e
)
=>
{
panic!
(
"could not create column family: {}"
,
e
);
},
}
}
// should fail to open db without specifying same column families
{
match
RocksDB
::
open_default
(
path
)
{
Ok
(
_
)
=>
panic!
(
"should not have opened DB successfully without specifying column
families"
),
Err
(
e
)
=>
assert
!
(
e
.starts_with
(
"Invalid argument: You have to open all column families."
)),
}
}
// should properly open db when specyfing all column families
{
match
RocksDB
::
open_cf
(
&
Options
::
new
(),
path
,
&
[
"cf1"
])
{
Ok
(
_
)
=>
println!
(
"successfully opened db with column family"
),
Err
(
e
)
=>
panic!
(
"failed to open db with column family: {}"
,
e
),
}
}
// should be able to write, read, merge, batch, and iterate over a cf
{
}
// should b able to drop a cf
{
let
mut
db
=
RocksDB
::
open_cf
(
&
Options
::
new
(),
path
,
&
[
"cf1"
])
.unwrap
();
match
db
.drop_cf
(
"cf1"
)
{
Ok
(
_
)
=>
println!
(
"cf1 successfully dropped."
),
Err
(
e
)
=>
panic!
(
"failed to drop column family: {}"
,
e
),
}
}
assert
!
(
RocksDB
::
destroy
(
&
Options
::
new
(),
path
)
.is_ok
());
}
test/test_column_family.rs
View file @
9f55661e
...
...
@@ -52,6 +52,14 @@ pub fn test_column_family() {
{
}
// should b able to drop a cf
{
let
mut
db
=
RocksDB
::
open_cf
(
&
Options
::
new
(),
path
,
&
[
"cf1"
])
.unwrap
();
match
db
.drop_cf
(
"cf1"
)
{
Ok
(
_
)
=>
println!
(
"cf1 successfully dropped."
),
Err
(
e
)
=>
panic!
(
"failed to drop column family: {}"
,
e
),
}
}
assert
!
(
RocksDB
::
destroy
(
&
Options
::
new
(),
path
)
.is_ok
());
}
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