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
0fe7d360
Commit
0fe7d360
authored
Jul 01, 2017
by
Huachao Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comment
parent
621b14de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
11 deletions
+17
-11
Cargo.toml
Cargo.toml
+1
-2
lib.rs
librocksdb_sys/src/lib.rs
+1
-1
table_properties_collector.rs
src/table_properties_collector.rs
+12
-6
table_properties_collector_factory.rs
src/table_properties_collector_factory.rs
+3
-2
No files found.
Cargo.toml
View file @
0fe7d360
...
...
@@ -34,4 +34,4 @@ tempdir = "0.3.4"
path
=
"librocksdb_sys"
[dev-dependencies]
byteorder
=
"1.0.0"
\ No newline at end of file
byteorder
=
"1.0.0"
librocksdb_sys/src/lib.rs
View file @
0fe7d360
...
...
@@ -187,7 +187,7 @@ pub enum DBInfoLogLevel {
DBNumInfoLog
=
6
,
}
#[derive(Copy,
Clone)]
#[derive(Copy,
Clone
,
Eq,
PartialEq
)]
#[repr(C)]
pub
enum
DBTableProperty
{
DataSize
=
1
,
...
...
src/table_properties_collector.rs
View file @
0fe7d360
...
...
@@ -14,6 +14,7 @@
use
crocksdb_ffi
::{
self
,
DBEntryType
,
DBUserCollectedProperties
,
DBTablePropertiesCollector
};
use
libc
::{
c_void
,
c_char
,
c_int
,
uint8_t
,
uint64_t
,
size_t
};
use
std
::
collections
::
HashMap
;
use
std
::
ffi
::
CString
;
use
std
::
mem
;
use
std
::
slice
;
...
...
@@ -25,10 +26,15 @@ use std::slice;
/// TablePropertiesCollector object per table and then call it sequentially
pub
trait
TablePropertiesCollector
{
/// The name of the properties collector.
fn
name
(
&
self
)
->
&
str
;
fn
name
(
&
self
)
->
&
CString
;
/// Will be called when a new key/value pair is inserted into the table.
fn
add_userkey
(
&
mut
self
,
key
:
&
[
u8
],
value
:
&
[
u8
],
entry_type
:
DBEntryType
);
fn
add_userkey
(
&
mut
self
,
key
:
&
[
u8
],
value
:
&
[
u8
],
entry_type
:
DBEntryType
,
seq
:
u64
,
file_size
:
u64
);
/// Will be called when a table has already been built and is ready for
/// writing the properties block.
...
...
@@ -38,7 +44,7 @@ pub trait TablePropertiesCollector {
extern
"C"
fn
name
(
collector
:
*
mut
c_void
)
->
*
const
c_char
{
unsafe
{
let
collector
=
&
mut
*
(
collector
as
*
mut
Box
<
TablePropertiesCollector
>
);
collector
.name
()
.as_ptr
()
as
*
const
c_char
collector
.name
()
.as_ptr
()
}
}
...
...
@@ -55,13 +61,13 @@ pub extern "C" fn add_userkey(collector: *mut c_void,
value
:
*
const
uint8_t
,
value_len
:
size_t
,
entry_type
:
c_int
,
_
:
uint64_t
,
_
:
uint64_t
)
{
seq
:
uint64_t
,
file_size
:
uint64_t
)
{
unsafe
{
let
collector
=
&
mut
*
(
collector
as
*
mut
Box
<
TablePropertiesCollector
>
);
let
key
=
slice
::
from_raw_parts
(
key
,
key_len
);
let
value
=
slice
::
from_raw_parts
(
value
,
value_len
);
collector
.add_userkey
(
key
,
value
,
mem
::
transmute
(
entry_type
));
collector
.add_userkey
(
key
,
value
,
mem
::
transmute
(
entry_type
)
,
seq
,
file_size
);
}
}
...
...
src/table_properties_collector_factory.rs
View file @
0fe7d360
...
...
@@ -13,13 +13,14 @@
use
crocksdb_ffi
::{
self
,
DBTablePropertiesCollector
,
DBTablePropertiesCollectorFactory
};
use
libc
::{
c_void
,
c_char
,
uint32_t
};
use
std
::
ffi
::
CString
;
use
table_properties_collector
::{
TablePropertiesCollector
,
new_table_properties_collector
};
/// Constructs `TablePropertiesCollector`.
/// Internals create a new `TablePropertiesCollector` for each new table.
pub
trait
TablePropertiesCollectorFactory
{
/// The name of the properties collector factory.
fn
name
(
&
self
)
->
&
str
;
fn
name
(
&
self
)
->
&
CString
;
/// Has to be thread-safe.
fn
create_table_properties_collector
(
&
mut
self
,
cf
:
u32
)
->
Box
<
TablePropertiesCollector
>
;
}
...
...
@@ -27,7 +28,7 @@ pub trait TablePropertiesCollectorFactory {
extern
"C"
fn
name
(
factory
:
*
mut
c_void
)
->
*
const
c_char
{
unsafe
{
let
factory
=
&
mut
*
(
factory
as
*
mut
Box
<
TablePropertiesCollectorFactory
>
);
factory
.name
()
.as_ptr
()
as
*
const
c_char
factory
.name
()
.as_ptr
()
}
}
...
...
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