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
65d4179c
Commit
65d4179c
authored
Jul 04, 2017
by
Cholerae Hu
Committed by
zhangjinpeng1987
Jul 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rocksdb: add get_compression method (#83)
parent
2321bc2c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
2 deletions
+21
-2
c.cc
librocksdb_sys/crocksdb/c.cc
+4
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+2
-0
lib.rs
librocksdb_sys/src/lib.rs
+2
-1
rocksdb_options.rs
src/rocksdb_options.rs
+4
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+9
-1
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
65d4179c
...
...
@@ -1768,6 +1768,10 @@ void crocksdb_options_set_compression(crocksdb_options_t* opt, int t) {
opt
->
rep
.
compression
=
static_cast
<
CompressionType
>
(
t
);
}
int
crocksdb_options_get_compression
(
crocksdb_options_t
*
opt
)
{
return
static_cast
<
int
>
(
opt
->
rep
.
compression
);
}
void
crocksdb_options_set_compression_per_level
(
crocksdb_options_t
*
opt
,
int
*
level_values
,
size_t
num_levels
)
{
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
65d4179c
...
...
@@ -854,6 +854,8 @@ enum {
};
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_set_compression
(
crocksdb_options_t
*
,
int
);
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_options_get_compression
(
crocksdb_options_t
*
);
enum
{
crocksdb_level_compaction
=
0
,
...
...
librocksdb_sys/src/lib.rs
View file @
65d4179c
...
...
@@ -71,7 +71,7 @@ pub enum DBEntryType {
Other
=
4
,
}
#[derive(Copy,
Clone)]
#[derive(Copy,
Clone
,
Debug,
PartialEq
)]
#[repr(C)]
pub
enum
DBCompressionType
{
DBNo
=
0
,
...
...
@@ -311,6 +311,7 @@ extern "C" {
pub
fn
crocksdb_options_set_compaction_style
(
options
:
*
mut
DBOptions
,
cs
:
DBCompactionStyle
);
pub
fn
crocksdb_options_set_compression
(
options
:
*
mut
DBOptions
,
compression_style_no
:
DBCompressionType
);
pub
fn
crocksdb_options_get_compression
(
options
:
*
mut
DBOptions
)
->
DBCompressionType
;
pub
fn
crocksdb_options_set_compression_per_level
(
options
:
*
mut
DBOptions
,
level_values
:
*
const
DBCompressionType
,
num_levels
:
size_t
);
...
...
src/rocksdb_options.rs
View file @
65d4179c
...
...
@@ -401,6 +401,10 @@ impl Options {
}
}
pub
fn
get_compression
(
&
self
)
->
DBCompressionType
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_get_compression
(
self
.inner
)
}
}
pub
fn
compression_per_level
(
&
mut
self
,
level_types
:
&
[
DBCompressionType
])
{
unsafe
{
crocksdb_ffi
::
crocksdb_options_set_compression_per_level
(
self
.inner
,
...
...
tests/test_rocksdb_options.rs
View file @
65d4179c
...
...
@@ -15,7 +15,7 @@ use rocksdb::{DB, Options, BlockBasedOptions, WriteOptions, SliceTransform, Writ
CompactOptions
};
use
rocksdb
::
crocksdb_ffi
::{
DBStatisticsHistogramType
as
HistogramType
,
DBStatisticsTickerType
as
TickerType
,
DBInfoLogLevel
as
InfoLogLevel
,
CompactionPriority
};
CompactionPriority
,
DBCompressionType
};
use
std
::
path
::
Path
;
use
std
::
thread
;
use
std
::
time
::
Duration
;
...
...
@@ -352,3 +352,11 @@ fn test_allow_concurrent_memtable_write() {
db
.put
(
format!
(
"k_{}"
,
i
)
.as_bytes
(),
b
"v"
)
.unwrap
();
}
}
#[test]
fn
test_get_compression
()
{
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.compression
(
DBCompressionType
::
DBSnappy
);
assert_eq!
(
opts
.get_compression
(),
DBCompressionType
::
DBSnappy
);
}
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