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
cb11b928
Commit
cb11b928
authored
Jul 11, 2016
by
zhangjinpeng1987
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/ngaut/rust-rocksdb
parents
2aebd37e
ebf9de0f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
16 deletions
+25
-16
lib.rs
src/lib.rs
+2
-2
main.rs
src/main.rs
+9
-8
rocksdb.rs
src/rocksdb.rs
+0
-0
rocksdb_options.rs
src/rocksdb_options.rs
+6
-3
test_column_family.rs
test/test_column_family.rs
+8
-3
No files found.
src/lib.rs
View file @
cb11b928
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
// 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.
//
//
#
!
[
feature
(
plugin
)]
extern
crate
libc
;
extern
crate
libc
;
...
@@ -27,6 +26,7 @@ pub mod comparator;
...
@@ -27,6 +26,7 @@ pub mod comparator;
pub
use
librocksdb_sys
::{
DBCompactionStyle
,
DBComparator
,
DBCompressionType
,
pub
use
librocksdb_sys
::{
DBCompactionStyle
,
DBComparator
,
DBCompressionType
,
new_bloom_filter
,
self
as
rocksdb_ffi
};
new_bloom_filter
,
self
as
rocksdb_ffi
};
pub
use
rocksdb
::{
DB
,
DBIterator
,
DBVector
,
Kv
,
SeekKey
,
Writable
,
WriteBatch
,
ReadOptions
};
pub
use
rocksdb
::{
DB
,
DBIterator
,
DBVector
,
Kv
,
ReadOptions
,
SeekKey
,
Writable
,
WriteBatch
};
pub
use
rocksdb_options
::{
BlockBasedOptions
,
Options
,
WriteOptions
};
pub
use
rocksdb_options
::{
BlockBasedOptions
,
Options
,
WriteOptions
};
pub
use
merge_operator
::
MergeOperands
;
pub
use
merge_operator
::
MergeOperands
;
src/main.rs
View file @
cb11b928
...
@@ -143,7 +143,7 @@ fn main() {
...
@@ -143,7 +143,7 @@ fn main() {
#[cfg(test)]
#[cfg(test)]
mod
tests
{
mod
tests
{
use
rocksdb
::{
BlockBasedOptions
,
DB
,
Options
,
DBCompressionType
};
use
rocksdb
::{
BlockBasedOptions
,
DB
,
DBCompressionType
,
Options
};
use
rocksdb
::
DBCompactionStyle
::
DBUniversal
;
use
rocksdb
::
DBCompactionStyle
::
DBUniversal
;
#[allow(dead_code)]
#[allow(dead_code)]
...
@@ -151,13 +151,14 @@ mod tests {
...
@@ -151,13 +151,14 @@ mod tests {
opts
:
&
mut
Options
,
opts
:
&
mut
Options
,
blockopts
:
&
mut
BlockBasedOptions
)
blockopts
:
&
mut
BlockBasedOptions
)
->
DB
{
->
DB
{
let
per_level_compression
:
[
DBCompressionType
;
7
]
=
[
DBCompressionType
::
DBNo
,
let
per_level_compression
:
[
DBCompressionType
;
7
]
=
DBCompressionType
::
DBNo
,
[
DBCompressionType
::
DBNo
,
DBCompressionType
::
DBNo
,
DBCompressionType
::
DBNo
,
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBNo
,
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBLz4
];
DBCompressionType
::
DBLz4
,
DBCompressionType
::
DBLz4
];
opts
.create_if_missing
(
true
);
opts
.create_if_missing
(
true
);
opts
.set_max_open_files
(
10000
);
opts
.set_max_open_files
(
10000
);
...
...
src/rocksdb.rs
View file @
cb11b928
This diff is collapsed.
Click to expand it.
src/rocksdb_options.rs
View file @
cb11b928
...
@@ -193,7 +193,8 @@ impl Options {
...
@@ -193,7 +193,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
{
rocksdb_ffi
::
rocksdb_options_set_compression_per_level
(
self
.inner
,
rocksdb_ffi
::
rocksdb_options_set_compression_per_level
(
self
.inner
,
level_types
.as_ptr
(),
level_types
.as_ptr
(),
...
@@ -402,9 +403,11 @@ impl Options {
...
@@ -402,9 +403,11 @@ impl Options {
pub
fn
set_report_bg_io_stats
(
&
mut
self
,
enable
:
bool
)
{
pub
fn
set_report_bg_io_stats
(
&
mut
self
,
enable
:
bool
)
{
unsafe
{
unsafe
{
if
enable
{
if
enable
{
rocksdb_ffi
::
rocksdb_options_set_report_bg_io_stats
(
self
.inner
,
1
);
rocksdb_ffi
::
rocksdb_options_set_report_bg_io_stats
(
self
.inner
,
1
);
}
else
{
}
else
{
rocksdb_ffi
::
rocksdb_options_set_report_bg_io_stats
(
self
.inner
,
0
);
rocksdb_ffi
::
rocksdb_options_set_report_bg_io_stats
(
self
.inner
,
0
);
}
}
}
}
}
}
...
...
test/test_column_family.rs
View file @
cb11b928
...
@@ -33,6 +33,7 @@ pub fn test_column_family() {
...
@@ -33,6 +33,7 @@ pub fn test_column_family() {
panic!
(
"could not create column family: {}"
,
e
);
panic!
(
"could not create column family: {}"
,
e
);
}
}
}
}
assert_eq!
(
db
.cf_names
(),
vec!
[
"cf1"
,
"default"
]);
}
}
// should fail to open db without specifying same column families
// should fail to open db without specifying same column families
...
@@ -56,7 +57,7 @@ pub fn test_column_family() {
...
@@ -56,7 +57,7 @@ pub fn test_column_family() {
{
{
let
mut
opts
=
Options
::
new
();
let
mut
opts
=
Options
::
new
();
opts
.add_merge_operator
(
"test operator"
,
test_provided_merge
);
opts
.add_merge_operator
(
"test operator"
,
test_provided_merge
);
match
DB
::
open_cf
(
&
opts
,
path_str
,
&
[
"cf1"
])
{
match
DB
::
open_cf
(
&
opts
,
path_str
,
&
[
"cf1"
]
,
&
[
&
opts
]
)
{
Ok
(
_
)
=>
println!
(
"successfully opened db with column family"
),
Ok
(
_
)
=>
println!
(
"successfully opened db with column family"
),
Err
(
e
)
=>
panic!
(
"failed to open db with column family: {}"
,
e
),
Err
(
e
)
=>
panic!
(
"failed to open db with column family: {}"
,
e
),
}
}
...
@@ -65,7 +66,7 @@ pub fn test_column_family() {
...
@@ -65,7 +66,7 @@ pub fn test_column_family() {
{
{
let
mut
opts
=
Options
::
new
();
let
mut
opts
=
Options
::
new
();
opts
.add_merge_operator
(
"test operator"
,
test_provided_merge
);
opts
.add_merge_operator
(
"test operator"
,
test_provided_merge
);
let
db
=
match
DB
::
open_cf
(
&
opts
,
path_str
,
&
[
"cf1"
])
{
let
db
=
match
DB
::
open_cf
(
&
opts
,
path_str
,
&
[
"cf1"
]
,
&
[
&
opts
]
)
{
Ok
(
db
)
=>
{
Ok
(
db
)
=>
{
println!
(
"successfully opened db with column family"
);
println!
(
"successfully opened db with column family"
);
db
db
...
@@ -113,7 +114,11 @@ pub fn test_column_family() {
...
@@ -113,7 +114,11 @@ pub fn test_column_family() {
}
}
// should b able to drop a cf
// should b able to drop a cf
{
{
let
mut
db
=
DB
::
open_cf
(
&
Options
::
new
(),
path_str
,
&
[
"cf1"
])
.unwrap
();
let
mut
db
=
DB
::
open_cf
(
&
Options
::
new
(),
path_str
,
&
[
"cf1"
],
&
[
&
Options
::
new
()])
.unwrap
();
match
db
.drop_cf
(
"cf1"
)
{
match
db
.drop_cf
(
"cf1"
)
{
Ok
(
_
)
=>
println!
(
"cf1 successfully dropped."
),
Ok
(
_
)
=>
println!
(
"cf1 successfully dropped."
),
Err
(
e
)
=>
panic!
(
"failed to drop column family: {}"
,
e
),
Err
(
e
)
=>
panic!
(
"failed to drop column family: {}"
,
e
),
...
...
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