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
49238c5d
Commit
49238c5d
authored
Aug 31, 2017
by
Shuai Li
Committed by
GitHub
Aug 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rocksdb options manual_wal_flush support (#123)
parent
a2da29b1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
0 deletions
+58
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+11
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+5
-0
lib.rs
librocksdb_sys/src/lib.rs
+2
-0
rocksdb.rs
src/rocksdb.rs
+9
-0
rocksdb_options.rs
src/rocksdb_options.rs
+6
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+25
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
49238c5d
...
...
@@ -1109,6 +1109,13 @@ void crocksdb_flush_cf(
SaveError
(
errptr
,
db
->
rep
->
Flush
(
options
->
rep
,
column_family
->
rep
));
}
void
crocksdb_flush_wal
(
crocksdb_t
*
db
,
unsigned
char
sync
,
char
**
errptr
)
{
SaveError
(
errptr
,
db
->
rep
->
FlushWAL
(
sync
));
}
void
crocksdb_sync_wal
(
crocksdb_t
*
db
,
char
**
errptr
)
{
...
...
@@ -2133,6 +2140,10 @@ void crocksdb_options_set_allow_concurrent_memtable_write(crocksdb_options_t* op
opt
->
rep
.
allow_concurrent_memtable_write
=
v
;
}
void
crocksdb_options_set_manual_wal_flush
(
crocksdb_options_t
*
opt
,
unsigned
char
v
)
{
opt
->
rep
.
manual_wal_flush
=
v
;
}
void
crocksdb_options_set_enable_write_thread_adaptive_yield
(
crocksdb_options_t
*
opt
,
unsigned
char
v
)
{
opt
->
rep
.
enable_write_thread_adaptive_yield
=
v
;
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
49238c5d
...
...
@@ -415,6 +415,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_flush_cf(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
column_family
,
const
crocksdb_flushoptions_t
*
options
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_flush_wal
(
crocksdb_t
*
db
,
unsigned
char
sync
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_sync_wal
(
crocksdb_t
*
db
,
char
**
errptr
);
...
...
@@ -880,6 +883,8 @@ crocksdb_options_set_enable_pipelined_write(crocksdb_options_t *,
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_allow_concurrent_memtable_write
(
crocksdb_options_t
*
,
unsigned
char
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_manual_wal_flush
(
crocksdb_options_t
*
,
unsigned
char
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_enable_write_thread_adaptive_yield
(
crocksdb_options_t
*
,
unsigned
char
);
...
...
librocksdb_sys/src/lib.rs
View file @
49238c5d
...
...
@@ -357,6 +357,7 @@ extern "C" {
pub
fn
crocksdb_options_set_bytes_per_sync
(
options
:
*
mut
Options
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_enable_pipelined_write
(
options
:
*
mut
Options
,
v
:
bool
);
pub
fn
crocksdb_options_set_allow_concurrent_memtable_write
(
options
:
*
mut
Options
,
v
:
bool
);
pub
fn
crocksdb_options_set_manual_wal_flush
(
options
:
*
mut
Options
,
v
:
bool
);
pub
fn
crocksdb_options_optimize_for_point_lookup
(
options
:
*
mut
Options
,
block_cache_size_mb
:
u64
,
...
...
@@ -848,6 +849,7 @@ extern "C" {
options
:
*
const
DBFlushOptions
,
err
:
*
mut
*
mut
c_char
,
);
pub
fn
crocksdb_flush_wal
(
db
:
*
mut
DBInstance
,
sync
:
bool
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_sync_wal
(
db
:
*
mut
DBInstance
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_approximate_sizes
(
...
...
src/rocksdb.rs
View file @
49238c5d
...
...
@@ -810,6 +810,15 @@ impl DB {
}
}
/// Flush the WAL memory buffer to the file. If sync is true, it calls SyncWAL
/// afterwards.
pub
fn
flush_wal
(
&
self
,
sync
:
bool
)
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_flush_wal
(
self
.inner
,
sync
));
Ok
(())
}
}
/// Sync the wal. Note that Write() followed by SyncWAL() is not exactly the
/// same as Write() with sync=true: in the latter case the changes won't be
/// visible until the sync is done.
...
...
src/rocksdb_options.rs
View file @
49238c5d
...
...
@@ -724,6 +724,12 @@ impl DBOptions {
}
}
pub
fn
manual_wal_flush
(
&
self
,
v
:
bool
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_manual_wal_flush
(
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
();
...
...
tests/test_rocksdb_options.rs
View file @
49238c5d
...
...
@@ -169,6 +169,19 @@ fn test_set_wal_opt() {
drop
(
db
);
}
#[cfg(not(windows))]
#[test]
fn
test_flush_wal
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_test_flush_wal"
)
.expect
(
""
);
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
opts
.manual_wal_flush
(
true
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
db
.put
(
b
"key"
,
b
"value"
)
.unwrap
();
db
.flush_wal
(
false
)
.unwrap
();
drop
(
db
);
}
#[cfg(not(windows))]
#[test]
fn
test_sync_wal
()
{
...
...
@@ -411,6 +424,18 @@ fn test_allow_concurrent_memtable_write() {
}
}
#[test]
fn
test_manual_wal_flush
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_manual_wal_flush"
)
.expect
(
""
);
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
opts
.manual_wal_flush
(
true
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
for
i
in
0
..
200
{
db
.put
(
format!
(
"k_{}"
,
i
)
.as_bytes
(),
b
"v"
)
.unwrap
();
}
}
#[test]
fn
test_enable_pipelined_write
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_enable_pipelined_write"
)
.expect
(
""
);
...
...
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