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
dab0fc9d
Unverified
Commit
dab0fc9d
authored
Dec 29, 2017
by
Huachao Huang
Committed by
GitHub
Dec 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add vector memtable option (#181)
parent
4acb7d85
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
0 deletions
+45
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+5
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+2
-0
lib.rs
librocksdb_sys/src/lib.rs
+1
-0
rocksdb_options.rs
src/rocksdb_options.rs
+6
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+31
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
dab0fc9d
...
@@ -129,6 +129,7 @@ using rocksdb::ExternalSstFilePropertyNames;
...
@@ -129,6 +129,7 @@ using rocksdb::ExternalSstFilePropertyNames;
using
rocksdb
::
DecodeFixed32
;
using
rocksdb
::
DecodeFixed32
;
using
rocksdb
::
DecodeFixed64
;
using
rocksdb
::
DecodeFixed64
;
using
rocksdb
::
PutFixed64
;
using
rocksdb
::
PutFixed64
;
using
rocksdb
::
VectorRepFactory
;
using
std
::
shared_ptr
;
using
std
::
shared_ptr
;
...
@@ -2457,6 +2458,10 @@ void crocksdb_options_set_ratelimiter(crocksdb_options_t *opt, crocksdb_ratelimi
...
@@ -2457,6 +2458,10 @@ void crocksdb_options_set_ratelimiter(crocksdb_options_t *opt, crocksdb_ratelimi
limiter
->
rep
=
nullptr
;
limiter
->
rep
=
nullptr
;
}
}
void
crocksdb_options_set_vector_memtable_factory
(
crocksdb_options_t
*
opt
,
uint64_t
reserved_bytes
)
{
opt
->
rep
.
memtable_factory
.
reset
(
new
VectorRepFactory
(
reserved_bytes
));
}
crocksdb_ratelimiter_t
*
crocksdb_ratelimiter_create
(
crocksdb_ratelimiter_t
*
crocksdb_ratelimiter_create
(
int64_t
rate_bytes_per_sec
,
int64_t
rate_bytes_per_sec
,
int64_t
refill_period_us
,
int64_t
refill_period_us
,
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
dab0fc9d
...
@@ -977,6 +977,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_fifo_compaction_options(
...
@@ -977,6 +977,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_fifo_compaction_options(
crocksdb_options_t
*
opt
,
crocksdb_fifo_compaction_options_t
*
fifo
);
crocksdb_options_t
*
opt
,
crocksdb_fifo_compaction_options_t
*
fifo
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_ratelimiter
(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_ratelimiter
(
crocksdb_options_t
*
opt
,
crocksdb_ratelimiter_t
*
limiter
);
crocksdb_options_t
*
opt
,
crocksdb_ratelimiter_t
*
limiter
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_vector_memtable_factory
(
crocksdb_options_t
*
opt
,
uint64_t
reserved_bytes
);
enum
{
enum
{
compaction_by_compensated_size
=
0
,
compaction_by_compensated_size
=
0
,
...
...
librocksdb_sys/src/lib.rs
View file @
dab0fc9d
...
@@ -547,6 +547,7 @@ extern "C" {
...
@@ -547,6 +547,7 @@ extern "C" {
target_size
:
*
const
u64
,
target_size
:
*
const
u64
,
num_paths
:
c_int
,
num_paths
:
c_int
,
);
);
pub
fn
crocksdb_options_set_vector_memtable_factory
(
options
:
*
mut
Options
,
reserved_bytes
:
u64
);
pub
fn
crocksdb_filterpolicy_create_bloom_full
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
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_filterpolicy_create_bloom
(
bits_per_key
:
c_int
)
->
*
mut
DBFilterPolicy
;
pub
fn
crocksdb_open
(
pub
fn
crocksdb_open
(
...
...
src/rocksdb_options.rs
View file @
dab0fc9d
...
@@ -1270,6 +1270,12 @@ impl ColumnFamilyOptions {
...
@@ -1270,6 +1270,12 @@ impl ColumnFamilyOptions {
crocksdb_ffi
::
crocksdb_options_set_fifo_compaction_options
(
self
.inner
,
fifo_opts
.inner
);
crocksdb_ffi
::
crocksdb_options_set_fifo_compaction_options
(
self
.inner
,
fifo_opts
.inner
);
}
}
}
}
pub
fn
set_vector_memtable_factory
(
&
mut
self
,
reserved_bytes
:
u64
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_vector_memtable_factory
(
self
.inner
,
reserved_bytes
);
}
}
}
}
// ColumnFamilyDescriptor is a pair of column family's name and options.
// ColumnFamilyDescriptor is a pair of column family's name and options.
...
...
tests/test_rocksdb_options.rs
View file @
dab0fc9d
...
@@ -668,3 +668,34 @@ fn test_readoptions_max_bytes_for_level_multiplier() {
...
@@ -668,3 +668,34 @@ fn test_readoptions_max_bytes_for_level_multiplier() {
cf_opts
.set_max_bytes_for_level_multiplier
(
8
);
cf_opts
.set_max_bytes_for_level_multiplier
(
8
);
assert_eq!
(
cf_opts
.get_max_bytes_for_level_multiplier
(),
8
);
assert_eq!
(
cf_opts
.get_max_bytes_for_level_multiplier
(),
8
);
}
}
#[test]
fn
test_vector_memtable_factory_options
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_vector_memtable_factory_options"
)
.unwrap
();
let
path_str
=
path
.path
()
.to_str
()
.unwrap
();
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
opts
.allow_concurrent_memtable_write
(
false
);
let
mut
cf_opts
=
ColumnFamilyOptions
::
new
();
cf_opts
.set_vector_memtable_factory
(
4096
);
let
db
=
DB
::
open_cf
(
opts
.clone
(),
path_str
,
vec!
[(
"default"
,
cf_opts
)])
.unwrap
();
db
.put
(
b
"k1"
,
b
"v1"
)
.unwrap
();
db
.put
(
b
"k2"
,
b
"v2"
)
.unwrap
();
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v1"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
db
.flush
(
true
)
.unwrap
();
let
mut
iter
=
db
.iter
();
iter
.seek
(
SeekKey
::
Start
);
assert
!
(
iter
.valid
());
assert_eq!
(
iter
.key
(),
b
"k1"
);
assert_eq!
(
iter
.value
(),
b
"v1"
);
assert
!
(
iter
.next
());
assert_eq!
(
iter
.key
(),
b
"k2"
);
assert_eq!
(
iter
.value
(),
b
"v2"
);
assert
!
(
!
iter
.next
());
assert
!
(
!
iter
.valid
());
}
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