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
73a86f71
Commit
73a86f71
authored
Apr 12, 2017
by
zhangjinpeng1987
Committed by
GitHub
Apr 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flush api for specified cf (#38)
parent
d9a1109e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
c.cc
librocksdb_sys/crocksdb/c.cc
+8
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+4
-0
lib.rs
librocksdb_sys/src/lib.rs
+4
-0
rocksdb.rs
src/rocksdb.rs
+30
-3
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
73a86f71
...
...
@@ -1042,6 +1042,14 @@ void crocksdb_flush(
SaveError
(
errptr
,
db
->
rep
->
Flush
(
options
->
rep
));
}
void
crocksdb_flush_cf
(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
column_family
,
const
crocksdb_flushoptions_t
*
options
,
char
**
errptr
)
{
SaveError
(
errptr
,
db
->
rep
->
Flush
(
options
->
rep
,
column_family
->
rep
));
}
void
crocksdb_disable_file_deletions
(
crocksdb_t
*
db
,
char
**
errptr
)
{
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
73a86f71
...
...
@@ -356,6 +356,10 @@ extern C_ROCKSDB_LIBRARY_API const crocksdb_livefiles_t* crocksdb_livefiles(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_flush
(
crocksdb_t
*
db
,
const
crocksdb_flushoptions_t
*
options
,
char
**
errptr
);
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_disable_file_deletions
(
crocksdb_t
*
db
,
char
**
errptr
);
...
...
librocksdb_sys/src/lib.rs
View file @
73a86f71
...
...
@@ -574,6 +574,10 @@ extern "C" {
pub
fn
crocksdb_flush
(
db
:
*
mut
DBInstance
,
options
:
*
const
DBFlushOptions
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_flush_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
options
:
*
const
DBFlushOptions
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_approximate_sizes
(
db
:
*
mut
DBInstance
,
num_ranges
:
c_int
,
...
...
src/rocksdb.rs
View file @
73a86f71
...
...
@@ -717,9 +717,6 @@ impl DB {
}
/// Flush all memtable data.
///
/// Due to lack of abi, only default cf is supported.
///
/// If sync, the flush will wait until the flush is done.
pub
fn
flush
(
&
self
,
sync
:
bool
)
->
Result
<
(),
String
>
{
unsafe
{
...
...
@@ -730,6 +727,17 @@ impl DB {
}
}
/// Flush all memtable data for specified cf.
/// If sync, the flush will wait until the flush is done.
pub
fn
flush_cf
(
&
self
,
cf
:
&
CFHandle
,
sync
:
bool
)
->
Result
<
(),
String
>
{
unsafe
{
let
mut
opts
=
FlushOptions
::
new
();
opts
.set_wait
(
sync
);
ffi_try!
(
crocksdb_flush_cf
(
self
.inner
,
cf
.inner
,
opts
.inner
));
Ok
(())
}
}
/// Return the approximate file system space used by keys in each ranges.
///
/// Note that the returned sizes measure file system space usage, so
...
...
@@ -1772,4 +1780,23 @@ mod test {
let
cf_handle
=
db
.cf_handle
(
"default"
)
.unwrap
();
assert
!
(
db
.get_block_cache_usage_cf
(
cf_handle
)
>
0
);
}
#[test]
fn
flush_cf
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_flush_cf"
)
.expect
(
""
);
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
let
mut
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
opts
=
Options
::
new
();
db
.create_cf
(
"cf"
,
&
opts
)
.unwrap
();
let
cf_handle
=
db
.cf_handle
(
"cf"
)
.unwrap
();
for
i
in
0
..
200
{
db
.put_cf
(
cf_handle
,
format!
(
"k_{}"
,
i
)
.as_bytes
(),
b
"v"
)
.unwrap
();
}
db
.flush_cf
(
cf_handle
,
true
)
.unwrap
();
let
total_sst_files_size
=
db
.get_property_int_cf
(
cf_handle
,
"rocksdb.total-sst-files-size"
)
.unwrap
();
assert
!
(
total_sst_files_size
>
0
);
}
}
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