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
21516f6f
Commit
21516f6f
authored
Jan 07, 2017
by
siddontang
Committed by
GitHub
Jan 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format code (#74)
parent
65a06684
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
334 additions
and
329 deletions
+334
-329
lib.rs
librocksdb_sys/src/lib.rs
+205
-204
compaction_filter.rs
src/compaction_filter.rs
+4
-5
main.rs
src/main.rs
+1
-0
rocksdb.rs
src/rocksdb.rs
+98
-96
rocksdb_options.rs
src/rocksdb_options.rs
+26
-24
No files found.
librocksdb_sys/src/lib.rs
View file @
21516f6f
...
...
@@ -138,9 +138,9 @@ extern "C" {
block_options
:
*
mut
DBBlockBasedTableOptions
);
pub
fn
crocksdb_options_increase_parallelism
(
options
:
*
mut
DBOptions
,
threads
:
c_int
);
pub
fn
crocksdb_options_optimize_level_style_compaction
(
options
:
*
mut
DBOptions
,
memtable_memory_budget
:
c_int
);
memtable_memory_budget
:
c_int
);
pub
fn
crocksdb_options_set_compaction_filter
(
options
:
*
mut
DBOptions
,
filter
:
*
mut
DBCompactionFilter
);
filter
:
*
mut
DBCompactionFilter
);
pub
fn
crocksdb_options_set_create_if_missing
(
options
:
*
mut
DBOptions
,
v
:
bool
);
pub
fn
crocksdb_options_set_max_open_files
(
options
:
*
mut
DBOptions
,
files
:
c_int
);
pub
fn
crocksdb_options_set_max_total_wal_size
(
options
:
*
mut
DBOptions
,
size
:
u64
);
...
...
@@ -148,38 +148,39 @@ extern "C" {
pub
fn
crocksdb_options_set_bytes_per_sync
(
options
:
*
mut
DBOptions
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_disable_data_sync
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
pub
fn
crocksdb_options_optimize_for_point_lookup
(
options
:
*
mut
DBOptions
,
block_cache_size_mb
:
u64
);
block_cache_size_mb
:
u64
);
pub
fn
crocksdb_options_set_table_cache_numshardbits
(
options
:
*
mut
DBOptions
,
bits
:
c_int
);
pub
fn
crocksdb_options_set_max_write_buffer_number
(
options
:
*
mut
DBOptions
,
bufno
:
c_int
);
pub
fn
crocksdb_options_set_min_write_buffer_number_to_merge
(
options
:
*
mut
DBOptions
,
bufno
:
c_int
);
bufno
:
c_int
);
pub
fn
crocksdb_options_set_level0_file_num_compaction_trigger
(
options
:
*
mut
DBOptions
,
no
:
c_int
);
pub
fn
crocksdb_options_set_level0_slowdown_writes_trigger
(
options
:
*
mut
DBOptions
,
no
:
c_int
);
no
:
c_int
);
pub
fn
crocksdb_options_set_level0_slowdown_writes_trigger
(
options
:
*
mut
DBOptions
,
no
:
c_int
);
pub
fn
crocksdb_options_set_level0_stop_writes_trigger
(
options
:
*
mut
DBOptions
,
no
:
c_int
);
pub
fn
crocksdb_options_set_write_buffer_size
(
options
:
*
mut
DBOptions
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_target_file_size_base
(
options
:
*
mut
DBOptions
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_target_file_size_multiplier
(
options
:
*
mut
DBOptions
,
mul
:
c_int
);
pub
fn
crocksdb_options_set_max_bytes_for_level_base
(
options
:
*
mut
DBOptions
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_max_bytes_for_level_multiplier
(
options
:
*
mut
DBOptions
,
mul
:
c_int
);
mul
:
c_int
);
pub
fn
crocksdb_options_set_max_log_file_size
(
options
:
*
mut
DBOptions
,
bytes
:
size_t
);
pub
fn
crocksdb_options_set_keep_log_file_num
(
options
:
*
mut
DBOptions
,
num
:
size_t
);
pub
fn
crocksdb_options_set_max_manifest_file_size
(
options
:
*
mut
DBOptions
,
bytes
:
u64
);
pub
fn
crocksdb_options_set_hash_skip_list_rep
(
options
:
*
mut
DBOptions
,
bytes
:
u64
,
a1
:
i32
,
a2
:
i32
);
bytes
:
u64
,
a1
:
i32
,
a2
:
i32
);
pub
fn
crocksdb_options_set_compaction_style
(
options
:
*
mut
DBOptions
,
cs
:
DBCompactionStyle
);
pub
fn
crocksdb_options_set_compression
(
options
:
*
mut
DBOptions
,
compression_style_no
:
DBCompressionType
);
compression_style_no
:
DBCompressionType
);
pub
fn
crocksdb_options_set_compression_per_level
(
options
:
*
mut
DBOptions
,
level_values
:
*
const
DBCompressionType
,
num_levels
:
size_t
);
level_values
:
*
const
DBCompressionType
,
num_levels
:
size_t
);
pub
fn
crocksdb_options_set_max_background_compactions
(
options
:
*
mut
DBOptions
,
max_bg_compactions
:
c_int
);
max_bg_compactions
:
c_int
);
pub
fn
crocksdb_options_set_max_background_flushes
(
options
:
*
mut
DBOptions
,
max_bg_flushes
:
c_int
);
max_bg_flushes
:
c_int
);
pub
fn
crocksdb_options_set_filter_deletes
(
options
:
*
mut
DBOptions
,
v
:
bool
);
pub
fn
crocksdb_options_set_disable_auto_compactions
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
pub
fn
crocksdb_options_set_report_bg_io_stats
(
options
:
*
mut
DBOptions
,
v
:
c_int
);
...
...
@@ -192,99 +193,99 @@ extern "C" {
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
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBInstance
;
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBInstance
;
pub
fn
crocksdb_writeoptions_create
()
->
*
mut
DBWriteOptions
;
pub
fn
crocksdb_writeoptions_destroy
(
writeopts
:
*
mut
DBWriteOptions
);
pub
fn
crocksdb_writeoptions_set_sync
(
writeopts
:
*
mut
DBWriteOptions
,
v
:
bool
);
pub
fn
crocksdb_writeoptions_disable_WAL
(
writeopts
:
*
mut
DBWriteOptions
,
v
:
c_int
);
pub
fn
crocksdb_put
(
db
:
*
mut
DBInstance
,
writeopts
:
*
mut
DBWriteOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
writeopts
:
*
mut
DBWriteOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_put_cf
(
db
:
*
mut
DBInstance
,
writeopts
:
*
mut
DBWriteOptions
,
cf
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
writeopts
:
*
mut
DBWriteOptions
,
cf
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_readoptions_create
()
->
*
mut
DBReadOptions
;
pub
fn
crocksdb_readoptions_destroy
(
readopts
:
*
mut
DBReadOptions
);
pub
fn
crocksdb_readoptions_set_verify_checksums
(
readopts
:
*
mut
DBReadOptions
,
v
:
bool
);
pub
fn
crocksdb_readoptions_set_fill_cache
(
readopts
:
*
mut
DBReadOptions
,
v
:
bool
);
pub
fn
crocksdb_readoptions_set_snapshot
(
readopts
:
*
mut
DBReadOptions
,
snapshot
:
*
const
DBSnapshot
);
snapshot
:
*
const
DBSnapshot
);
pub
fn
crocksdb_readoptions_set_iterate_upper_bound
(
readopts
:
*
mut
DBReadOptions
,
k
:
*
const
u8
,
kLen
:
size_t
);
k
:
*
const
u8
,
kLen
:
size_t
);
pub
fn
crocksdb_readoptions_set_read_tier
(
readopts
:
*
mut
DBReadOptions
,
tier
:
c_int
);
pub
fn
crocksdb_readoptions_set_tailing
(
readopts
:
*
mut
DBReadOptions
,
v
:
bool
);
pub
fn
crocksdb_get
(
db
:
*
const
DBInstance
,
readopts
:
*
const
DBReadOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
valLen
:
*
const
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
u8
;
readopts
:
*
const
DBReadOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
valLen
:
*
const
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
u8
;
pub
fn
crocksdb_get_cf
(
db
:
*
const
DBInstance
,
readopts
:
*
const
DBReadOptions
,
cf_handle
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
valLen
:
*
const
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
u8
;
readopts
:
*
const
DBReadOptions
,
cf_handle
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
valLen
:
*
const
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
u8
;
pub
fn
crocksdb_create_iterator
(
db
:
*
mut
DBInstance
,
readopts
:
*
const
DBReadOptions
)
->
*
mut
DBIterator
;
readopts
:
*
const
DBReadOptions
)
->
*
mut
DBIterator
;
pub
fn
crocksdb_create_iterator_cf
(
db
:
*
mut
DBInstance
,
readopts
:
*
const
DBReadOptions
,
cf_handle
:
*
mut
DBCFHandle
)
->
*
mut
DBIterator
;
readopts
:
*
const
DBReadOptions
,
cf_handle
:
*
mut
DBCFHandle
)
->
*
mut
DBIterator
;
pub
fn
crocksdb_create_snapshot
(
db
:
*
mut
DBInstance
)
->
*
const
DBSnapshot
;
pub
fn
crocksdb_release_snapshot
(
db
:
*
mut
DBInstance
,
snapshot
:
*
const
DBSnapshot
);
pub
fn
crocksdb_delete
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_delete_cf
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
cf
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_close
(
db
:
*
mut
DBInstance
);
pub
fn
crocksdb_destroy_db
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_repair_db
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
// Merge
pub
fn
crocksdb_merge
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_
delet
e_cf
(
db
:
*
mut
DBInstance
,
pub
fn
crocksdb_
merg
e_cf
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
cf
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_close
(
db
:
*
mut
DBInstance
);
pub
fn
crocksdb_destroy_db
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_repair_db
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
// Merge
pub
fn
crocksdb_merge
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_merge_cf
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
cf
:
*
mut
DBCFHandle
,
k
:
*
const
u8
,
kLen
:
size_t
,
v
:
*
const
u8
,
vLen
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_mergeoperator_create
(
state
:
*
mut
c_void
,
destroy
:
extern
fn
(
*
mut
c_void
)
->
(),
...
...
@@ -326,90 +327,90 @@ extern "C" {
pub
fn
crocksdb_iter_get_error
(
iter
:
*
const
DBIterator
,
err
:
*
mut
*
mut
c_char
);
// Write batch
pub
fn
crocksdb_write
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
batch
:
*
mut
DBWriteBatch
,
err
:
*
mut
*
mut
c_char
);
writeopts
:
*
const
DBWriteOptions
,
batch
:
*
mut
DBWriteBatch
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_writebatch_create
()
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_create_from
(
rep
:
*
const
u8
,
size
:
size_t
)
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_destroy
(
batch
:
*
mut
DBWriteBatch
);
pub
fn
crocksdb_writebatch_clear
(
batch
:
*
mut
DBWriteBatch
);
pub
fn
crocksdb_writebatch_count
(
batch
:
*
mut
DBWriteBatch
)
->
c_int
;
pub
fn
crocksdb_writebatch_put
(
batch
:
*
mut
DBWriteBatch
,
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_put_cf
(
batch
:
*
mut
DBWriteBatch
,
cf
:
*
mut
DBCFHandle
,
cf
:
*
mut
DBCFHandle
,
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_merge
(
batch
:
*
mut
DBWriteBatch
,
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_merge
(
batch
:
*
mut
DBWriteBatch
,
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_merge_cf
(
batch
:
*
mut
DBWriteBatch
,
cf
:
*
mut
DBCFHandle
,
key
:
*
const
u8
,
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_delete
(
batch
:
*
mut
DBWriteBatch
,
key
:
*
const
u8
,
klen
:
size_t
);
pub
fn
crocksdb_writebatch_delete_cf
(
batch
:
*
mut
DBWriteBatch
,
cf
:
*
mut
DBCFHandle
,
key
:
*
const
u8
,
klen
:
size_t
);
klen
:
size_t
,
val
:
*
const
u8
,
vlen
:
size_t
);
pub
fn
crocksdb_writebatch_delete
(
batch
:
*
mut
DBWriteBatch
,
key
:
*
const
u8
,
klen
:
size_t
);
pub
fn
crocksdb_writebatch_delete_cf
(
batch
:
*
mut
DBWriteBatch
,
cf
:
*
mut
DBCFHandle
,
key
:
*
const
u8
,
klen
:
size_t
);
pub
fn
crocksdb_writebatch_iterate
(
batch
:
*
mut
DBWriteBatch
,
state
:
*
mut
c_void
,
put_fn
:
extern
"C"
fn
(
state
:
*
mut
c_void
,
k
:
*
const
u8
,
klen
:
size_t
,
v
:
*
const
u8
,
vlen
:
size_t
),
deleted_fn
:
extern
"C"
fn
(
state
:
*
mut
c_void
,
k
:
*
const
u8
,
klen
:
size_t
));
state
:
*
mut
c_void
,
put_fn
:
extern
"C"
fn
(
state
:
*
mut
c_void
,
k
:
*
const
u8
,
klen
:
size_t
,
v
:
*
const
u8
,
vlen
:
size_t
),
deleted_fn
:
extern
"C"
fn
(
state
:
*
mut
c_void
,
k
:
*
const
u8
,
klen
:
size_t
));
pub
fn
crocksdb_writebatch_data
(
batch
:
*
mut
DBWriteBatch
,
size
:
*
mut
size_t
)
->
*
const
u8
;
// Comparator
pub
fn
crocksdb_options_set_comparator
(
options
:
*
mut
DBOptions
,
cb
:
*
mut
DBComparator
);
pub
fn
crocksdb_comparator_create
(
state
:
*
mut
c_void
,
destroy
:
extern
"C"
fn
(
*
mut
c_void
)
->
(),
compare
:
extern
"C"
fn
(
arg
:
*
mut
c_void
,
a
:
*
const
c_char
,
alen
:
size_t
,
b
:
*
const
c_char
,
blen
:
size_t
)
->
c_int
,
name_fn
:
extern
"C"
fn
(
*
mut
c_void
)
->
*
const
c_char
)
->
*
mut
DBComparator
;
destroy
:
extern
"C"
fn
(
*
mut
c_void
)
->
(),
compare
:
extern
"C"
fn
(
arg
:
*
mut
c_void
,
a
:
*
const
c_char
,
alen
:
size_t
,
b
:
*
const
c_char
,
blen
:
size_t
)
->
c_int
,
name_fn
:
extern
"C"
fn
(
*
mut
c_void
)
->
*
const
c_char
)
->
*
mut
DBComparator
;
pub
fn
crocksdb_comparator_destroy
(
cmp
:
*
mut
DBComparator
);
// Column Family
pub
fn
crocksdb_open_column_families
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
num_column_families
:
c_int
,
column_family_names
:
*
const
*
const
c_char
,
column_family_options
:
*
const
*
const
DBOptions
,
column_family_handles
:
*
const
*
mut
DBCFHandle
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBInstance
;
path
:
*
const
c_char
,
num_column_families
:
c_int
,
column_family_names
:
*
const
*
const
c_char
,
column_family_options
:
*
const
*
const
DBOptions
,
column_family_handles
:
*
const
*
mut
DBCFHandle
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBInstance
;
pub
fn
crocksdb_create_column_family
(
db
:
*
mut
DBInstance
,
column_family_options
:
*
const
DBOptions
,
column_family_name
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBCFHandle
;
column_family_options
:
*
const
DBOptions
,
column_family_name
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBCFHandle
;
pub
fn
crocksdb_drop_column_family
(
db
:
*
mut
DBInstance
,
column_family_handle
:
*
mut
DBCFHandle
,
err
:
*
mut
*
mut
c_char
);
column_family_handle
:
*
mut
DBCFHandle
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_column_family_handle_destroy
(
column_family_handle
:
*
mut
DBCFHandle
);
pub
fn
crocksdb_list_column_families
(
db
:
*
const
DBOptions
,
path
:
*
const
c_char
,
lencf
:
*
mut
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
*
mut
c_char
;
path
:
*
const
c_char
,
lencf
:
*
mut
size_t
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
*
mut
c_char
;
pub
fn
crocksdb_list_column_families_destroy
(
list
:
*
mut
*
mut
c_char
,
len
:
size_t
);
// Flush options
...
...
@@ -418,70 +419,70 @@ extern "C" {
pub
fn
crocksdb_flushoptions_set_wait
(
opt
:
*
mut
DBFlushOptions
,
whether_wait
:
bool
);
pub
fn
crocksdb_flush
(
db
:
*
mut
DBInstance
,
options
:
*
const
DBFlushOptions
,
err
:
*
mut
*
mut
c_char
);
options
:
*
const
DBFlushOptions
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_approximate_sizes
(
db
:
*
mut
DBInstance
,
num_ranges
:
c_int
,
range_start_key
:
*
const
*
const
u8
,
range_start_key_len
:
*
const
size_t
,
range_limit_key
:
*
const
*
const
u8
,
range_limit_key_len
:
*
const
size_t
,
sizes
:
*
mut
uint64_t
);
num_ranges
:
c_int
,
range_start_key
:
*
const
*
const
u8
,
range_start_key_len
:
*
const
size_t
,
range_limit_key
:
*
const
*
const
u8
,
range_limit_key_len
:
*
const
size_t
,
sizes
:
*
mut
uint64_t
);
pub
fn
crocksdb_approximate_sizes_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
num_ranges
:
c_int
,
range_start_key
:
*
const
*
const
u8
,
range_start_key_len
:
*
const
size_t
,
range_limit_key
:
*
const
*
const
u8
,
range_limit_key_len
:
*
const
size_t
,
sizes
:
*
mut
uint64_t
);
cf
:
*
mut
DBCFHandle
,
num_ranges
:
c_int
,
range_start_key
:
*
const
*
const
u8
,
range_start_key_len
:
*
const
size_t
,
range_limit_key
:
*
const
*
const
u8
,
range_limit_key_len
:
*
const
size_t
,
sizes
:
*
mut
uint64_t
);
pub
fn
crocksdb_compact_range
(
db
:
*
mut
DBInstance
,
start_key
:
*
const
u8
,
start_key_len
:
size_t
,
limit_key
:
*
const
u8
,
limit_key_len
:
size_t
);
start_key
:
*
const
u8
,
start_key_len
:
size_t
,
limit_key
:
*
const
u8
,
limit_key_len
:
size_t
);
pub
fn
crocksdb_compact_range_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
start_key
:
*
const
u8
,
start_key_len
:
size_t
,
limit_key
:
*
const
u8
,
limit_key_len
:
size_t
);
cf
:
*
mut
DBCFHandle
,
start_key
:
*
const
u8
,
start_key_len
:
size_t
,
limit_key
:
*
const
u8
,
limit_key_len
:
size_t
);
pub
fn
crocksdb_delete_file_in_range
(
db
:
*
mut
DBInstance
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
mut
c_char
);
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_delete_file_in_range_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
mut
c_char
);
cf
:
*
mut
DBCFHandle
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_property_value
(
db
:
*
mut
DBInstance
,
propname
:
*
const
c_char
)
->
*
mut
c_char
;
pub
fn
crocksdb_property_value_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
propname
:
*
const
c_char
)
->
*
mut
c_char
;
cf
:
*
mut
DBCFHandle
,
propname
:
*
const
c_char
)
->
*
mut
c_char
;
// Compaction filter
pub
fn
crocksdb_compactionfilter_create
(
state
:
*
mut
c_void
,
destructor
:
extern
"C"
fn
(
*
mut
c_void
),
filter
:
extern
"C"
fn
(
*
mut
c_void
,
c_int
,
*
const
u8
,
size_t
,
*
const
u8
,
size_t
,
*
mut
*
mut
u8
,
*
mut
size_t
,
*
mut
bool
)
->
bool
,
name
:
extern
"C"
fn
(
*
mut
c_void
)
->
*
const
c_char
)
->
*
mut
DBCompactionFilter
;
destructor
:
extern
"C"
fn
(
*
mut
c_void
),
filter
:
extern
"C"
fn
(
*
mut
c_void
,
c_int
,
*
const
u8
,
size_t
,
*
const
u8
,
size_t
,
*
mut
*
mut
u8
,
*
mut
size_t
,
*
mut
bool
)
->
bool
,
name
:
extern
"C"
fn
(
*
mut
c_void
)
->
*
const
c_char
)
->
*
mut
DBCompactionFilter
;
pub
fn
crocksdb_compactionfilter_set_ignore_snapshots
(
filter
:
*
mut
DBCompactionFilter
,
ignore_snapshot
:
bool
);
ignore_snapshot
:
bool
);
pub
fn
crocksdb_compactionfilter_destroy
(
filter
:
*
mut
DBCompactionFilter
);
// Restore Option
...
...
@@ -492,18 +493,18 @@ extern "C" {
// Backup engine
// TODO: add more ffis about backup engine.
pub
fn
crocksdb_backup_engine_open
(
options
:
*
const
DBOptions
,
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBBackupEngine
;
path
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
)
->
*
mut
DBBackupEngine
;
pub
fn
crocksdb_backup_engine_create_new_backup
(
be
:
*
mut
DBBackupEngine
,
db
:
*
mut
DBInstance
,
err
:
*
mut
*
mut
c_char
);
db
:
*
mut
DBInstance
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_backup_engine_close
(
be
:
*
mut
DBBackupEngine
);
pub
fn
crocksdb_backup_engine_restore_db_from_latest_backup
(
be
:
*
mut
DBBackupEngine
,
db_path
:
*
const
c_char
,
wal_path
:
*
const
c_char
,
ropts
:
*
const
DBRestoreOptions
,
err
:
*
mut
*
mut
c_char
);
db_path
:
*
const
c_char
,
wal_path
:
*
const
c_char
,
ropts
:
*
const
DBRestoreOptions
,
err
:
*
mut
*
mut
c_char
);
}
#[cfg(test)]
...
...
@@ -558,21 +559,21 @@ mod test {
let
mut
sizes
=
vec!
[
0
;
1
];
crocksdb_approximate_sizes
(
db
,
1
,
vec!
[
b
"
\x00\x00
"
.as_ptr
()]
.as_ptr
(),
vec!
[
1
]
.as_ptr
(),
vec!
[
b
"
\xff\x00
"
.as_ptr
()]
.as_ptr
(),
vec!
[
1
]
.as_ptr
(),
sizes
.as_mut_ptr
());
1
,
vec!
[
b
"
\x00\x00
"
.as_ptr
()]
.as_ptr
(),
vec!
[
1
]
.as_ptr
(),
vec!
[
b
"
\xff\x00
"
.as_ptr
()]
.as_ptr
(),
vec!
[
1
]
.as_ptr
(),
sizes
.as_mut_ptr
());
assert_eq!
(
sizes
.len
(),
1
);
assert
!
(
sizes
[
0
]
>
0
);
crocksdb_delete_file_in_range
(
db
,
b
"
\x00\x00
"
.as_ptr
(),
2
,
b
"
\xff\x00
"
.as_ptr
(),
2
,
&
mut
err
);
b
"
\x00\x00
"
.as_ptr
(),
2
,
b
"
\xff\x00
"
.as_ptr
(),
2
,
&
mut
err
);
assert
!
(
err
.is_null
(),
error_message
(
err
));
let
propname
=
CString
::
new
(
"rocksdb.total-sst-files-size"
)
.unwrap
();
...
...
src/compaction_filter.rs
View file @
21516f6f
use
libc
::{
c_void
,
c_char
,
c_int
,
size_t
};
use
crocksdb_ffi
::{
self
,
DBCompactionFilter
};
use
libc
::{
c_void
,
c_char
,
c_int
,
size_t
};
use
std
::
ffi
::
CString
;
use
std
::
slice
;
...
...
@@ -75,9 +74,9 @@ pub unsafe fn new_compaction_filter(c_name: CString,
filter
:
f
,
}));
let
filter
=
crocksdb_ffi
::
crocksdb_compactionfilter_create
(
proxy
as
*
mut
c_void
,
destructor
,
filter
,
name
);
destructor
,
filter
,
name
);
crocksdb_ffi
::
crocksdb_compactionfilter_set_ignore_snapshots
(
filter
,
ignore_snapshots
);
Ok
(
CompactionFilterHandle
{
inner
:
filter
})
}
src/main.rs
View file @
21516f6f
...
...
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
extern
crate
rocksdb
;
use
rocksdb
::{
DB
,
MergeOperands
,
Options
,
Writable
};
...
...
src/rocksdb.rs
View file @
21516f6f
...
...
@@ -13,10 +13,8 @@
// limitations under the License.
//
use
libc
::{
self
,
c_int
,
c_void
,
size_t
};
use
crocksdb_ffi
::{
self
,
DBWriteBatch
,
DBCFHandle
,
DBInstance
,
DBBackupEngine
};
use
libc
::{
self
,
c_int
,
c_void
,
size_t
};
use
rocksdb_options
::{
Options
,
ReadOptions
,
UnsafeSnap
,
WriteOptions
,
FlushOptions
,
RestoreOptions
};
use
std
::
collections
::
BTreeMap
;
use
std
::
collections
::
btree_map
::
Entry
;
...
...
@@ -115,7 +113,9 @@ impl<'a> DBIterator<'a> {
SeekKey
::
Start
=>
crocksdb_ffi
::
crocksdb_iter_seek_to_first
(
self
.inner
),
SeekKey
::
End
=>
crocksdb_ffi
::
crocksdb_iter_seek_to_last
(
self
.inner
),
SeekKey
::
Key
(
key
)
=>
{
crocksdb_ffi
::
crocksdb_iter_seek_for_prev
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
)
crocksdb_ffi
::
crocksdb_iter_seek_for_prev
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
)
}
}
}
...
...
@@ -171,8 +171,8 @@ impl<'a> DBIterator<'a> {
pub
fn
new_cf
(
db
:
&
'a
DB
,
cf_handle
:
&
CFHandle
,
readopts
:
ReadOptions
)
->
DBIterator
<
'a
>
{
unsafe
{
let
iterator
=
crocksdb_ffi
::
crocksdb_create_iterator_cf
(
db
.inner
,
readopts
.get_inner
(),
cf_handle
.inner
);
readopts
.get_inner
(),
cf_handle
.inner
);
DBIterator
{
db
:
db
,
readopts
:
readopts
,
...
...
@@ -340,11 +340,11 @@ impl DB {
let
db
=
unsafe
{
ffi_try!
(
crocksdb_open_column_families
(
opts
.inner
,
cpath
.as_ptr
(),
cfs_v
.len
()
as
c_int
,
cfnames
.as_ptr
(),
cfopts
.as_ptr
(),
cfhandles
.as_ptr
()))
cpath
.as_ptr
(),
cfs_v
.len
()
as
c_int
,
cfnames
.as_ptr
(),
cfopts
.as_ptr
(),
cfhandles
.as_ptr
()))
};
for
handle
in
&
cfhandles
{
...
...
@@ -444,10 +444,10 @@ impl DB {
let
val_len
:
size_t
=
0
;
let
val_len_ptr
=
&
val_len
as
*
const
size_t
;
let
val
=
ffi_try!
(
crocksdb_get
(
self
.inner
,
readopts
.get_inner
(),
key
.as_ptr
(),
key
.len
()
as
size_t
,
val_len_ptr
));
readopts
.get_inner
(),
key
.as_ptr
(),
key
.len
()
as
size_t
,
val_len_ptr
));
if
val
.is_null
()
{
Ok
(
None
)
}
else
{
...
...
@@ -469,11 +469,11 @@ impl DB {
let
val_len
:
size_t
=
0
;
let
val_len_ptr
=
&
val_len
as
*
const
size_t
;
let
val
=
ffi_try!
(
crocksdb_get_cf
(
self
.inner
,
readopts
.get_inner
(),
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
val_len_ptr
));
readopts
.get_inner
(),
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
val_len_ptr
));
if
val
.is_null
()
{
Ok
(
None
)
}
else
{
...
...
@@ -563,11 +563,11 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_put
(
self
.inner
,
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -580,12 +580,12 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_put_cf
(
self
.inner
,
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -596,11 +596,11 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_merge
(
self
.inner
,
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -612,21 +612,21 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_merge_cf
(
self
.inner
,
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
));
Ok
(())
}
}
fn
delete_opt
(
&
self
,
key
:
&
[
u8
],
writeopts
:
&
WriteOptions
)
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_delete
(
self
.inner
,
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
));
writeopts
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -638,10 +638,10 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_delete_cf
(
self
.inner
,
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
));
writeopts
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -699,22 +699,22 @@ impl DB {
match
cf
{
None
=>
unsafe
{
crocksdb_ffi
::
crocksdb_approximate_sizes
(
self
.inner
,
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
},
Some
(
cf
)
=>
unsafe
{
crocksdb_ffi
::
crocksdb_approximate_sizes_cf
(
self
.inner
,
cf
.inner
,
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
cf
.inner
,
n
,
start_key_ptr
,
start_key_len_ptr
,
end_key_ptr
,
end_key_len_ptr
,
size_ptr
)
},
}
sizes
...
...
@@ -742,10 +742,10 @@ impl DB {
pub
fn
delete_file_in_range
(
&
self
,
start_key
:
&
[
u8
],
end_key
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_delete_file_in_range
(
self
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
));
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -757,11 +757,11 @@ impl DB {
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_delete_file_in_range_cf
(
self
.inner
,
cf
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
));
cf
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
));
Ok
(())
}
}
...
...
@@ -791,7 +791,9 @@ impl DB {
let
value
=
match
cf
{
None
=>
crocksdb_ffi
::
crocksdb_property_value
(
self
.inner
,
prop_name
.as_ptr
()),
Some
(
cf
)
=>
{
crocksdb_ffi
::
crocksdb_property_value_cf
(
self
.inner
,
cf
.inner
,
prop_name
.as_ptr
())
crocksdb_ffi
::
crocksdb_property_value_cf
(
self
.inner
,
cf
.inner
,
prop_name
.as_ptr
())
}
};
...
...
@@ -853,9 +855,9 @@ impl DB {
unsafe
{
ffi_try!
(
crocksdb_backup_engine_restore_db_from_latest_backup
(
backup_engine
.inner
,
c_db_path
.as_ptr
(),
c_wal_path
.as_ptr
(),
ropts
.inner
))
c_db_path
.as_ptr
(),
c_wal_path
.as_ptr
(),
ropts
.inner
))
};
DB
::
open_default
(
restore_db_path
)
...
...
@@ -941,10 +943,10 @@ impl Writable for WriteBatch {
fn
put
(
&
self
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_put
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
Ok
(())
}
}
...
...
@@ -952,11 +954,11 @@ impl Writable for WriteBatch {
fn
put_cf
(
&
self
,
cf
:
&
CFHandle
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_put_cf
(
self
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
Ok
(())
}
}
...
...
@@ -964,10 +966,10 @@ impl Writable for WriteBatch {
fn
merge
(
&
self
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_merge
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
Ok
(())
}
}
...
...
@@ -975,11 +977,11 @@ impl Writable for WriteBatch {
fn
merge_cf
(
&
self
,
cf
:
&
CFHandle
,
key
:
&
[
u8
],
value
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_merge_cf
(
self
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
,
value
.as_ptr
(),
value
.len
()
as
size_t
);
Ok
(())
}
}
...
...
@@ -994,9 +996,9 @@ impl Writable for WriteBatch {
fn
delete_cf
(
&
self
,
cf
:
&
CFHandle
,
key
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_delete_cf
(
self
.inner
,
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
);
cf
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
);
Ok
(())
}
}
...
...
src/rocksdb_options.rs
View file @
21516f6f
...
...
@@ -15,13 +15,13 @@
use
compaction_filter
::{
CompactionFilter
,
new_compaction_filter
,
CompactionFilterHandle
};
use
comparator
::{
self
,
ComparatorCallback
,
compare_callback
};
use
crocksdb_ffi
::{
self
,
DBOptions
,
DBWriteOptions
,
DBBlockBasedTableOptions
,
DBReadOptions
,
DBRestoreOptions
,
DBCompressionType
,
DBRecoveryMode
,
DBSnapshot
,
DBInstance
,
DBFlushOptions
};
use
libc
::{
self
,
c_int
,
size_t
,
c_void
};
use
merge_operator
::{
self
,
MergeOperatorCallback
,
full_merge_callback
,
partial_merge_callback
};
use
merge_operator
::
MergeFn
;
use
crocksdb_ffi
::{
self
,
DBOptions
,
DBWriteOptions
,
DBBlockBasedTableOptions
,
DBReadOptions
,
DBRestoreOptions
,
DBCompressionType
,
DBRecoveryMode
,
DBSnapshot
,
DBInstance
,
DBFlushOptions
};
use
std
::
ffi
::{
CStr
,
CString
};
use
std
::
mem
;
...
...
@@ -154,8 +154,8 @@ impl ReadOptions {
self
.upper_bound
=
Vec
::
from
(
key
);
unsafe
{
crocksdb_ffi
::
crocksdb_readoptions_set_iterate_upper_bound
(
self
.inner
,
self
.upper_bound
.as_ptr
(),
self
.upper_bound
.len
());
self
.upper_bound
.as_ptr
(),
self
.upper_bound
.len
());
}
}
...
...
@@ -247,7 +247,7 @@ impl Options {
pub
fn
optimize_level_style_compaction
(
&
mut
self
,
memtable_memory_budget
:
i32
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_optimize_level_style_compaction
(
self
.inner
,
memtable_memory_budget
);
memtable_memory_budget
);
}
}
...
...
@@ -277,10 +277,10 @@ impl Options {
};
self
.filter
=
Some
(
try!
(
new_compaction_filter
(
c_name
,
ignore_snapshots
,
filter
)));
crocksdb_ffi
::
crocksdb_options_set_compaction_filter
(
self
.inner
,
self
.filter
.as_ref
()
.unwrap
()
.inner
);
self
.filter
.as_ref
()
.unwrap
()
.inner
);
Ok
(())
}
}
...
...
@@ -300,8 +300,8 @@ impl Options {
pub
fn
compression_per_level
(
&
mut
self
,
level_types
:
&
[
DBCompressionType
])
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_compression_per_level
(
self
.inner
,
level_types
.as_ptr
(),
level_types
.len
()
as
size_t
)
level_types
.as_ptr
(),
level_types
.len
()
as
size_t
)
}
}
...
...
@@ -312,12 +312,13 @@ impl Options {
});
unsafe
{
let
mo
=
crocksdb_ffi
::
crocksdb_mergeoperator_create
(
mem
::
transmute
(
cb
),
merge_operator
::
destructor_callback
,
full_merge_callback
,
partial_merge_callback
,
None
,
merge_operator
::
name_callback
);
let
mo
=
crocksdb_ffi
::
crocksdb_mergeoperator_create
(
mem
::
transmute
(
cb
),
merge_operator
::
destructor_callback
,
full_merge_callback
,
partial_merge_callback
,
None
,
merge_operator
::
name_callback
);
crocksdb_ffi
::
crocksdb_options_set_merge_operator
(
self
.inner
,
mo
);
}
}
...
...
@@ -330,9 +331,9 @@ impl Options {
unsafe
{
let
cmp
=
crocksdb_ffi
::
crocksdb_comparator_create
(
mem
::
transmute
(
cb
),
comparator
::
destructor_callback
,
compare_callback
,
comparator
::
name_callback
);
comparator
::
destructor_callback
,
compare_callback
,
comparator
::
name_callback
);
crocksdb_ffi
::
crocksdb_options_set_comparator
(
self
.inner
,
cmp
);
}
}
...
...
@@ -432,7 +433,8 @@ impl Options {
pub
fn
set_min_write_buffer_number_to_merge
(
&
mut
self
,
to_merge
:
c_int
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_min_write_buffer_number_to_merge
(
self
.inner
,
to_merge
);
crocksdb_ffi
::
crocksdb_options_set_min_write_buffer_number_to_merge
(
self
.inner
,
to_merge
);
}
}
...
...
@@ -600,7 +602,7 @@ impl RestoreOptions {
pub
fn
set_keep_log_files
(
&
mut
self
,
flag
:
bool
)
{
unsafe
{
crocksdb_ffi
::
crocksdb_restore_options_set_keep_log_files
(
self
.inner
,
if
flag
{
1
}
else
{
0
})
if
flag
{
1
}
else
{
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