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
269c5712
Commit
269c5712
authored
Jul 17, 2015
by
Tyler Neely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run rustfmt on the code.
parent
b6cf467a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
77 deletions
+76
-77
README.md
README.md
+1
-1
comparator.rs
src/comparator.rs
+7
-5
ffi.rs
src/ffi.rs
+8
-8
lib.rs
src/lib.rs
+4
-20
merge_operator.rs
src/merge_operator.rs
+28
-16
rocksdb.rs
src/rocksdb.rs
+20
-16
rocksdb_options.rs
src/rocksdb_options.rs
+8
-11
No files found.
README.md
View file @
269c5712
...
@@ -12,7 +12,7 @@ This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.0.6
...
@@ -12,7 +12,7 @@ This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.0.6
-
[
x
]
LRU cache
-
[
x
]
LRU cache
-
[
x
]
destroy/repair
-
[
x
]
destroy/repair
-
[
x
]
iterator
-
[
x
]
iterator
-
[
]
comparator
-
[
x
]
comparator
-
[
x
]
snapshot
-
[
x
]
snapshot
-
[
]
column family operations
-
[
]
column family operations
-
[
]
slicetransform
-
[
]
slicetransform
...
...
src/comparator.rs
View file @
269c5712
...
@@ -25,7 +25,7 @@ use rocksdb::RocksDB;
...
@@ -25,7 +25,7 @@ use rocksdb::RocksDB;
pub
struct
ComparatorCallback
{
pub
struct
ComparatorCallback
{
pub
name
:
CString
,
pub
name
:
CString
,
pub
f
:
fn
(
&
[
u8
],
&
[
u8
])
->
i32
,
pub
f
:
fn
(
&
[
u8
],
&
[
u8
])
->
i32
,
}
}
pub
extern
"C"
fn
destructor_callback
(
raw_cb
:
*
mut
c_void
)
{
pub
extern
"C"
fn
destructor_callback
(
raw_cb
:
*
mut
c_void
)
{
...
@@ -42,10 +42,12 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char {
...
@@ -42,10 +42,12 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char {
}
}
}
}
pub
extern
"C"
fn
compare_callback
(
pub
extern
"C"
fn
compare_callback
(
raw_cb
:
*
mut
c_void
,
raw_cb
:
*
mut
c_void
,
a_raw
:
*
const
c_char
,
a_raw
:
*
const
c_char
,
a_len
:
size_t
,
a_len
:
size_t
,
b_raw
:
*
const
c_char
,
b_len
:
size_t
)
->
c_int
{
b_raw
:
*
const
c_char
,
b_len
:
size_t
)
->
c_int
{
unsafe
{
unsafe
{
let
cb
:
&
mut
ComparatorCallback
=
let
cb
:
&
mut
ComparatorCallback
=
&
mut
*
(
raw_cb
as
*
mut
ComparatorCallback
);
&
mut
*
(
raw_cb
as
*
mut
ComparatorCallback
);
...
...
src/ffi.rs
View file @
269c5712
...
@@ -71,25 +71,25 @@ pub fn new_cache(capacity: size_t) -> RocksDBCache {
...
@@ -71,25 +71,25 @@ pub fn new_cache(capacity: size_t) -> RocksDBCache {
#[repr(C)]
#[repr(C)]
pub
enum
RocksDBCompressionType
{
pub
enum
RocksDBCompressionType
{
RocksDBNoCompression
=
0
,
RocksDBNoCompression
=
0
,
RocksDBSnappyCompression
=
1
,
RocksDBSnappyCompression
=
1
,
RocksDBZlibCompression
=
2
,
RocksDBZlibCompression
=
2
,
RocksDBBz2Compression
=
3
,
RocksDBBz2Compression
=
3
,
RocksDBLz4Compression
=
4
,
RocksDBLz4Compression
=
4
,
RocksDBLz4hcCompression
=
5
RocksDBLz4hcCompression
=
5
,
}
}
#[repr(C)]
#[repr(C)]
pub
enum
RocksDBCompactionStyle
{
pub
enum
RocksDBCompactionStyle
{
RocksDBLevelCompaction
=
0
,
RocksDBLevelCompaction
=
0
,
RocksDBUniversalCompaction
=
1
,
RocksDBUniversalCompaction
=
1
,
RocksDBFifoCompaction
=
2
RocksDBFifoCompaction
=
2
,
}
}
#[repr(C)]
#[repr(C)]
pub
enum
RocksDBUniversalCompactionStyle
{
pub
enum
RocksDBUniversalCompactionStyle
{
rocksdb_similar_size_compaction_stop_style
=
0
,
rocksdb_similar_size_compaction_stop_style
=
0
,
rocksdb_total_size_compaction_stop_style
=
1
rocksdb_total_size_compaction_stop_style
=
1
,
}
}
//TODO audit the use of boolean arguments, b/c I think they need to be u8 instead...
//TODO audit the use of boolean arguments, b/c I think they need to be u8 instead...
...
...
src/lib.rs
View file @
269c5712
...
@@ -21,26 +21,10 @@
...
@@ -21,26 +21,10 @@
#
!
[
feature
(
raw
)]
#
!
[
feature
(
raw
)]
pub
use
ffi
as
rocksdb_ffi
;
pub
use
ffi
as
rocksdb_ffi
;
pub
use
ffi
::{
pub
use
ffi
::{
new_bloom_filter
,
RocksDBCompactionStyle
,
RocksDBComparator
};
new_bloom_filter
,
pub
use
rocksdb
::{
RocksDB
,
RocksDBResult
,
RocksDBVector
,
WriteBatch
,
Writable
,
Direction
};
RocksDBCompactionStyle
,
pub
use
rocksdb_options
::{
Options
,
BlockBasedOptions
};
RocksDBComparator
,
pub
use
merge_operator
::
MergeOperands
;
};
pub
use
rocksdb
::{
RocksDB
,
RocksDBResult
,
RocksDBVector
,
WriteBatch
,
Writable
,
Direction
,
};
pub
use
rocksdb_options
::{
Options
,
BlockBasedOptions
,
};
pub
use
merge_operator
::{
MergeOperands
,
};
pub
mod
rocksdb
;
pub
mod
rocksdb
;
pub
mod
ffi
;
pub
mod
ffi
;
pub
mod
rocksdb_options
;
pub
mod
rocksdb_options
;
...
...
src/merge_operator.rs
View file @
269c5712
...
@@ -20,12 +20,12 @@ use std::mem;
...
@@ -20,12 +20,12 @@ use std::mem;
use
std
::
ptr
;
use
std
::
ptr
;
use
std
::
slice
;
use
std
::
slice
;
use
rocksdb_options
::
{
Options
}
;
use
rocksdb_options
::
Options
;
use
rocksdb
::{
RocksDB
,
RocksDBResult
,
RocksDBVector
,
Writable
};
use
rocksdb
::{
RocksDB
,
RocksDBResult
,
RocksDBVector
,
Writable
};
pub
struct
MergeOperatorCallback
{
pub
struct
MergeOperatorCallback
{
pub
name
:
CString
,
pub
name
:
CString
,
pub
merge_fn
:
fn
(
&
[
u8
],
Option
<&
[
u8
]
>
,
&
mut
MergeOperands
)
->
Vec
<
u8
>
,
pub
merge_fn
:
fn
(
&
[
u8
],
Option
<&
[
u8
]
>
,
&
mut
MergeOperands
)
->
Vec
<
u8
>
,
}
}
pub
extern
"C"
fn
destructor_callback
(
raw_cb
:
*
mut
c_void
)
{
pub
extern
"C"
fn
destructor_callback
(
raw_cb
:
*
mut
c_void
)
{
...
@@ -43,12 +43,17 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char {
...
@@ -43,12 +43,17 @@ pub extern "C" fn name_callback(raw_cb: *mut c_void) -> *const c_char {
}
}
}
}
pub
extern
"C"
fn
full_merge_callback
(
pub
extern
"C"
fn
full_merge_callback
(
raw_cb
:
*
mut
c_void
,
raw_cb
:
*
mut
c_void
,
raw_key
:
*
const
c_char
,
key_len
:
size_t
,
raw_key
:
*
const
c_char
,
existing_value
:
*
const
c_char
,
existing_value_len
:
size_t
,
key_len
:
size_t
,
operands_list
:
*
const
*
const
c_char
,
operands_list_len
:
*
const
size_t
,
existing_value
:
*
const
c_char
,
num_operands
:
c_int
,
existing_value_len
:
size_t
,
success
:
*
mut
u8
,
new_value_length
:
*
mut
size_t
)
->
*
const
c_char
{
operands_list
:
*
const
*
const
c_char
,
operands_list_len
:
*
const
size_t
,
num_operands
:
c_int
,
success
:
*
mut
u8
,
new_value_length
:
*
mut
size_t
)
->
*
const
c_char
{
unsafe
{
unsafe
{
let
cb
:
&
mut
MergeOperatorCallback
=
let
cb
:
&
mut
MergeOperatorCallback
=
&
mut
*
(
raw_cb
as
*
mut
MergeOperatorCallback
);
&
mut
*
(
raw_cb
as
*
mut
MergeOperatorCallback
);
...
@@ -72,11 +77,15 @@ pub extern "C" fn full_merge_callback(
...
@@ -72,11 +77,15 @@ pub extern "C" fn full_merge_callback(
}
}
}
}
pub
extern
"C"
fn
partial_merge_callback
(
pub
extern
"C"
fn
partial_merge_callback
(
raw_cb
:
*
mut
c_void
,
raw_cb
:
*
mut
c_void
,
raw_key
:
*
const
c_char
,
key_len
:
size_t
,
raw_key
:
*
const
c_char
,
operands_list
:
*
const
*
const
c_char
,
operands_list_len
:
*
const
size_t
,
key_len
:
size_t
,
num_operands
:
c_int
,
operands_list
:
*
const
*
const
c_char
,
success
:
*
mut
u8
,
new_value_length
:
*
mut
size_t
)
->
*
const
c_char
{
operands_list_len
:
*
const
size_t
,
num_operands
:
c_int
,
success
:
*
mut
u8
,
new_value_length
:
*
mut
size_t
)
->
*
const
c_char
{
unsafe
{
unsafe
{
let
cb
:
&
mut
MergeOperatorCallback
=
let
cb
:
&
mut
MergeOperatorCallback
=
&
mut
*
(
raw_cb
as
*
mut
MergeOperatorCallback
);
&
mut
*
(
raw_cb
as
*
mut
MergeOperatorCallback
);
...
@@ -107,7 +116,8 @@ pub struct MergeOperands {
...
@@ -107,7 +116,8 @@ pub struct MergeOperands {
impl
MergeOperands
{
impl
MergeOperands
{
fn
new
(
operands_list
:
*
const
*
const
c_char
,
fn
new
(
operands_list
:
*
const
*
const
c_char
,
operands_list_len
:
*
const
size_t
,
operands_list_len
:
*
const
size_t
,
num_operands
:
c_int
)
->
MergeOperands
{
num_operands
:
c_int
)
->
MergeOperands
{
assert
!
(
num_operands
>=
0
);
assert
!
(
num_operands
>=
0
);
MergeOperands
{
MergeOperands
{
operands_list
:
operands_list
,
operands_list
:
operands_list
,
...
@@ -148,8 +158,10 @@ impl<'a> Iterator for &'a mut MergeOperands {
...
@@ -148,8 +158,10 @@ impl<'a> Iterator for &'a mut MergeOperands {
}
}
}
}
fn
test_provided_merge
(
new_key
:
&
[
u8
],
existing_val
:
Option
<&
[
u8
]
>
,
fn
test_provided_merge
(
new_key
:
&
[
u8
],
mut
operands
:
&
mut
MergeOperands
)
->
Vec
<
u8
>
{
existing_val
:
Option
<&
[
u8
]
>
,
mut
operands
:
&
mut
MergeOperands
)
->
Vec
<
u8
>
{
let
nops
=
operands
.size_hint
()
.
0
;
let
nops
=
operands
.size_hint
()
.
0
;
let
mut
result
:
Vec
<
u8
>
=
Vec
::
with_capacity
(
nops
);
let
mut
result
:
Vec
<
u8
>
=
Vec
::
with_capacity
(
nops
);
match
existing_val
{
match
existing_val
{
...
...
src/rocksdb.rs
View file @
269c5712
...
@@ -46,14 +46,16 @@ pub struct Snapshot<'a> {
...
@@ -46,14 +46,16 @@ pub struct Snapshot<'a> {
}
}
pub
struct
DBIterator
{
pub
struct
DBIterator
{
//TODO: should have a reference to DB to enforce scope, but it's trickier than I thought to add
// TODO: should have a reference to DB to enforce scope, but it's trickier than I
// thought to add
inner
:
rocksdb_ffi
::
RocksDBIterator
,
inner
:
rocksdb_ffi
::
RocksDBIterator
,
direction
:
Direction
,
direction
:
Direction
,
just_seeked
:
bool
just_seeked
:
bool
,
}
}
pub
enum
Direction
{
pub
enum
Direction
{
forward
,
reverse
forward
,
reverse
,
}
}
pub
struct
SubDBIterator
<
'a
>
{
pub
struct
SubDBIterator
<
'a
>
{
...
@@ -64,7 +66,7 @@ pub struct SubDBIterator<'a> {
...
@@ -64,7 +66,7 @@ pub struct SubDBIterator<'a> {
impl
<
'a
>
Iterator
for
SubDBIterator
<
'a
>
{
impl
<
'a
>
Iterator
for
SubDBIterator
<
'a
>
{
type
Item
=
(
&
'a
[
u8
],
&
'a
[
u8
]);
type
Item
=
(
&
'a
[
u8
],
&
'a
[
u8
]);
fn
next
(
&
mut
self
)
->
Option
<
(
&
'a
[
u8
],
&
'a
[
u8
])
>
{
fn
next
(
&
mut
self
)
->
Option
<
(
&
'a
[
u8
],
&
'a
[
u8
])
>
{
let
native_iter
=
self
.iter.inner
;
let
native_iter
=
self
.iter.inner
;
if
!
self
.iter.just_seeked
{
if
!
self
.iter.just_seeked
{
match
self
.direction
{
match
self
.direction
{
...
@@ -91,7 +93,7 @@ impl <'a> Iterator for SubDBIterator<'a> {
...
@@ -91,7 +93,7 @@ impl <'a> Iterator for SubDBIterator<'a> {
}
}
impl
DBIterator
{
impl
DBIterator
{
//TODO alias db & opts to different lifetimes, and DBIterator to the db's lifetime
//TODO alias db & opts to different lifetimes, and DBIterator to the db's lifetime
fn
new
(
db
:
&
RocksDB
,
readopts
:
&
ReadOptions
)
->
DBIterator
{
fn
new
(
db
:
&
RocksDB
,
readopts
:
&
ReadOptions
)
->
DBIterator
{
unsafe
{
unsafe
{
let
iterator
=
rocksdb_ffi
::
rocksdb_create_iterator
(
db
.inner
,
readopts
.inner
);
let
iterator
=
rocksdb_ffi
::
rocksdb_create_iterator
(
db
.inner
,
readopts
.inner
);
...
@@ -105,7 +107,7 @@ impl DBIterator {
...
@@ -105,7 +107,7 @@ impl DBIterator {
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_iter_seek_to_first
(
self
.inner
);
rocksdb_ffi
::
rocksdb_iter_seek_to_first
(
self
.inner
);
};
};
SubDBIterator
{
iter
:
self
,
direction
:
Direction
::
forward
,
}
SubDBIterator
{
iter
:
self
,
direction
:
Direction
::
forward
}
}
}
pub
fn
from_end
(
&
mut
self
)
->
SubDBIterator
{
pub
fn
from_end
(
&
mut
self
)
->
SubDBIterator
{
...
@@ -113,7 +115,7 @@ impl DBIterator {
...
@@ -113,7 +115,7 @@ impl DBIterator {
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_iter_seek_to_last
(
self
.inner
);
rocksdb_ffi
::
rocksdb_iter_seek_to_last
(
self
.inner
);
};
};
SubDBIterator
{
iter
:
self
,
direction
:
Direction
::
reverse
,
}
SubDBIterator
{
iter
:
self
,
direction
:
Direction
::
reverse
}
}
}
pub
fn
from
(
&
mut
self
,
key
:
&
[
u8
],
dir
:
Direction
)
->
SubDBIterator
{
pub
fn
from
(
&
mut
self
,
key
:
&
[
u8
],
dir
:
Direction
)
->
SubDBIterator
{
...
@@ -121,7 +123,7 @@ impl DBIterator {
...
@@ -121,7 +123,7 @@ impl DBIterator {
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_iter_seek
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
);
rocksdb_ffi
::
rocksdb_iter_seek
(
self
.inner
,
key
.as_ptr
(),
key
.len
()
as
size_t
);
}
}
SubDBIterator
{
iter
:
self
,
direction
:
dir
,
}
SubDBIterator
{
iter
:
self
,
direction
:
dir
}
}
}
}
}
...
@@ -136,7 +138,7 @@ impl Drop for DBIterator {
...
@@ -136,7 +138,7 @@ impl Drop for DBIterator {
impl
<
'a
>
Snapshot
<
'a
>
{
impl
<
'a
>
Snapshot
<
'a
>
{
pub
fn
new
(
db
:
&
RocksDB
)
->
Snapshot
{
pub
fn
new
(
db
:
&
RocksDB
)
->
Snapshot
{
let
snapshot
=
unsafe
{
rocksdb_ffi
::
rocksdb_create_snapshot
(
db
.inner
)
};
let
snapshot
=
unsafe
{
rocksdb_ffi
::
rocksdb_create_snapshot
(
db
.inner
)
};
Snapshot
{
db
:
db
,
inner
:
snapshot
}
Snapshot
{
db
:
db
,
inner
:
snapshot
}
}
}
pub
fn
iterator
(
&
self
)
->
DBIterator
{
pub
fn
iterator
(
&
self
)
->
DBIterator
{
...
@@ -179,8 +181,9 @@ impl RocksDB {
...
@@ -179,8 +181,9 @@ impl RocksDB {
pub
fn
open
(
opts
:
&
Options
,
path
:
&
str
)
->
Result
<
RocksDB
,
String
>
{
pub
fn
open
(
opts
:
&
Options
,
path
:
&
str
)
->
Result
<
RocksDB
,
String
>
{
let
cpath
=
match
CString
::
new
(
path
.as_bytes
())
{
let
cpath
=
match
CString
::
new
(
path
.as_bytes
())
{
Ok
(
c
)
=>
c
,
Ok
(
c
)
=>
c
,
Err
(
_
)
=>
return
Err
(
"Failed to convert path to CString when opening rocksdb"
.to_string
()),
Err
(
_
)
=>
return
Err
(
"Failed to convert path to CString when opening rocksdb"
.to_string
()),
};
};
let
cpath_ptr
=
cpath
.as_ptr
();
let
cpath_ptr
=
cpath
.as_ptr
();
...
@@ -207,7 +210,7 @@ impl RocksDB {
...
@@ -207,7 +210,7 @@ impl RocksDB {
if
db_ptr
.is_null
()
{
if
db_ptr
.is_null
()
{
return
Err
(
"Could not initialize database."
.to_string
());
return
Err
(
"Could not initialize database."
.to_string
());
}
}
Ok
(
RocksDB
{
inner
:
db
})
Ok
(
RocksDB
{
inner
:
db
})
}
}
pub
fn
destroy
(
opts
:
&
Options
,
path
:
&
str
)
->
Result
<
(),
String
>
{
pub
fn
destroy
(
opts
:
&
Options
,
path
:
&
str
)
->
Result
<
(),
String
>
{
...
@@ -357,7 +360,7 @@ impl WriteBatch {
...
@@ -357,7 +360,7 @@ impl WriteBatch {
WriteBatch
{
WriteBatch
{
inner
:
unsafe
{
inner
:
unsafe
{
rocksdb_ffi
::
rocksdb_writebatch_create
()
rocksdb_ffi
::
rocksdb_writebatch_create
()
}
}
,
}
}
}
}
}
}
...
@@ -418,8 +421,9 @@ impl ReadOptions {
...
@@ -418,8 +421,9 @@ impl ReadOptions {
ReadOptions
{
inner
:
rocksdb_ffi
::
rocksdb_readoptions_create
()}
ReadOptions
{
inner
:
rocksdb_ffi
::
rocksdb_readoptions_create
()}
}
}
}
}
//TODO add snapshot setting here
// TODO add snapshot setting here
//TODO add snapshot wrapper structs with proper destructors; that struct needs an "iterator" impl too.
// TODO add snapshot wrapper structs with proper destructors;
// that struct needs an "iterator" impl too.
fn
fill_cache
(
&
mut
self
,
v
:
bool
)
{
fn
fill_cache
(
&
mut
self
,
v
:
bool
)
{
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_readoptions_set_fill_cache
(
self
.inner
,
v
);
rocksdb_ffi
::
rocksdb_readoptions_set_fill_cache
(
self
.inner
,
v
);
...
@@ -504,7 +508,7 @@ impl <T, E> RocksDBResult<T, E> {
...
@@ -504,7 +508,7 @@ impl <T, E> RocksDBResult<T, E> {
}
}
}
}
pub
fn
on_absent
<
F
:
FnOnce
()
->
()
>
(
self
,
f
:
F
)
->
RocksDBResult
<
T
,
E
>
{
pub
fn
on_absent
<
F
:
FnOnce
()
->
()
>
(
self
,
f
:
F
)
->
RocksDBResult
<
T
,
E
>
{
match
self
{
match
self
{
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
Some
(
x
)
=>
RocksDBResult
::
Some
(
x
),
RocksDBResult
::
None
=>
{
RocksDBResult
::
None
=>
{
...
...
src/rocksdb_options.rs
View file @
269c5712
...
@@ -19,8 +19,8 @@ use std::ffi::CString;
...
@@ -19,8 +19,8 @@ use std::ffi::CString;
use
std
::
mem
;
use
std
::
mem
;
use
rocksdb_ffi
;
use
rocksdb_ffi
;
use
merge_operator
::{
self
,
MergeOperatorCallback
,
MergeOperands
,
full_merge_callback
,
use
merge_operator
::{
self
,
MergeOperatorCallback
,
MergeOperands
,
partial_merge_callback
};
full_merge_callback
,
partial_merge_callback
};
use
comparator
::{
self
,
ComparatorCallback
,
compare_callback
};
use
comparator
::{
self
,
ComparatorCallback
,
compare_callback
};
pub
struct
BlockBasedOptions
{
pub
struct
BlockBasedOptions
{
...
@@ -54,7 +54,7 @@ impl BlockBasedOptions {
...
@@ -54,7 +54,7 @@ impl BlockBasedOptions {
if
opt_ptr
.is_null
()
{
if
opt_ptr
.is_null
()
{
panic!
(
"Could not create rocksdb block based options"
.to_string
());
panic!
(
"Could not create rocksdb block based options"
.to_string
());
}
}
BlockBasedOptions
{
inner
:
block_opts
,
}
BlockBasedOptions
{
inner
:
block_opts
}
}
}
pub
fn
set_block_size
(
&
mut
self
,
size
:
u64
)
{
pub
fn
set_block_size
(
&
mut
self
,
size
:
u64
)
{
...
@@ -107,8 +107,7 @@ impl Options {
...
@@ -107,8 +107,7 @@ impl Options {
}
}
}
}
pub
fn
optimize_level_style_compaction
(
&
mut
self
,
pub
fn
optimize_level_style_compaction
(
&
mut
self
,
memtable_memory_budget
:
i32
)
{
memtable_memory_budget
:
i32
)
{
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_options_optimize_level_style_compaction
(
rocksdb_ffi
::
rocksdb_options_optimize_level_style_compaction
(
self
.inner
,
memtable_memory_budget
);
self
.inner
,
memtable_memory_budget
);
...
@@ -122,8 +121,9 @@ impl Options {
...
@@ -122,8 +121,9 @@ impl Options {
}
}
}
}
pub
fn
add_merge_operator
<
'a
>
(
&
mut
self
,
name
:
&
str
,
pub
fn
add_merge_operator
<
'a
>
(
&
mut
self
,
merge_fn
:
fn
(
&
[
u8
],
Option
<&
[
u8
]
>
,
&
mut
MergeOperands
)
->
Vec
<
u8
>
)
{
name
:
&
str
,
merge_fn
:
fn
(
&
[
u8
],
Option
<&
[
u8
]
>
,
&
mut
MergeOperands
)
->
Vec
<
u8
>
)
{
let
cb
=
Box
::
new
(
MergeOperatorCallback
{
let
cb
=
Box
::
new
(
MergeOperatorCallback
{
name
:
CString
::
new
(
name
.as_bytes
())
.unwrap
(),
name
:
CString
::
new
(
name
.as_bytes
())
.unwrap
(),
merge_fn
:
merge_fn
,
merge_fn
:
merge_fn
,
...
@@ -258,8 +258,7 @@ impl Options {
...
@@ -258,8 +258,7 @@ impl Options {
}
}
}
}
pub
fn
set_compaction_style
(
&
mut
self
,
style
:
pub
fn
set_compaction_style
(
&
mut
self
,
style
:
rocksdb_ffi
::
RocksDBCompactionStyle
)
{
rocksdb_ffi
::
RocksDBCompactionStyle
)
{
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_options_set_compaction_style
(
rocksdb_ffi
::
rocksdb_options_set_compaction_style
(
self
.inner
,
style
);
self
.inner
,
style
);
...
@@ -306,5 +305,3 @@ impl Options {
...
@@ -306,5 +305,3 @@ impl Options {
}
}
}
}
}
}
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