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
9b78173e
Commit
9b78173e
authored
Aug 01, 2016
by
zhangjinpeng1987
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comments
parent
e951a51d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
22 deletions
+11
-22
lib.rs
src/lib.rs
+1
-1
main.rs
src/main.rs
+2
-3
rocksdb_options.rs
src/rocksdb_options.rs
+8
-18
No files found.
src/lib.rs
View file @
9b78173e
...
...
@@ -28,5 +28,5 @@ pub use librocksdb_sys::{DBCompactionStyle, DBComparator, DBCompressionType,
new_bloom_filter
,
self
as
rocksdb_ffi
};
pub
use
rocksdb
::{
DB
,
DBIterator
,
DBVector
,
Kv
,
ReadOptions
,
SeekKey
,
Writable
,
WriteBatch
};
pub
use
rocksdb_options
::{
BlockBasedOptions
,
Options
,
WriteOptions
,
FilterPolicy
};
pub
use
rocksdb_options
::{
BlockBasedOptions
,
Options
,
WriteOptions
};
pub
use
merge_operator
::
MergeOperands
;
src/main.rs
View file @
9b78173e
...
...
@@ -143,7 +143,7 @@ fn main() {
#[cfg(test)]
mod
tests
{
use
rocksdb
::{
BlockBasedOptions
,
DB
,
DBCompressionType
,
Options
,
FilterPolicy
};
use
rocksdb
::{
BlockBasedOptions
,
DB
,
DBCompressionType
,
Options
};
use
rocksdb
::
DBCompactionStyle
::
DBUniversal
;
#[allow(dead_code)]
...
...
@@ -181,8 +181,7 @@ mod tests {
opts
.compression_per_level
(
&
per_level_compression
);
blockopts
.set_block_size
(
524288
);
blockopts
.set_cache_index_and_filter_blocks
(
true
);
let
bloom_filter
=
FilterPolicy
::
new_bloom_filter
(
10
,
false
);
blockopts
.set_filter_policy
(
bloom_filter
);
blockopts
.set_bloom_filter
(
10
,
false
);
opts
.set_block_based_table_factory
(
blockopts
);
opts
.set_disable_auto_compactions
(
true
);
...
...
src/rocksdb_options.rs
View file @
9b78173e
...
...
@@ -22,10 +22,6 @@ use merge_operator::{self, MergeOperatorCallback, full_merge_callback,
use
comparator
::{
self
,
ComparatorCallback
,
compare_callback
};
use
merge_operator
::
MergeFn
;
pub
struct
FilterPolicy
{
inner
:
rocksdb_ffi
::
DBFilterPolicy
,
}
pub
struct
BlockBasedOptions
{
inner
:
rocksdb_ffi
::
DBBlockBasedTableOptions
,
}
...
...
@@ -74,18 +70,6 @@ impl Default for BlockBasedOptions {
}
}
impl
FilterPolicy
{
pub
fn
new_bloom_filter
(
bits_per_key
:
c_int
,
block_based
:
bool
)
->
FilterPolicy
{
let
filter
=
if
block_based
{
unsafe
{
rocksdb_ffi
::
rocksdb_filterpolicy_create_bloom
(
bits_per_key
)
}
}
else
{
unsafe
{
rocksdb_ffi
::
rocksdb_filterpolicy_create_bloom_full
(
bits_per_key
)
}
};
FilterPolicy
{
inner
:
filter
}
}
}
impl
BlockBasedOptions
{
pub
fn
new
()
->
BlockBasedOptions
{
BlockBasedOptions
::
default
()
...
...
@@ -107,10 +91,16 @@ impl BlockBasedOptions {
}
}
pub
fn
set_
filter_policy
(
&
mut
self
,
filter
:
FilterPolicy
)
{
pub
fn
set_
bloom_filter
(
&
mut
self
,
bits_per_key
:
c_int
,
block_based
:
bool
)
{
unsafe
{
let
bloom
=
if
block_based
{
rocksdb_ffi
::
rocksdb_filterpolicy_create_bloom
(
bits_per_key
)
}
else
{
rocksdb_ffi
::
rocksdb_filterpolicy_create_bloom_full
(
bits_per_key
)
};
rocksdb_ffi
::
rocksdb_block_based_options_set_filter_policy
(
self
.inner
,
filter
.inner
);
bloom
);
}
}
...
...
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