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
a28ba922
Commit
a28ba922
authored
Dec 06, 2016
by
Neil Shen
Committed by
GitHub
Dec 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rocksdb log dir option (#61)
parent
ba914b8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
lib.rs
librocksdb_sys/src/lib.rs
+1
-0
rocksdb.rs
src/rocksdb.rs
+28
-0
rocksdb_options.rs
src/rocksdb_options.rs
+7
-0
No files found.
librocksdb_sys/src/lib.rs
View file @
a28ba922
...
@@ -189,6 +189,7 @@ extern "C" {
...
@@ -189,6 +189,7 @@ extern "C" {
pub
fn
rocksdb_options_statistics_get_string
(
options
:
*
mut
DBOptions
)
->
*
const
c_char
;
pub
fn
rocksdb_options_statistics_get_string
(
options
:
*
mut
DBOptions
)
->
*
const
c_char
;
pub
fn
rocksdb_options_set_stats_dump_period_sec
(
options
:
*
mut
DBOptions
,
v
:
usize
);
pub
fn
rocksdb_options_set_stats_dump_period_sec
(
options
:
*
mut
DBOptions
,
v
:
usize
);
pub
fn
rocksdb_options_set_num_levels
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
pub
fn
rocksdb_options_set_num_levels
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
pub
fn
rocksdb_options_set_db_log_dir
(
options
:
*
mut
DBOptions
,
path
:
*
const
c_char
);
pub
fn
rocksdb_filterpolicy_create_bloom_full
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
rocksdb_filterpolicy_create_bloom_full
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
rocksdb_filterpolicy_create_bloom
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
rocksdb_filterpolicy_create_bloom
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
rocksdb_open
(
options
:
*
mut
DBOptions
,
pub
fn
rocksdb_open
(
options
:
*
mut
DBOptions
,
...
...
src/rocksdb.rs
View file @
a28ba922
...
@@ -1043,6 +1043,8 @@ impl Drop for BackupEngine {
...
@@ -1043,6 +1043,8 @@ impl Drop for BackupEngine {
#[cfg(test)]
#[cfg(test)]
mod
test
{
mod
test
{
use
rocksdb_options
::
*
;
use
rocksdb_options
::
*
;
use
std
::
fs
;
use
std
::
path
::
Path
;
use
std
::
str
;
use
std
::
str
;
use
super
::
*
;
use
super
::
*
;
use
tempdir
::
TempDir
;
use
tempdir
::
TempDir
;
...
@@ -1218,6 +1220,32 @@ mod test {
...
@@ -1218,6 +1220,32 @@ mod test {
assert
!
(
r
.unwrap
()
.unwrap
()
.to_utf8
()
.unwrap
()
==
str
::
from_utf8
(
value
)
.unwrap
());
assert
!
(
r
.unwrap
()
.unwrap
()
.to_utf8
()
.unwrap
()
==
str
::
from_utf8
(
value
)
.unwrap
());
}
}
}
}
#[test]
fn
log_dir_test
()
{
let
db_dir
=
TempDir
::
new
(
"_rust_rocksdb_logdirtest"
)
.unwrap
();
let
db_path
=
db_dir
.path
()
.to_str
()
.unwrap
();
let
log_path
=
format!
(
"{}"
,
Path
::
new
(
&
db_path
)
.join
(
"log_path"
)
.display
());
fs
::
create_dir_all
(
&
log_path
)
.unwrap
();
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.set_db_log_dir
(
&
log_path
);
DB
::
open
(
opts
,
db_path
)
.unwrap
();
// Check LOG file.
let
mut
read_dir
=
fs
::
read_dir
(
&
log_path
)
.unwrap
();
let
entry
=
read_dir
.next
()
.unwrap
()
.unwrap
();
let
name
=
entry
.file_name
();
name
.to_str
()
.unwrap
()
.find
(
"LOG"
)
.unwrap
();
for
entry
in
fs
::
read_dir
(
&
db_path
)
.unwrap
()
{
let
entry
=
entry
.unwrap
();
let
name
=
entry
.file_name
();
assert
!
(
name
.to_str
()
.unwrap
()
.find
(
"LOG"
)
.is_none
());
}
}
}
}
#[test]
#[test]
...
...
src/rocksdb_options.rs
View file @
a28ba922
...
@@ -549,6 +549,13 @@ impl Options {
...
@@ -549,6 +549,13 @@ impl Options {
rocksdb_ffi
::
rocksdb_options_set_num_levels
(
self
.inner
,
n
);
rocksdb_ffi
::
rocksdb_options_set_num_levels
(
self
.inner
,
n
);
}
}
}
}
pub
fn
set_db_log_dir
(
&
mut
self
,
path
:
&
str
)
{
let
path
=
CString
::
new
(
path
.as_bytes
())
.unwrap
();
unsafe
{
rocksdb_ffi
::
rocksdb_options_set_db_log_dir
(
self
.inner
,
path
.as_ptr
());
}
}
}
}
pub
struct
FlushOptions
{
pub
struct
FlushOptions
{
...
...
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