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
7ad71128
Commit
7ad71128
authored
Jul 06, 2017
by
Cholerae Hu
Committed by
zhangjinpeng1987
Jul 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rocksdb: add supported_compression function (#88)
parent
40b2408f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
1 deletion
+48
-1
c.cc
librocksdb_sys/crocksdb/c.cc
+12
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+3
-0
lib.rs
librocksdb_sys/src/lib.rs
+3
-0
rocksdb.rs
src/rocksdb.rs
+30
-1
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
7ad71128
...
@@ -2947,6 +2947,18 @@ const char* crocksdb_pinnableslice_value(const crocksdb_pinnableslice_t* v,
...
@@ -2947,6 +2947,18 @@ const char* crocksdb_pinnableslice_value(const crocksdb_pinnableslice_t* v,
return
v
->
rep
.
data
();
return
v
->
rep
.
data
();
}
}
size_t
crocksdb_get_supported_compression_number
()
{
return
rocksdb
::
GetSupportedCompressions
().
size
();
}
void
crocksdb_get_supported_compression
(
int
*
v
,
size_t
l
)
{
auto
compressions
=
rocksdb
::
GetSupportedCompressions
();
assert
(
compressions
.
size
()
==
l
);
for
(
size_t
i
=
0
;
i
<
compressions
.
size
();
i
++
)
{
v
[
i
]
=
static_cast
<
int
>
(
compressions
[
i
]);
}
}
/* Table Properties */
/* Table Properties */
struct
crocksdb_user_collected_properties_t
{
struct
crocksdb_user_collected_properties_t
{
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
7ad71128
...
@@ -1218,6 +1218,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_pinnableslice_destroy(
...
@@ -1218,6 +1218,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_pinnableslice_destroy(
extern
C_ROCKSDB_LIBRARY_API
const
char
*
crocksdb_pinnableslice_value
(
extern
C_ROCKSDB_LIBRARY_API
const
char
*
crocksdb_pinnableslice_value
(
const
crocksdb_pinnableslice_t
*
t
,
size_t
*
vlen
);
const
crocksdb_pinnableslice_t
*
t
,
size_t
*
vlen
);
extern
C_ROCKSDB_LIBRARY_API
size_t
crocksdb_get_supported_compression_number
();
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_get_supported_compression
(
int
*
,
size_t
);
/* Table Properties */
/* Table Properties */
extern
C_ROCKSDB_LIBRARY_API
crocksdb_table_properties_t
*
extern
C_ROCKSDB_LIBRARY_API
crocksdb_table_properties_t
*
...
...
librocksdb_sys/src/lib.rs
View file @
7ad71128
...
@@ -82,6 +82,7 @@ pub enum DBCompressionType {
...
@@ -82,6 +82,7 @@ pub enum DBCompressionType {
DBLz4hc
=
5
,
DBLz4hc
=
5
,
// DBXpress = 6, not support currently.
// DBXpress = 6, not support currently.
DBZstd
=
7
,
DBZstd
=
7
,
DBZstdNotFinal
=
0x40
,
}
}
#[repr(C)]
#[repr(C)]
...
@@ -852,6 +853,8 @@ extern "C" {
...
@@ -852,6 +853,8 @@ extern "C" {
valLen
:
*
mut
size_t
)
valLen
:
*
mut
size_t
)
->
*
const
u8
;
->
*
const
u8
;
pub
fn
crocksdb_pinnableslice_destroy
(
v
:
*
mut
DBPinnableSlice
);
pub
fn
crocksdb_pinnableslice_destroy
(
v
:
*
mut
DBPinnableSlice
);
pub
fn
crocksdb_get_supported_compression_number
()
->
size_t
;
pub
fn
crocksdb_get_supported_compression
(
v
:
*
mut
DBCompressionType
,
l
:
size_t
);
pub
fn
crocksdb_user_collected_properties_add
(
props
:
*
mut
DBUserCollectedProperties
,
pub
fn
crocksdb_user_collected_properties_add
(
props
:
*
mut
DBUserCollectedProperties
,
key
:
*
const
uint8_t
,
key
:
*
const
uint8_t
,
...
...
src/rocksdb.rs
View file @
7ad71128
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
//
//
use
crocksdb_ffi
::{
self
,
DBWriteBatch
,
DBCFHandle
,
DBInstance
,
DBBackupEngine
,
use
crocksdb_ffi
::{
self
,
DBWriteBatch
,
DBCFHandle
,
DBInstance
,
DBBackupEngine
,
DBStatisticsTickerType
,
DBStatisticsHistogramType
,
DBPinnableSlice
};
DBStatisticsTickerType
,
DBStatisticsHistogramType
,
DBPinnableSlice
,
DBCompressionType
};
use
libc
::{
self
,
c_int
,
c_void
,
size_t
};
use
libc
::{
self
,
c_int
,
c_void
,
size_t
};
use
rocksdb_options
::{
Options
,
ReadOptions
,
UnsafeSnap
,
WriteOptions
,
FlushOptions
,
EnvOptions
,
use
rocksdb_options
::{
Options
,
ReadOptions
,
UnsafeSnap
,
WriteOptions
,
FlushOptions
,
EnvOptions
,
RestoreOptions
,
IngestExternalFileOptions
,
HistogramData
,
CompactOptions
};
RestoreOptions
,
IngestExternalFileOptions
,
HistogramData
,
CompactOptions
};
...
@@ -1459,6 +1460,17 @@ impl Drop for SstFileWriter {
...
@@ -1459,6 +1460,17 @@ impl Drop for SstFileWriter {
}
}
}
}
pub
fn
supported_compression
()
->
Vec
<
DBCompressionType
>
{
unsafe
{
let
size
=
crocksdb_ffi
::
crocksdb_get_supported_compression_number
()
as
usize
;
let
mut
v
:
Vec
<
DBCompressionType
>
=
Vec
::
with_capacity
(
size
);
let
pv
=
v
.as_mut_ptr
();
crocksdb_ffi
::
crocksdb_get_supported_compression
(
pv
,
size
as
size_t
);
v
.set_len
(
size
);
v
}
}
#[cfg(test)]
#[cfg(test)]
mod
test
{
mod
test
{
use
std
::
fs
;
use
std
::
fs
;
...
@@ -1889,4 +1901,21 @@ mod test {
...
@@ -1889,4 +1901,21 @@ mod test {
.unwrap
();
.unwrap
();
assert
!
(
total_sst_files_size
>
0
);
assert
!
(
total_sst_files_size
>
0
);
}
}
#[test]
fn
test_supported_compression
()
{
let
mut
com
=
supported_compression
();
let
len_before
=
com
.len
();
assert
!
(
com
.len
()
!=
0
);
com
.dedup
();
assert_eq!
(
len_before
,
com
.len
());
for
c
in
com
{
println!
(
"{:?}"
,
c
);
println!
(
"{}"
,
c
as
u32
);
match
c
as
u32
{
0
...
5
|
7
|
0x40
=>
assert
!
(
true
),
_
=>
assert
!
(
false
),
}
}
}
}
}
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