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
6d8620d1
Unverified
Commit
6d8620d1
authored
Nov 04, 2020
by
Xinye Tao
Committed by
GitHub
Nov 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option for max-background-flushes and max-background-compactions (#550) (#558)
Signed-off-by:
tabokie
<
xy.tao@outlook.com
>
parent
1c679f31
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
117 additions
and
1 deletion
+117
-1
aarch64-unknown-linux-gnu-bindings.rs
...ocksdb_sys/bindings/aarch64-unknown-linux-gnu-bindings.rs
+20
-0
x86_64-unknown-linux-gnu-bindings.rs
librocksdb_sys/bindings/x86_64-unknown-linux-gnu-bindings.rs
+20
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+19
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+9
-1
lib.rs
librocksdb_sys/src/lib.rs
+10
-0
rocksdb.rs
src/rocksdb.rs
+9
-0
rocksdb_options.rs
src/rocksdb_options.rs
+20
-0
test_rocksdb_options.rs
tests/cases/test_rocksdb_options.rs
+10
-0
No files found.
librocksdb_sys/bindings/aarch64-unknown-linux-gnu-bindings.rs
View file @
6d8620d1
...
@@ -2063,6 +2063,26 @@ extern "C" {
...
@@ -2063,6 +2063,26 @@ extern "C" {
pub
fn
crocksdb_options_get_max_background_jobs
(
arg1
:
*
const
crocksdb_options_t
)
pub
fn
crocksdb_options_get_max_background_jobs
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
->
libc
::
c_int
;
}
}
extern
"C"
{
pub
fn
crocksdb_options_set_max_background_compactions
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
libc
::
c_int
,
);
}
extern
"C"
{
pub
fn
crocksdb_options_get_max_background_compactions
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
}
extern
"C"
{
pub
fn
crocksdb_options_set_max_background_flushes
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
libc
::
c_int
,
);
}
extern
"C"
{
pub
fn
crocksdb_options_get_max_background_flushes
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
}
extern
"C"
{
extern
"C"
{
pub
fn
crocksdb_options_set_max_log_file_size
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
usize
);
pub
fn
crocksdb_options_set_max_log_file_size
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
usize
);
}
}
...
...
librocksdb_sys/bindings/x86_64-unknown-linux-gnu-bindings.rs
View file @
6d8620d1
...
@@ -2166,6 +2166,26 @@ extern "C" {
...
@@ -2166,6 +2166,26 @@ extern "C" {
pub
fn
crocksdb_options_get_max_background_jobs
(
arg1
:
*
const
crocksdb_options_t
)
pub
fn
crocksdb_options_get_max_background_jobs
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
->
libc
::
c_int
;
}
}
extern
"C"
{
pub
fn
crocksdb_options_set_max_background_compactions
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
libc
::
c_int
,
);
}
extern
"C"
{
pub
fn
crocksdb_options_get_max_background_compactions
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
}
extern
"C"
{
pub
fn
crocksdb_options_set_max_background_flushes
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
libc
::
c_int
,
);
}
extern
"C"
{
pub
fn
crocksdb_options_get_max_background_flushes
(
arg1
:
*
const
crocksdb_options_t
)
->
libc
::
c_int
;
}
extern
"C"
{
extern
"C"
{
pub
fn
crocksdb_options_set_max_log_file_size
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
usize
);
pub
fn
crocksdb_options_set_max_log_file_size
(
arg1
:
*
mut
crocksdb_options_t
,
arg2
:
usize
);
}
}
...
...
librocksdb_sys/crocksdb/c.cc
View file @
6d8620d1
...
@@ -2687,6 +2687,25 @@ int crocksdb_options_get_max_background_jobs(const crocksdb_options_t* opt) {
...
@@ -2687,6 +2687,25 @@ int crocksdb_options_get_max_background_jobs(const crocksdb_options_t* opt) {
return
opt
->
rep
.
max_background_jobs
;
return
opt
->
rep
.
max_background_jobs
;
}
}
void
crocksdb_options_set_max_background_compactions
(
crocksdb_options_t
*
opt
,
int
n
)
{
opt
->
rep
.
max_background_compactions
=
n
;
}
int
crocksdb_options_get_max_background_compactions
(
const
crocksdb_options_t
*
opt
)
{
return
opt
->
rep
.
max_background_compactions
;
}
void
crocksdb_options_set_max_background_flushes
(
crocksdb_options_t
*
opt
,
int
n
)
{
opt
->
rep
.
max_background_flushes
=
n
;
}
int
crocksdb_options_get_max_background_flushes
(
const
crocksdb_options_t
*
opt
)
{
return
opt
->
rep
.
max_background_flushes
;
}
void
crocksdb_options_set_max_log_file_size
(
crocksdb_options_t
*
opt
,
size_t
v
)
{
void
crocksdb_options_set_max_log_file_size
(
crocksdb_options_t
*
opt
,
size_t
v
)
{
opt
->
rep
.
max_log_file_size
=
v
;
opt
->
rep
.
max_log_file_size
=
v
;
}
}
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
6d8620d1
...
@@ -994,7 +994,15 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_background_jobs(
...
@@ -994,7 +994,15 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_max_background_jobs(
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_options_get_max_background_jobs
(
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_options_get_max_background_jobs
(
const
crocksdb_options_t
*
);
const
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_max_log_file_size
(
crocksdb_options_t
*
,
size_t
);
crocksdb_options_set_max_background_compactions
(
crocksdb_options_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_options_get_max_background_compactions
(
const
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_max_background_flushes
(
crocksdb_options_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_options_get_max_background_flushes
(
const
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_max_log_file_size
(
crocksdb_options_t
*
,
size_t
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_log_file_time_to_roll
(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_log_file_time_to_roll
(
crocksdb_options_t
*
,
size_t
);
crocksdb_options_t
*
,
size_t
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_keep_log_file_num
(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_keep_log_file_num
(
...
...
librocksdb_sys/src/lib.rs
View file @
6d8620d1
...
@@ -673,6 +673,16 @@ extern "C" {
...
@@ -673,6 +673,16 @@ extern "C" {
pub
fn
crocksdb_set_bottommost_compression
(
options
:
*
mut
Options
,
c
:
DBCompressionType
);
pub
fn
crocksdb_set_bottommost_compression
(
options
:
*
mut
Options
,
c
:
DBCompressionType
);
pub
fn
crocksdb_options_set_max_background_jobs
(
options
:
*
mut
Options
,
max_bg_jobs
:
c_int
);
pub
fn
crocksdb_options_set_max_background_jobs
(
options
:
*
mut
Options
,
max_bg_jobs
:
c_int
);
pub
fn
crocksdb_options_get_max_background_jobs
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_get_max_background_jobs
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_set_max_background_compactions
(
options
:
*
mut
Options
,
max_bg_compactions
:
c_int
,
);
pub
fn
crocksdb_options_get_max_background_compactions
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_set_max_background_flushes
(
options
:
*
mut
Options
,
max_bg_flushes
:
c_int
,
);
pub
fn
crocksdb_options_get_max_background_flushes
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_set_disable_auto_compactions
(
options
:
*
mut
Options
,
v
:
c_int
);
pub
fn
crocksdb_options_set_disable_auto_compactions
(
options
:
*
mut
Options
,
v
:
c_int
);
pub
fn
crocksdb_options_get_disable_auto_compactions
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_get_disable_auto_compactions
(
options
:
*
const
Options
)
->
c_int
;
pub
fn
crocksdb_options_set_report_bg_io_stats
(
options
:
*
mut
Options
,
v
:
c_int
);
pub
fn
crocksdb_options_set_report_bg_io_stats
(
options
:
*
mut
Options
,
v
:
c_int
);
...
...
src/rocksdb.rs
View file @
6d8620d1
...
@@ -3329,6 +3329,15 @@ mod test {
...
@@ -3329,6 +3329,15 @@ mod test {
let
db_opts
=
db
.get_db_options
();
let
db_opts
=
db
.get_db_options
();
assert_eq!
(
db_opts
.get_max_background_jobs
(),
8
);
assert_eq!
(
db_opts
.get_max_background_jobs
(),
8
);
db
.set_db_options
(
&
[(
"max_background_compactions"
,
"6"
)])
.unwrap
();
db
.set_db_options
(
&
[(
"max_background_flushes"
,
"3"
)])
.unwrap
();
let
db_opts
=
db
.get_db_options
();
assert_eq!
(
db_opts
.get_max_background_jobs
(),
8
);
assert_eq!
(
db_opts
.get_max_background_compactions
(),
6
);
assert_eq!
(
db_opts
.get_max_background_flushes
(),
3
);
let
cf_opts
=
db
.get_options_cf
(
cf
);
let
cf_opts
=
db
.get_options_cf
(
cf
);
assert_eq!
(
cf_opts
.get_disable_auto_compactions
(),
false
);
assert_eq!
(
cf_opts
.get_disable_auto_compactions
(),
false
);
db
.set_options_cf
(
cf
,
&
[(
"disable_auto_compactions"
,
"true"
)])
db
.set_options_cf
(
cf
,
&
[(
"disable_auto_compactions"
,
"true"
)])
...
...
src/rocksdb_options.rs
View file @
6d8620d1
...
@@ -794,6 +794,26 @@ impl DBOptions {
...
@@ -794,6 +794,26 @@ impl DBOptions {
unsafe
{
crocksdb_ffi
::
crocksdb_options_get_max_background_jobs
(
self
.inner
)
as
i32
}
unsafe
{
crocksdb_ffi
::
crocksdb_options_get_max_background_jobs
(
self
.inner
)
as
i32
}
}
}
pub
fn
set_max_background_compactions
(
&
mut
self
,
n
:
c_int
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_max_background_compactions
(
self
.inner
,
n
);
}
}
pub
fn
get_max_background_compactions
(
&
self
)
->
i32
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_get_max_background_compactions
(
self
.inner
)
as
i32
}
}
pub
fn
set_max_background_flushes
(
&
mut
self
,
n
:
c_int
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_max_background_flushes
(
self
.inner
,
n
);
}
}
pub
fn
get_max_background_flushes
(
&
self
)
->
i32
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_get_max_background_flushes
(
self
.inner
)
as
i32
}
}
pub
fn
set_max_subcompactions
(
&
mut
self
,
n
:
u32
)
{
pub
fn
set_max_subcompactions
(
&
mut
self
,
n
:
u32
)
{
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_max_subcompactions
(
self
.inner
,
n
);
crocksdb_ffi
::
crocksdb_options_set_max_subcompactions
(
self
.inner
,
n
);
...
...
tests/cases/test_rocksdb_options.rs
View file @
6d8620d1
...
@@ -565,6 +565,16 @@ fn test_set_max_background_jobs() {
...
@@ -565,6 +565,16 @@ fn test_set_max_background_jobs() {
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
}
}
#[test]
fn
test_set_max_background_compactions_and_flushes
()
{
let
path
=
tempdir_with_prefix
(
"_rust_rocksdb_max_background_compactions_and_flushes"
);
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
opts
.set_max_background_compactions
(
4
);
opts
.set_max_background_flushes
(
1
);
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
}
#[test]
#[test]
fn
test_set_compaction_pri
()
{
fn
test_set_compaction_pri
()
{
let
path
=
tempdir_with_prefix
(
"_rust_rocksdb_compaction_pri"
);
let
path
=
tempdir_with_prefix
(
"_rust_rocksdb_compaction_pri"
);
...
...
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