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
cd24a696
Commit
cd24a696
authored
Feb 14, 2017
by
zhangjinpeng1987
Committed by
siddontang
Feb 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support memtable_insert_with_hint_prefix_extractor (#10)
parent
ccaa7407
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
2 deletions
+66
-2
c.cc
librocksdb_sys/crocksdb/c.cc
+5
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+3
-0
lib.rs
librocksdb_sys/src/lib.rs
+4
-1
rocksdb_options.rs
src/rocksdb_options.rs
+18
-0
test_rocksdb_options.rs
test/test_rocksdb_options.rs
+36
-1
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
cd24a696
...
...
@@ -1705,6 +1705,11 @@ void crocksdb_options_set_prefix_extractor(
opt
->
rep
.
prefix_extractor
.
reset
(
prefix_extractor
);
}
void
crocksdb_options_set_memtable_insert_with_hint_prefix_extractor
(
crocksdb_options_t
*
opt
,
crocksdb_slicetransform_t
*
prefix_extractor
)
{
opt
->
rep
.
memtable_insert_with_hint_prefix_extractor
.
reset
(
prefix_extractor
);
}
void
crocksdb_options_set_disable_data_sync
(
crocksdb_options_t
*
opt
,
int
disable_data_sync
)
{
opt
->
rep
.
disableDataSync
=
disable_data_sync
;
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
cd24a696
...
...
@@ -587,6 +587,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_compression_options(
crocksdb_options_t
*
,
int
,
int
,
int
,
int
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_prefix_extractor
(
crocksdb_options_t
*
,
crocksdb_slicetransform_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_memtable_insert_with_hint_prefix_extractor
(
crocksdb_options_t
*
,
crocksdb_slicetransform_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_num_levels
(
crocksdb_options_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
void
...
...
librocksdb_sys/src/lib.rs
View file @
cd24a696
...
...
@@ -255,12 +255,15 @@ extern "C" {
percentile95
:
*
mut
c_double
,
percentile99
:
*
mut
c_double
,
average
:
*
mut
c_double
,
standard_deviation
:
*
mut
c_double
)
->
bool
;
standard_deviation
:
*
mut
c_double
)
->
bool
;
pub
fn
crocksdb_options_set_stats_dump_period_sec
(
options
:
*
mut
DBOptions
,
v
:
usize
);
pub
fn
crocksdb_options_set_num_levels
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
pub
fn
crocksdb_options_set_db_log_dir
(
options
:
*
mut
DBOptions
,
path
:
*
const
c_char
);
pub
fn
crocksdb_options_set_prefix_extractor
(
options
:
*
mut
DBOptions
,
prefix_extractor
:
*
mut
DBSliceTransform
);
pub
fn
crocksdb_options_set_memtable_insert_with_hint_prefix_extractor
(
options
:
*
mut
DBOptions
,
prefix_extractor
:
*
mut
DBSliceTransform
);
pub
fn
crocksdb_options_set_memtable_prefix_bloom_size_ratio
(
options
:
*
mut
DBOptions
,
ratio
:
c_double
);
pub
fn
crocksdb_filterpolicy_create_bloom_full
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
...
...
src/rocksdb_options.rs
View file @
cd24a696
...
...
@@ -649,6 +649,24 @@ impl Options {
}
}
pub
fn
set_memtable_insert_hint_prefix_extractor
<
S
>
(
&
mut
self
,
name
:
S
,
transform
:
Box
<
SliceTransform
>
)
->
Result
<
(),
String
>
where
S
:
Into
<
Vec
<
u8
>>
{
unsafe
{
let
c_name
=
match
CString
::
new
(
name
)
{
Ok
(
s
)
=>
s
,
Err
(
e
)
=>
return
Err
(
format!
(
"failed to convert to cstring: {:?}"
,
e
)),
};
let
transform
=
try!
(
new_slice_transform
(
c_name
,
transform
));
crocksdb_ffi
::
crocksdb_options_set_memtable_insert_with_hint_prefix_extractor
(
self
.inner
,
transform
);
Ok
(())
}
}
pub
fn
set_memtable_prefix_bloom_size_ratio
(
&
mut
self
,
ratio
:
f64
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_memtable_prefix_bloom_size_ratio
(
self
.inner
,
ratio
);
...
...
test/test_rocksdb_options.rs
View file @
cd24a696
...
...
@@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use
rocksdb
::{
DB
,
Options
};
use
rocksdb
::{
DB
,
Options
,
WriteOptions
,
SliceTransform
};
use
rocksdb
::
crocksdb_ffi
::{
DBStatisticsHistogramType
as
HistogramType
,
DBStatisticsTickerType
as
TickerType
};
use
tempdir
::
TempDir
;
...
...
@@ -72,3 +72,38 @@ fn test_enable_statistics() {
let
opts
=
Options
::
new
();
assert
!
(
opts
.get_statistics
()
.is_none
());
}
struct
FixedPrefixTransform
{
pub
prefix_len
:
usize
,
}
impl
SliceTransform
for
FixedPrefixTransform
{
fn
transform
<
'a
>
(
&
mut
self
,
key
:
&
'a
[
u8
])
->
&
'a
[
u8
]
{
&
key
[
..
self
.prefix_len
]
}
fn
in_domain
(
&
mut
self
,
key
:
&
[
u8
])
->
bool
{
key
.len
()
>=
self
.prefix_len
}
}
#[test]
fn
test_memtable_insert_hint_prefix_extractor
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_memtable_insert_hint_prefix_extractor"
)
.expect
(
""
);
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.set_memtable_insert_hint_prefix_extractor
(
"FixedPrefixTransform"
,
Box
::
new
(
FixedPrefixTransform
{
prefix_len
:
2
,
}))
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
wopts
=
WriteOptions
::
new
();
db
.put_opt
(
b
"k0-1"
,
b
"a"
,
&
wopts
)
.unwrap
();
db
.put_opt
(
b
"k0-2"
,
b
"b"
,
&
wopts
)
.unwrap
();
db
.put_opt
(
b
"k0-3"
,
b
"c"
,
&
wopts
)
.unwrap
();
assert_eq!
(
db
.get
(
b
"k0-1"
)
.unwrap
()
.unwrap
(),
b
"a"
);
assert_eq!
(
db
.get
(
b
"k0-2"
)
.unwrap
()
.unwrap
(),
b
"b"
);
assert_eq!
(
db
.get
(
b
"k0-3"
)
.unwrap
()
.unwrap
(),
b
"c"
);
}
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