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
e0de1aad
Commit
e0de1aad
authored
Jun 02, 2017
by
zhangjinpeng1987
Committed by
ShuYu Wang
Jun 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export abi to set compaction priority (#63)
parent
fcf0dfd6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
2 deletions
+53
-2
c.cc
librocksdb_sys/crocksdb/c.cc
+4
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+9
-0
lib.rs
librocksdb_sys/src/lib.rs
+22
-0
lib.rs
src/lib.rs
+1
-1
rocksdb_options.rs
src/rocksdb_options.rs
+6
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+11
-1
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
e0de1aad
...
...
@@ -2089,6 +2089,10 @@ void crocksdb_options_set_fifo_compaction_options(
opt
->
rep
.
compaction_options_fifo
=
fifo
->
rep
;
}
void
crocksdb_options_set_compaction_priority
(
crocksdb_options_t
*
opt
,
unsigned
char
priority
)
{
opt
->
rep
.
compaction_pri
=
static_cast
<
rocksdb
::
CompactionPri
>
(
priority
);
}
char
*
crocksdb_options_statistics_get_string
(
crocksdb_options_t
*
opt
)
{
rocksdb
::
Statistics
*
statistics
=
opt
->
rep
.
statistics
.
get
();
if
(
statistics
)
{
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
e0de1aad
...
...
@@ -834,6 +834,15 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_fifo_compaction_options(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_ratelimiter
(
crocksdb_options_t
*
opt
,
crocksdb_ratelimiter_t
*
limiter
);
enum
{
compaction_by_compensated_size
=
0
,
compaction_by_oldest_largestseq_first
=
1
,
compaction_by_oldest_smallest_seq_first
=
2
,
compaction_by_min_overlapping_ratio
=
3
,
};
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_compaction_priority
(
crocksdb_options_t
*
,
unsigned
char
);
/* RateLimiter */
extern
C_ROCKSDB_LIBRARY_API
crocksdb_ratelimiter_t
*
crocksdb_ratelimiter_create
(
int64_t
rate_bytes_per_sec
,
int64_t
refill_period_us
,
int32_t
fairness
);
...
...
librocksdb_sys/src/lib.rs
View file @
e0de1aad
...
...
@@ -89,6 +89,26 @@ pub enum DBRecoveryMode {
SkipAnyCorruptedRecords
=
3
,
}
#[derive(Copy,
Clone,
PartialEq)]
#[repr(C)]
pub
enum
CompactionPriority
{
// In Level-based compaction, it Determines which file from a level to be
// picked to merge to the next level. We suggest people try
// kMinOverlappingRatio first when you tune your database.
ByCompensatedSize
=
0
,
// First compact files whose data's latest update time is oldest.
// Try this if you only update some hot keys in small ranges.
OldestLargestSeqFirst
=
1
,
// First compact files whose range hasn't been compacted to the next level
// for the longest. If your updates are random across the key space,
// write amplification is slightly better with this option.
OldestSmallestSeqFirst
=
2
,
// First compact files whose ratio between overlapping size in next level
// and its size is the smallest. It in many cases can optimize write
// amplification.
MinOverlappingRatio
=
3
,
}
#[derive(Copy,
Clone)]
#[repr(C)]
pub
enum
DBStatisticsTickerType
{
...
...
@@ -315,6 +335,8 @@ extern "C" {
v
:
u64
);
pub
fn
crocksdb_options_set_hard_pending_compaction_bytes_limit
(
options
:
*
mut
DBOptions
,
v
:
u64
);
pub
fn
crocksdb_options_set_compaction_priority
(
options
:
*
mut
DBOptions
,
v
:
CompactionPriority
);
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
DBOptions
,
...
...
src/lib.rs
View file @
e0de1aad
...
...
@@ -30,7 +30,7 @@ mod slice_transform;
pub
use
compaction_filter
::
CompactionFilter
;
pub
use
librocksdb_sys
::{
DBCompactionStyle
,
DBCompressionType
,
DBRecoveryMode
,
DBInfoLogLevel
,
DBStatisticsTickerType
,
DBStatisticsHistogramType
,
new_bloom_filter
,
self
as
crocksdb_ffi
};
CompactionPriority
,
self
as
crocksdb_ffi
};
pub
use
merge_operator
::
MergeOperands
;
pub
use
rocksdb
::{
DB
,
DBIterator
,
DBVector
,
Kv
,
SeekKey
,
Writable
,
WriteBatch
,
CFHandle
,
Range
,
BackupEngine
,
SstFileWriter
};
...
...
src/rocksdb_options.rs
View file @
e0de1aad
...
...
@@ -579,6 +579,12 @@ impl Options {
}
}
pub
fn
compaction_priority
(
&
mut
self
,
priority
:
crocksdb_ffi
::
CompactionPriority
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_compaction_priority
(
self
.inner
,
priority
);
}
}
pub
fn
set_base_background_compactions
(
&
mut
self
,
n
:
c_int
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_base_background_compactions
(
self
.inner
,
n
);
...
...
tests/test_rocksdb_options.rs
View file @
e0de1aad
...
...
@@ -14,7 +14,8 @@
use
rocksdb
::{
DB
,
Options
,
BlockBasedOptions
,
WriteOptions
,
SliceTransform
,
Writable
,
CompactOptions
};
use
rocksdb
::
crocksdb_ffi
::{
DBStatisticsHistogramType
as
HistogramType
,
DBStatisticsTickerType
as
TickerType
,
DBInfoLogLevel
as
InfoLogLevel
};
DBStatisticsTickerType
as
TickerType
,
DBInfoLogLevel
as
InfoLogLevel
,
CompactionPriority
};
use
std
::
path
::
Path
;
use
std
::
thread
;
use
std
::
time
::
Duration
;
...
...
@@ -320,3 +321,12 @@ fn test_set_base_background_compactions() {
opts
.set_base_background_compactions
(
4
);
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
}
#[test]
fn
test_set_compaction_pri
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_compaction_pri"
)
.expect
(
""
);
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.compaction_priority
(
CompactionPriority
::
MinOverlappingRatio
);
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