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
229732cb
Commit
229732cb
authored
Oct 10, 2017
by
Jay
Committed by
GitHub
Oct 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use cf descriptor to create cf (#146)
parent
9aa42565
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
27 deletions
+20
-27
rocksdb.rs
src/rocksdb.rs
+11
-12
test_column_family.rs
tests/test_column_family.rs
+1
-2
test_delete_range.rs
tests/test_delete_range.rs
+1
-2
test_ingest_external_file.rs
tests/test_ingest_external_file.rs
+4
-7
test_read_only.rs
tests/test_read_only.rs
+3
-4
No files found.
src/rocksdb.rs
View file @
229732cb
...
...
@@ -615,12 +615,12 @@ impl DB {
self
.get_cf_opt
(
cf
,
key
,
&
ReadOptions
::
new
())
}
pub
fn
create_cf
(
&
mut
self
,
name
:
&
str
,
cf_opts
:
ColumnFamilyOptions
,
)
->
Result
<&
CFHandle
,
String
>
{
let
cname
=
match
CString
::
new
(
name
.as_bytes
())
{
pub
fn
create_cf
<
'a
,
T
>
(
&
mut
self
,
cfd
:
T
)
->
Result
<&
CFHandle
,
String
>
where
T
:
Into
<
ColumnFamilyDescriptor
<
'a
>>
,
{
let
cfd
=
cfd
.into
();
let
cname
=
match
CString
::
new
(
cfd
.
name
.as_bytes
())
{
Ok
(
c
)
=>
c
,
Err
(
_
)
=>
{
return
Err
(
...
...
@@ -632,12 +632,12 @@ impl DB {
unsafe
{
let
cf_handler
=
ffi_try!
(
crocksdb_create_column_family
(
self
.inner
,
cf
_opt
s
.inner
,
cf
d
.option
s.inner
,
cname_ptr
));
let
handle
=
CFHandle
{
inner
:
cf_handler
};
self
._cf_opts
.push
(
cf
_opt
s
);
Ok
(
match
self
.cfs
.entry
(
name
.to_owned
())
{
self
._cf_opts
.push
(
cf
d
.option
s
);
Ok
(
match
self
.cfs
.entry
(
cfd
.
name
.to_owned
())
{
Entry
::
Occupied
(
mut
e
)
=>
{
e
.insert
(
handle
);
e
.into_mut
()
...
...
@@ -1972,7 +1972,7 @@ mod test {
if
*
cf
==
"default"
{
continue
;
}
db
.create_cf
(
cf
,
cf_opts
)
.unwrap
();
db
.create_cf
(
(
*
cf
,
cf_opts
)
)
.unwrap
();
}
}
let
opts_list_cfs
=
DBOptions
::
new
();
...
...
@@ -2156,8 +2156,7 @@ mod test {
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
let
mut
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
cf_opts
=
ColumnFamilyOptions
::
new
();
db
.create_cf
(
"cf"
,
cf_opts
)
.unwrap
();
db
.create_cf
(
"cf"
)
.unwrap
();
let
cf_handle
=
db
.cf_handle
(
"cf"
)
.unwrap
();
for
i
in
0
..
200
{
...
...
tests/test_column_family.rs
View file @
229732cb
...
...
@@ -28,8 +28,7 @@ pub fn test_column_family() {
let
mut
cf_opts
=
ColumnFamilyOptions
::
new
();
cf_opts
.add_merge_operator
(
"test operator"
,
test_provided_merge
);
let
mut
db
=
DB
::
open_cf
(
opts
,
path_str
,
vec!
[(
"default"
,
cf_opts
)])
.unwrap
();
let
cf_opts
=
ColumnFamilyOptions
::
new
();
match
db
.create_cf
(
"cf1"
,
cf_opts
)
{
match
db
.create_cf
(
"cf1"
)
{
Ok
(
_
)
=>
println!
(
"cf1 created successfully"
),
Err
(
e
)
=>
{
panic!
(
"could not create column family: {}"
,
e
);
...
...
tests/test_delete_range.rs
View file @
229732cb
...
...
@@ -1460,8 +1460,7 @@ fn test_delete_range_ingest_file() {
],
);
let
cf_opts
=
ColumnFamilyOptions
::
new
();
db
.create_cf
(
"cf1"
,
cf_opts
)
.unwrap
();
db
.create_cf
(
"cf1"
)
.unwrap
();
let
handle
=
db
.cf_handle
(
"cf1"
)
.unwrap
();
gen_sst
(
ColumnFamilyOptions
::
new
(),
None
,
test_sstfile_str
);
...
...
tests/test_ingest_external_file.rs
View file @
229732cb
...
...
@@ -97,8 +97,7 @@ fn concat_merge(_: &[u8], existing_val: Option<&[u8]>, operands: &mut MergeOpera
fn
test_ingest_external_file
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_ingest_sst"
)
.expect
(
""
);
let
mut
db
=
create_default_database
(
&
path
);
let
cf_opts
=
ColumnFamilyOptions
::
new
();
db
.create_cf
(
"cf1"
,
cf_opts
)
.unwrap
();
db
.create_cf
(
"cf1"
)
.unwrap
();
let
handle
=
db
.cf_handle
(
"cf1"
)
.unwrap
();
let
gen_path
=
TempDir
::
new
(
"_rust_rocksdb_ingest_sst_gen"
)
.expect
(
""
);
let
test_sstfile
=
gen_path
.path
()
.join
(
"test_sst_file"
);
...
...
@@ -217,7 +216,7 @@ fn test_ingest_external_file_new_cf() {
let
test_sstfile_str
=
test_sstfile
.to_str
()
.unwrap
();
let
mut
cf_opts
=
ColumnFamilyOptions
::
new
();
cf_opts
.add_merge_operator
(
"merge operator"
,
concat_merge
);
db
.create_cf
(
"cf1"
,
cf_opts
)
.unwrap
();
db
.create_cf
(
(
"cf1"
,
cf_opts
)
)
.unwrap
();
let
handle
=
db
.cf_handle
(
"cf1"
)
.unwrap
();
let
mut
ingest_opt
=
IngestExternalFileOptions
::
new
();
...
...
@@ -295,8 +294,7 @@ fn create_default_database(path: &TempDir) -> DB {
fn
create_cfs
(
db
:
&
mut
DB
,
cfs
:
&
[
&
str
])
{
for
cf
in
cfs
{
if
*
cf
!=
"default"
{
let
cf_opts
=
ColumnFamilyOptions
::
new
();
db
.create_cf
(
cf
,
cf_opts
)
.unwrap
();
db
.create_cf
(
*
cf
)
.unwrap
();
}
}
}
...
...
@@ -323,8 +321,7 @@ fn test_ingest_simulate_real_world() {
let
mut
db2
=
create_default_database
(
&
path2
);
for
cf
in
&
ALL_CFS
{
if
*
cf
!=
"default"
{
let
cf_opts
=
ColumnFamilyOptions
::
new
();
db2
.create_cf
(
cf
,
cf_opts
)
.unwrap
();
db2
.create_cf
(
*
cf
)
.unwrap
();
}
}
for
cf
in
&
ALL_CFS
{
...
...
tests/test_read_only.rs
View file @
229732cb
use
rocksdb
::{
ColumnFamilyOptions
,
DBOptions
,
Writable
,
DB
};
use
rocksdb
::{
DBOptions
,
Writable
,
DB
};
use
tempdir
::
TempDir
;
macro_rules!
check_kv
{
...
...
@@ -53,9 +53,8 @@ fn test_open_cf_for_read_only() {
{
let
mut
rw
=
DB
::
open_default
(
path
)
.unwrap
();
let
cf_opts
=
ColumnFamilyOptions
::
new
();
let
_
=
rw
.create_cf
(
"cf1"
,
cf_opts
.clone
())
.unwrap
();
let
_
=
rw
.create_cf
(
"cf2"
,
cf_opts
.clone
())
.unwrap
();
let
_
=
rw
.create_cf
(
"cf1"
)
.unwrap
();
let
_
=
rw
.create_cf
(
"cf2"
)
.unwrap
();
}
{
...
...
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