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
c712a98e
Commit
c712a98e
authored
Jul 28, 2016
by
zhangjinpeng1987
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make filter policy live as long as BlockBasedOptions
parent
c61e7a89
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
main.rs
src/main.rs
+1
-1
rocksdb_options.rs
src/rocksdb_options.rs
+8
-3
No files found.
src/main.rs
View file @
c712a98e
...
@@ -182,7 +182,7 @@ mod tests {
...
@@ -182,7 +182,7 @@ mod tests {
blockopts
.set_block_size
(
524288
);
blockopts
.set_block_size
(
524288
);
blockopts
.set_cache_index_and_filter_blocks
(
true
);
blockopts
.set_cache_index_and_filter_blocks
(
true
);
let
bloom_filter
=
FilterPolicy
::
new_bloom_filter
(
10
,
false
);
let
bloom_filter
=
FilterPolicy
::
new_bloom_filter
(
10
,
false
);
blockopts
.set_filter_policy
(
&
bloom_filter
);
blockopts
.set_filter_policy
(
bloom_filter
);
opts
.set_block_based_table_factory
(
blockopts
);
opts
.set_block_based_table_factory
(
blockopts
);
opts
.set_disable_auto_compactions
(
true
);
opts
.set_disable_auto_compactions
(
true
);
...
...
src/rocksdb_options.rs
View file @
c712a98e
...
@@ -28,6 +28,10 @@ pub struct FilterPolicy {
...
@@ -28,6 +28,10 @@ pub struct FilterPolicy {
pub
struct
BlockBasedOptions
{
pub
struct
BlockBasedOptions
{
inner
:
rocksdb_ffi
::
DBBlockBasedTableOptions
,
inner
:
rocksdb_ffi
::
DBBlockBasedTableOptions
,
// FilterPolicy must live as long as BlockBasedTableOptions,
// so we introduce this field
filter_policy
:
Option
<
FilterPolicy
>
,
}
}
pub
struct
Options
{
pub
struct
Options
{
...
@@ -78,7 +82,7 @@ impl Default for BlockBasedOptions {
...
@@ -78,7 +82,7 @@ impl Default for 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
,
filter_policy
:
None
}
}
}
}
}
...
@@ -115,10 +119,11 @@ impl BlockBasedOptions {
...
@@ -115,10 +119,11 @@ impl BlockBasedOptions {
}
}
}
}
pub
fn
set_filter_policy
(
&
mut
self
,
filter
:
&
FilterPolicy
)
{
pub
fn
set_filter_policy
(
&
mut
self
,
filter
:
FilterPolicy
)
{
self
.filter_policy
=
Some
(
filter
);
unsafe
{
unsafe
{
rocksdb_ffi
::
rocksdb_block_based_options_set_filter_policy
(
self
.inner
,
rocksdb_ffi
::
rocksdb_block_based_options_set_filter_policy
(
self
.inner
,
filter
.inner
);
self
.filter_policy
.as_ref
()
.unwrap
()
.inner
);
}
}
}
}
...
...
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