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
98ab8149
Commit
98ab8149
authored
Jul 28, 2017
by
follitude
Committed by
siddontang
Jul 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support db_paths (#105)
parent
06ad3fc1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
0 deletions
+55
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+13
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+4
-0
lib.rs
librocksdb_sys/src/lib.rs
+5
-0
rocksdb_options.rs
src/rocksdb_options.rs
+23
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+10
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
98ab8149
...
...
@@ -98,6 +98,7 @@ using rocksdb::TablePropertiesCollection;
using
rocksdb
::
TablePropertiesCollector
;
using
rocksdb
::
TablePropertiesCollectorFactory
;
using
rocksdb
::
KeyVersion
;
using
rocksdb
::
DbPath
;
using
std
::
shared_ptr
;
...
...
@@ -1992,6 +1993,18 @@ void crocksdb_options_set_use_fsync(
opt
->
rep
.
use_fsync
=
use_fsync
;
}
void
crocksdb_options_set_db_paths
(
crocksdb_options_t
*
opt
,
const
char
*
const
*
dbpath_list
,
const
size_t
*
path_lens
,
const
uint64_t
*
target_size
,
int
num_paths
)
{
std
::
vector
<
DbPath
>
db_paths
;
for
(
int
i
=
0
;
i
<
num_paths
;
++
i
)
{
db_paths
.
emplace_back
(
DbPath
(
std
::
string
(
dbpath_list
[
i
],
path_lens
[
i
]),
target_size
[
i
]));
}
opt
->
rep
.
db_paths
=
db_paths
;
}
void
crocksdb_options_set_db_log_dir
(
crocksdb_options_t
*
opt
,
const
char
*
db_log_dir
)
{
opt
->
rep
.
db_log_dir
=
db_log_dir
;
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
98ab8149
...
...
@@ -822,6 +822,10 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_arena_block_size(
crocksdb_options_t
*
,
size_t
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_use_fsync
(
crocksdb_options_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_db_paths
(
crocksdb_options_t
*
,
const
char
*
const
*
,
const
size_t
*
,
const
uint64_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_db_log_dir
(
crocksdb_options_t
*
,
const
char
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_wal_dir
(
crocksdb_options_t
*
,
...
...
librocksdb_sys/src/lib.rs
View file @
98ab8149
...
...
@@ -385,6 +385,11 @@ extern "C" {
pub
fn
crocksdb_options_set_hard_pending_compaction_bytes_limit
(
options
:
*
mut
Options
,
v
:
u64
);
pub
fn
crocksdb_options_set_compaction_priority
(
options
:
*
mut
Options
,
v
:
CompactionPriority
);
pub
fn
crocksdb_options_set_db_paths
(
options
:
*
mut
Options
,
db_paths
:
*
const
*
const
c_char
,
path_lens
:
*
const
usize
,
target_size
:
*
const
u64
,
num_paths
:
c_int
);
pub
fn
crocksdb_filterpolicy_create_bloom_full
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
crocksdb_filterpolicy_create_bloom
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
crocksdb_open
(
options
:
*
mut
Options
,
...
...
src/rocksdb_options.rs
View file @
98ab8149
...
...
@@ -27,6 +27,7 @@ use merge_operator::MergeFn;
use
slice_transform
::{
SliceTransform
,
new_slice_transform
};
use
std
::
ffi
::{
CStr
,
CString
};
use
std
::
mem
;
use
std
::
path
::
Path
;
use
table_properties_collector_factory
::{
TablePropertiesCollectorFactory
,
new_table_properties_collector_factory
};
...
...
@@ -614,6 +615,28 @@ impl DBOptions {
crocksdb_ffi
::
crocksdb_options_set_allow_concurrent_memtable_write
(
self
.inner
,
v
);
}
}
/// the second parameter is a slice which contains tuples (path, target_size).
pub
fn
set_db_paths
<
T
:
AsRef
<
Path
>>
(
&
self
,
val
:
&
[(
T
,
u64
)])
{
let
num_paths
=
val
.len
();
let
mut
cpaths
=
Vec
::
with_capacity
(
num_paths
);
let
mut
cpath_lens
=
Vec
::
with_capacity
(
num_paths
);
let
mut
sizes
=
Vec
::
with_capacity
(
num_paths
);
for
dbpath
in
val
{
let
dbpath_str
=
dbpath
.
0
.as_ref
()
.to_str
();
cpaths
.push
(
dbpath_str
.unwrap
()
.as_ptr
()
as
_
);
cpath_lens
.push
(
dbpath_str
.unwrap
()
.len
());
sizes
.push
(
dbpath
.
1
);
}
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_db_paths
(
self
.inner
,
cpaths
.as_ptr
(),
cpath_lens
.as_ptr
(),
sizes
.as_ptr
(),
num_paths
as
c_int
);
}
}
}
pub
struct
ColumnFamilyOptions
{
...
...
tests/test_rocksdb_options.rs
View file @
98ab8149
...
...
@@ -452,3 +452,13 @@ fn test_clone_options() {
let
cf_opts2
=
cf_opts
.clone
();
assert_eq!
(
cf_opts
.get_compression
(),
cf_opts2
.get_compression
());
}
#[test]
fn
test_db_paths
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_db_paths"
)
.expect
(
""
);
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
let
tmp_path
=
TempDir
::
new
(
"_rust_rocksdb_test_db_path"
)
.expect
(
""
);
opts
.set_db_paths
(
&
[(
tmp_path
.path
(),
1073741824
as
u64
)]);
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.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