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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
29 deletions
+31
-29
lib.rs
librocksdb_sys/src/lib.rs
+0
-0
compaction_filter.rs
src/compaction_filter.rs
+4
-5
main.rs
src/main.rs
+1
-0
rocksdb.rs
src/rocksdb.rs
+0
-0
rocksdb_options.rs
src/rocksdb_options.rs
+26
-24
No files found.
librocksdb_sys/src/lib.rs
View file @
21516f6f
This diff is collapsed.
Click to expand it.
src/compaction_filter.rs
View file @
21516f6f
use
libc
::{
c_void
,
c_char
,
c_int
,
size_t
};
use
crocksdb_ffi
::{
self
,
DBCompactionFilter
};
use
crocksdb_ffi
::{
self
,
DBCompactionFilter
};
use
libc
::{
c_void
,
c_char
,
c_int
,
size_t
};
use
std
::
ffi
::
CString
;
use
std
::
ffi
::
CString
;
use
std
::
slice
;
use
std
::
slice
;
...
@@ -75,9 +74,9 @@ pub unsafe fn new_compaction_filter(c_name: CString,
...
@@ -75,9 +74,9 @@ pub unsafe fn new_compaction_filter(c_name: CString,
filter
:
f
,
filter
:
f
,
}));
}));
let
filter
=
crocksdb_ffi
::
crocksdb_compactionfilter_create
(
proxy
as
*
mut
c_void
,
let
filter
=
crocksdb_ffi
::
crocksdb_compactionfilter_create
(
proxy
as
*
mut
c_void
,
destructor
,
destructor
,
filter
,
filter
,
name
);
name
);
crocksdb_ffi
::
crocksdb_compactionfilter_set_ignore_snapshots
(
filter
,
ignore_snapshots
);
crocksdb_ffi
::
crocksdb_compactionfilter_set_ignore_snapshots
(
filter
,
ignore_snapshots
);
Ok
(
CompactionFilterHandle
{
inner
:
filter
})
Ok
(
CompactionFilterHandle
{
inner
:
filter
})
}
}
src/main.rs
View file @
21516f6f
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
//
//
extern
crate
rocksdb
;
extern
crate
rocksdb
;
use
rocksdb
::{
DB
,
MergeOperands
,
Options
,
Writable
};
use
rocksdb
::{
DB
,
MergeOperands
,
Options
,
Writable
};
...
...
src/rocksdb.rs
View file @
21516f6f
This diff is collapsed.
Click to expand it.
src/rocksdb_options.rs
View file @
21516f6f
...
@@ -15,13 +15,13 @@
...
@@ -15,13 +15,13 @@
use
compaction_filter
::{
CompactionFilter
,
new_compaction_filter
,
CompactionFilterHandle
};
use
compaction_filter
::{
CompactionFilter
,
new_compaction_filter
,
CompactionFilterHandle
};
use
comparator
::{
self
,
ComparatorCallback
,
compare_callback
};
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
libc
::{
self
,
c_int
,
size_t
,
c_void
};
use
merge_operator
::{
self
,
MergeOperatorCallback
,
full_merge_callback
,
partial_merge_callback
};
use
merge_operator
::{
self
,
MergeOperatorCallback
,
full_merge_callback
,
partial_merge_callback
};
use
merge_operator
::
MergeFn
;
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
::
ffi
::{
CStr
,
CString
};
use
std
::
mem
;
use
std
::
mem
;
...
@@ -154,8 +154,8 @@ impl ReadOptions {
...
@@ -154,8 +154,8 @@ impl ReadOptions {
self
.upper_bound
=
Vec
::
from
(
key
);
self
.upper_bound
=
Vec
::
from
(
key
);
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_readoptions_set_iterate_upper_bound
(
self
.inner
,
crocksdb_ffi
::
crocksdb_readoptions_set_iterate_upper_bound
(
self
.inner
,
self
.upper_bound
.as_ptr
(),
self
.upper_bound
.as_ptr
(),
self
.upper_bound
.len
());
self
.upper_bound
.len
());
}
}
}
}
...
@@ -247,7 +247,7 @@ impl Options {
...
@@ -247,7 +247,7 @@ impl Options {
pub
fn
optimize_level_style_compaction
(
&
mut
self
,
memtable_memory_budget
:
i32
)
{
pub
fn
optimize_level_style_compaction
(
&
mut
self
,
memtable_memory_budget
:
i32
)
{
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_optimize_level_style_compaction
(
self
.inner
,
crocksdb_ffi
::
crocksdb_options_optimize_level_style_compaction
(
self
.inner
,
memtable_memory_budget
);
memtable_memory_budget
);
}
}
}
}
...
@@ -277,10 +277,10 @@ impl Options {
...
@@ -277,10 +277,10 @@ impl Options {
};
};
self
.filter
=
Some
(
try!
(
new_compaction_filter
(
c_name
,
ignore_snapshots
,
filter
)));
self
.filter
=
Some
(
try!
(
new_compaction_filter
(
c_name
,
ignore_snapshots
,
filter
)));
crocksdb_ffi
::
crocksdb_options_set_compaction_filter
(
self
.inner
,
crocksdb_ffi
::
crocksdb_options_set_compaction_filter
(
self
.inner
,
self
.filter
self
.filter
.as_ref
()
.as_ref
()
.unwrap
()
.unwrap
()
.inner
);
.inner
);
Ok
(())
Ok
(())
}
}
}
}
...
@@ -300,8 +300,8 @@ impl Options {
...
@@ -300,8 +300,8 @@ impl Options {
pub
fn
compression_per_level
(
&
mut
self
,
level_types
:
&
[
DBCompressionType
])
{
pub
fn
compression_per_level
(
&
mut
self
,
level_types
:
&
[
DBCompressionType
])
{
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_compression_per_level
(
self
.inner
,
crocksdb_ffi
::
crocksdb_options_set_compression_per_level
(
self
.inner
,
level_types
.as_ptr
(),
level_types
.as_ptr
(),
level_types
.len
()
as
size_t
)
level_types
.len
()
as
size_t
)
}
}
}
}
...
@@ -312,12 +312,13 @@ impl Options {
...
@@ -312,12 +312,13 @@ impl Options {
});
});
unsafe
{
unsafe
{
let
mo
=
crocksdb_ffi
::
crocksdb_mergeoperator_create
(
mem
::
transmute
(
cb
),
let
mo
=
merge_operator
::
destructor_callback
,
crocksdb_ffi
::
crocksdb_mergeoperator_create
(
mem
::
transmute
(
cb
),
full_merge_callback
,
merge_operator
::
destructor_callback
,
partial_merge_callback
,
full_merge_callback
,
None
,
partial_merge_callback
,
merge_operator
::
name_callback
);
None
,
merge_operator
::
name_callback
);
crocksdb_ffi
::
crocksdb_options_set_merge_operator
(
self
.inner
,
mo
);
crocksdb_ffi
::
crocksdb_options_set_merge_operator
(
self
.inner
,
mo
);
}
}
}
}
...
@@ -330,9 +331,9 @@ impl Options {
...
@@ -330,9 +331,9 @@ impl Options {
unsafe
{
unsafe
{
let
cmp
=
crocksdb_ffi
::
crocksdb_comparator_create
(
mem
::
transmute
(
cb
),
let
cmp
=
crocksdb_ffi
::
crocksdb_comparator_create
(
mem
::
transmute
(
cb
),
comparator
::
destructor_callback
,
comparator
::
destructor_callback
,
compare_callback
,
compare_callback
,
comparator
::
name_callback
);
comparator
::
name_callback
);
crocksdb_ffi
::
crocksdb_options_set_comparator
(
self
.inner
,
cmp
);
crocksdb_ffi
::
crocksdb_options_set_comparator
(
self
.inner
,
cmp
);
}
}
}
}
...
@@ -432,7 +433,8 @@ impl Options {
...
@@ -432,7 +433,8 @@ impl Options {
pub
fn
set_min_write_buffer_number_to_merge
(
&
mut
self
,
to_merge
:
c_int
)
{
pub
fn
set_min_write_buffer_number_to_merge
(
&
mut
self
,
to_merge
:
c_int
)
{
unsafe
{
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 {
...
@@ -600,7 +602,7 @@ impl RestoreOptions {
pub
fn
set_keep_log_files
(
&
mut
self
,
flag
:
bool
)
{
pub
fn
set_keep_log_files
(
&
mut
self
,
flag
:
bool
)
{
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_restore_options_set_keep_log_files
(
self
.inner
,
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