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
cfcb93fb
Unverified
Commit
cfcb93fb
authored
Aug 14, 2019
by
qupeng
Committed by
GitHub
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix clippy warnings (#333)
Signed-off-by:
qupeng
<
qupeng@pingcap.com
>
parent
9603a845
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
28 deletions
+47
-28
compaction_filter.rs
src/compaction_filter.rs
+2
-2
event_listener.rs
src/event_listener.rs
+26
-6
main.rs
src/main.rs
+1
-1
rocksdb_options.rs
src/rocksdb_options.rs
+5
-5
slice_transform.rs
src/slice_transform.rs
+2
-2
table_filter.rs
src/table_filter.rs
+2
-2
table_properties_collector.rs
src/table_properties_collector.rs
+3
-3
table_properties_collector_factory.rs
src/table_properties_collector_factory.rs
+4
-4
test_rocksdb_options.rs
tests/cases/test_rocksdb_options.rs
+0
-1
test_table_properties.rs
tests/cases/test_table_properties.rs
+1
-1
test_titan.rs
tests/cases/test_titan.rs
+1
-1
No files found.
src/compaction_filter.rs
View file @
cfcb93fb
...
@@ -21,7 +21,7 @@ pub trait CompactionFilter {
...
@@ -21,7 +21,7 @@ pub trait CompactionFilter {
#[repr(C)]
#[repr(C)]
pub
struct
CompactionFilterProxy
{
pub
struct
CompactionFilterProxy
{
name
:
CString
,
name
:
CString
,
filter
:
Box
<
CompactionFilter
>
,
filter
:
Box
<
dyn
CompactionFilter
>
,
}
}
extern
"C"
fn
name
(
filter
:
*
mut
c_void
)
->
*
const
c_char
{
extern
"C"
fn
name
(
filter
:
*
mut
c_void
)
->
*
const
c_char
{
...
@@ -69,7 +69,7 @@ impl Drop for CompactionFilterHandle {
...
@@ -69,7 +69,7 @@ impl Drop for CompactionFilterHandle {
pub
unsafe
fn
new_compaction_filter
(
pub
unsafe
fn
new_compaction_filter
(
c_name
:
CString
,
c_name
:
CString
,
ignore_snapshots
:
bool
,
ignore_snapshots
:
bool
,
f
:
Box
<
CompactionFilter
>
,
f
:
Box
<
dyn
CompactionFilter
>
,
)
->
Result
<
CompactionFilterHandle
,
String
>
{
)
->
Result
<
CompactionFilterHandle
,
String
>
{
let
proxy
=
Box
::
into_raw
(
Box
::
new
(
CompactionFilterProxy
{
let
proxy
=
Box
::
into_raw
(
Box
::
new
(
CompactionFilterProxy
{
name
:
c_name
,
name
:
c_name
,
...
...
src/event_listener.rs
View file @
cfcb93fb
...
@@ -183,7 +183,7 @@ pub trait EventListener: Send + Sync {
...
@@ -183,7 +183,7 @@ pub trait EventListener: Send + Sync {
extern
"C"
fn
destructor
(
ctx
:
*
mut
c_void
)
{
extern
"C"
fn
destructor
(
ctx
:
*
mut
c_void
)
{
unsafe
{
unsafe
{
Box
::
from_raw
(
ctx
as
*
mut
Box
<
EventListener
>
);
Box
::
from_raw
(
ctx
as
*
mut
Box
<
dyn
EventListener
>
);
}
}
}
}
...
@@ -194,7 +194,12 @@ extern "C" fn on_flush_completed(
...
@@ -194,7 +194,12 @@ extern "C" fn on_flush_completed(
_
:
*
mut
DBInstance
,
_
:
*
mut
DBInstance
,
info
:
*
const
DBFlushJobInfo
,
info
:
*
const
DBFlushJobInfo
,
)
{
)
{
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
EventListener
>
),
mem
::
transmute
(
&*
info
))
};
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
dyn
EventListener
>
),
mem
::
transmute
(
&*
info
),
)
};
ctx
.on_flush_completed
(
info
);
ctx
.on_flush_completed
(
info
);
}
}
...
@@ -203,7 +208,12 @@ extern "C" fn on_compaction_completed(
...
@@ -203,7 +208,12 @@ extern "C" fn on_compaction_completed(
_
:
*
mut
DBInstance
,
_
:
*
mut
DBInstance
,
info
:
*
const
DBCompactionJobInfo
,
info
:
*
const
DBCompactionJobInfo
,
)
{
)
{
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
EventListener
>
),
mem
::
transmute
(
&*
info
))
};
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
dyn
EventListener
>
),
mem
::
transmute
(
&*
info
),
)
};
ctx
.on_compaction_completed
(
info
);
ctx
.on_compaction_completed
(
info
);
}
}
...
@@ -212,17 +222,27 @@ extern "C" fn on_external_file_ingested(
...
@@ -212,17 +222,27 @@ extern "C" fn on_external_file_ingested(
_
:
*
mut
DBInstance
,
_
:
*
mut
DBInstance
,
info
:
*
const
DBIngestionInfo
,
info
:
*
const
DBIngestionInfo
,
)
{
)
{
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
EventListener
>
),
mem
::
transmute
(
&*
info
))
};
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
dyn
EventListener
>
),
mem
::
transmute
(
&*
info
),
)
};
ctx
.on_external_file_ingested
(
info
);
ctx
.on_external_file_ingested
(
info
);
}
}
extern
"C"
fn
on_stall_conditions_changed
(
ctx
:
*
mut
c_void
,
info
:
*
const
DBWriteStallInfo
)
{
extern
"C"
fn
on_stall_conditions_changed
(
ctx
:
*
mut
c_void
,
info
:
*
const
DBWriteStallInfo
)
{
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
EventListener
>
),
mem
::
transmute
(
&*
info
))
};
let
(
ctx
,
info
)
=
unsafe
{
(
&*
(
ctx
as
*
mut
Box
<
dyn
EventListener
>
),
mem
::
transmute
(
&*
info
),
)
};
ctx
.on_stall_conditions_changed
(
info
);
ctx
.on_stall_conditions_changed
(
info
);
}
}
pub
fn
new_event_listener
<
L
:
EventListener
>
(
l
:
L
)
->
*
mut
DBEventListener
{
pub
fn
new_event_listener
<
L
:
EventListener
>
(
l
:
L
)
->
*
mut
DBEventListener
{
let
p
:
Box
<
EventListener
>
=
Box
::
new
(
l
);
let
p
:
Box
<
dyn
EventListener
>
=
Box
::
new
(
l
);
unsafe
{
unsafe
{
crocksdb_ffi
::
crocksdb_eventlistener_create
(
crocksdb_ffi
::
crocksdb_eventlistener_create
(
Box
::
into_raw
(
Box
::
new
(
p
))
as
*
mut
c_void
,
Box
::
into_raw
(
Box
::
new
(
p
))
as
*
mut
c_void
,
...
...
src/main.rs
View file @
cfcb93fb
...
@@ -107,7 +107,7 @@ fn custom_merge() {
...
@@ -107,7 +107,7 @@ fn custom_merge() {
}
}
}
}
let
opts
=
DBOptions
::
new
();
let
opts
=
DBOptions
::
new
();
DB
::
destroy
(
&
opts
,
path
)
.is_ok
();
let
_
=
DB
::
destroy
(
&
opts
,
path
)
.is_ok
();
}
}
#[cfg(test)]
#[cfg(test)]
...
...
src/rocksdb_options.rs
View file @
cfcb93fb
...
@@ -451,7 +451,7 @@ impl ReadOptions {
...
@@ -451,7 +451,7 @@ impl ReadOptions {
}
}
}
}
pub
fn
set_table_filter
(
&
mut
self
,
filter
:
Box
<
TableFilter
>
)
{
pub
fn
set_table_filter
(
&
mut
self
,
filter
:
Box
<
dyn
TableFilter
>
)
{
unsafe
{
unsafe
{
let
f
=
Box
::
into_raw
(
Box
::
new
(
filter
));
let
f
=
Box
::
into_raw
(
Box
::
new
(
filter
));
crocksdb_ffi
::
crocksdb_readoptions_set_table_filter
(
crocksdb_ffi
::
crocksdb_readoptions_set_table_filter
(
...
@@ -1179,7 +1179,7 @@ impl ColumnFamilyOptions {
...
@@ -1179,7 +1179,7 @@ impl ColumnFamilyOptions {
&
mut
self
,
&
mut
self
,
name
:
S
,
name
:
S
,
ignore_snapshots
:
bool
,
ignore_snapshots
:
bool
,
filter
:
Box
<
CompactionFilter
>
,
filter
:
Box
<
dyn
CompactionFilter
>
,
)
->
Result
<
(),
String
>
)
->
Result
<
(),
String
>
where
where
S
:
Into
<
Vec
<
u8
>>
,
S
:
Into
<
Vec
<
u8
>>
,
...
@@ -1201,7 +1201,7 @@ impl ColumnFamilyOptions {
...
@@ -1201,7 +1201,7 @@ impl ColumnFamilyOptions {
pub
fn
add_table_properties_collector_factory
(
pub
fn
add_table_properties_collector_factory
(
&
mut
self
,
&
mut
self
,
fname
:
&
str
,
fname
:
&
str
,
factory
:
Box
<
TablePropertiesCollectorFactory
>
,
factory
:
Box
<
dyn
TablePropertiesCollectorFactory
>
,
)
{
)
{
unsafe
{
unsafe
{
let
f
=
new_table_properties_collector_factory
(
fname
,
factory
);
let
f
=
new_table_properties_collector_factory
(
fname
,
factory
);
...
@@ -1472,7 +1472,7 @@ impl ColumnFamilyOptions {
...
@@ -1472,7 +1472,7 @@ impl ColumnFamilyOptions {
pub
fn
set_prefix_extractor
<
S
>
(
pub
fn
set_prefix_extractor
<
S
>
(
&
mut
self
,
&
mut
self
,
name
:
S
,
name
:
S
,
transform
:
Box
<
SliceTransform
>
,
transform
:
Box
<
dyn
SliceTransform
>
,
)
->
Result
<
(),
String
>
)
->
Result
<
(),
String
>
where
where
S
:
Into
<
Vec
<
u8
>>
,
S
:
Into
<
Vec
<
u8
>>
,
...
@@ -1497,7 +1497,7 @@ impl ColumnFamilyOptions {
...
@@ -1497,7 +1497,7 @@ impl ColumnFamilyOptions {
pub
fn
set_memtable_insert_hint_prefix_extractor
<
S
>
(
pub
fn
set_memtable_insert_hint_prefix_extractor
<
S
>
(
&
mut
self
,
&
mut
self
,
name
:
S
,
name
:
S
,
transform
:
Box
<
SliceTransform
>
,
transform
:
Box
<
dyn
SliceTransform
>
,
)
->
Result
<
(),
String
>
)
->
Result
<
(),
String
>
where
where
S
:
Into
<
Vec
<
u8
>>
,
S
:
Into
<
Vec
<
u8
>>
,
...
...
src/slice_transform.rs
View file @
cfcb93fb
...
@@ -40,7 +40,7 @@ pub trait SliceTransform {
...
@@ -40,7 +40,7 @@ pub trait SliceTransform {
#[repr(C)]
#[repr(C)]
pub
struct
SliceTransformProxy
{
pub
struct
SliceTransformProxy
{
name
:
CString
,
name
:
CString
,
transform
:
Box
<
SliceTransform
>
,
transform
:
Box
<
dyn
SliceTransform
>
,
}
}
extern
"C"
fn
name
(
transform
:
*
mut
c_void
)
->
*
const
c_char
{
extern
"C"
fn
name
(
transform
:
*
mut
c_void
)
->
*
const
c_char
{
...
@@ -86,7 +86,7 @@ extern "C" fn in_range(transform: *mut c_void, key: *const u8, key_len: size_t)
...
@@ -86,7 +86,7 @@ extern "C" fn in_range(transform: *mut c_void, key: *const u8, key_len: size_t)
pub
unsafe
fn
new_slice_transform
(
pub
unsafe
fn
new_slice_transform
(
c_name
:
CString
,
c_name
:
CString
,
f
:
Box
<
SliceTransform
>
,
f
:
Box
<
dyn
SliceTransform
>
,
)
->
Result
<*
mut
DBSliceTransform
,
String
>
{
)
->
Result
<*
mut
DBSliceTransform
,
String
>
{
let
proxy
=
Box
::
into_raw
(
Box
::
new
(
SliceTransformProxy
{
let
proxy
=
Box
::
into_raw
(
Box
::
new
(
SliceTransformProxy
{
name
:
c_name
,
name
:
c_name
,
...
...
src/table_filter.rs
View file @
cfcb93fb
...
@@ -27,13 +27,13 @@ pub trait TableFilter {
...
@@ -27,13 +27,13 @@ pub trait TableFilter {
pub
extern
"C"
fn
table_filter
(
ctx
:
*
mut
c_void
,
props
:
*
const
DBTableProperties
)
->
c_int
{
pub
extern
"C"
fn
table_filter
(
ctx
:
*
mut
c_void
,
props
:
*
const
DBTableProperties
)
->
c_int
{
unsafe
{
unsafe
{
let
filter
=
&*
(
ctx
as
*
mut
Box
<
TableFilter
>
);
let
filter
=
&*
(
ctx
as
*
mut
Box
<
dyn
TableFilter
>
);
filter
.table_filter
(
mem
::
transmute
(
&*
props
))
as
c_int
filter
.table_filter
(
mem
::
transmute
(
&*
props
))
as
c_int
}
}
}
}
pub
extern
"C"
fn
destroy_table_filter
(
filter
:
*
mut
c_void
)
{
pub
extern
"C"
fn
destroy_table_filter
(
filter
:
*
mut
c_void
)
{
unsafe
{
unsafe
{
Box
::
from_raw
(
filter
as
*
mut
Box
<
TableFilter
>
);
Box
::
from_raw
(
filter
as
*
mut
Box
<
dyn
TableFilter
>
);
}
}
}
}
src/table_properties_collector.rs
View file @
cfcb93fb
...
@@ -35,11 +35,11 @@ pub trait TablePropertiesCollector {
...
@@ -35,11 +35,11 @@ pub trait TablePropertiesCollector {
struct
TablePropertiesCollectorHandle
{
struct
TablePropertiesCollectorHandle
{
name
:
CString
,
name
:
CString
,
rep
:
Box
<
TablePropertiesCollector
>
,
rep
:
Box
<
dyn
TablePropertiesCollector
>
,
}
}
impl
TablePropertiesCollectorHandle
{
impl
TablePropertiesCollectorHandle
{
fn
new
(
name
:
&
str
,
rep
:
Box
<
TablePropertiesCollector
>
)
->
TablePropertiesCollectorHandle
{
fn
new
(
name
:
&
str
,
rep
:
Box
<
dyn
TablePropertiesCollector
>
)
->
TablePropertiesCollectorHandle
{
TablePropertiesCollectorHandle
{
TablePropertiesCollectorHandle
{
name
:
CString
::
new
(
name
)
.unwrap
(),
name
:
CString
::
new
(
name
)
.unwrap
(),
rep
:
rep
,
rep
:
rep
,
...
@@ -97,7 +97,7 @@ pub extern "C" fn finish(handle: *mut c_void, props: *mut DBUserCollectedPropert
...
@@ -97,7 +97,7 @@ pub extern "C" fn finish(handle: *mut c_void, props: *mut DBUserCollectedPropert
pub
unsafe
fn
new_table_properties_collector
(
pub
unsafe
fn
new_table_properties_collector
(
cname
:
&
str
,
cname
:
&
str
,
collector
:
Box
<
TablePropertiesCollector
>
,
collector
:
Box
<
dyn
TablePropertiesCollector
>
,
)
->
*
mut
DBTablePropertiesCollector
{
)
->
*
mut
DBTablePropertiesCollector
{
let
handle
=
TablePropertiesCollectorHandle
::
new
(
cname
,
collector
);
let
handle
=
TablePropertiesCollectorHandle
::
new
(
cname
,
collector
);
crocksdb_ffi
::
crocksdb_table_properties_collector_create
(
crocksdb_ffi
::
crocksdb_table_properties_collector_create
(
...
...
src/table_properties_collector_factory.rs
View file @
cfcb93fb
...
@@ -20,18 +20,18 @@ use table_properties_collector::{new_table_properties_collector, TableProperties
...
@@ -20,18 +20,18 @@ use table_properties_collector::{new_table_properties_collector, TableProperties
/// Internals create a new `TablePropertiesCollector` for each new table.
/// Internals create a new `TablePropertiesCollector` for each new table.
pub
trait
TablePropertiesCollectorFactory
{
pub
trait
TablePropertiesCollectorFactory
{
/// Has to be thread-safe.
/// Has to be thread-safe.
fn
create_table_properties_collector
(
&
mut
self
,
cf
:
u32
)
->
Box
<
TablePropertiesCollector
>
;
fn
create_table_properties_collector
(
&
mut
self
,
cf
:
u32
)
->
Box
<
dyn
TablePropertiesCollector
>
;
}
}
struct
TablePropertiesCollectorFactoryHandle
{
struct
TablePropertiesCollectorFactoryHandle
{
name
:
CString
,
name
:
CString
,
rep
:
Box
<
TablePropertiesCollectorFactory
>
,
rep
:
Box
<
dyn
TablePropertiesCollectorFactory
>
,
}
}
impl
TablePropertiesCollectorFactoryHandle
{
impl
TablePropertiesCollectorFactoryHandle
{
fn
new
(
fn
new
(
name
:
&
str
,
name
:
&
str
,
rep
:
Box
<
TablePropertiesCollectorFactory
>
,
rep
:
Box
<
dyn
TablePropertiesCollectorFactory
>
,
)
->
TablePropertiesCollectorFactoryHandle
{
)
->
TablePropertiesCollectorFactoryHandle
{
TablePropertiesCollectorFactoryHandle
{
TablePropertiesCollectorFactoryHandle
{
name
:
CString
::
new
(
name
)
.unwrap
(),
name
:
CString
::
new
(
name
)
.unwrap
(),
...
@@ -66,7 +66,7 @@ extern "C" fn create_table_properties_collector(
...
@@ -66,7 +66,7 @@ extern "C" fn create_table_properties_collector(
pub
unsafe
fn
new_table_properties_collector_factory
(
pub
unsafe
fn
new_table_properties_collector_factory
(
fname
:
&
str
,
fname
:
&
str
,
factory
:
Box
<
TablePropertiesCollectorFactory
>
,
factory
:
Box
<
dyn
TablePropertiesCollectorFactory
>
,
)
->
*
mut
DBTablePropertiesCollectorFactory
{
)
->
*
mut
DBTablePropertiesCollectorFactory
{
let
handle
=
TablePropertiesCollectorFactoryHandle
::
new
(
fname
,
factory
);
let
handle
=
TablePropertiesCollectorFactoryHandle
::
new
(
fname
,
factory
);
crocksdb_ffi
::
crocksdb_table_properties_collector_factory_create
(
crocksdb_ffi
::
crocksdb_table_properties_collector_factory_create
(
...
...
tests/cases/test_rocksdb_options.rs
View file @
cfcb93fb
...
@@ -15,7 +15,6 @@ use rocksdb::crocksdb_ffi::{
...
@@ -15,7 +15,6 @@ use rocksdb::crocksdb_ffi::{
CompactionPriority
,
DBCompressionType
,
DBInfoLogLevel
as
InfoLogLevel
,
DBRateLimiterMode
,
CompactionPriority
,
DBCompressionType
,
DBInfoLogLevel
as
InfoLogLevel
,
DBRateLimiterMode
,
DBStatisticsHistogramType
as
HistogramType
,
DBStatisticsTickerType
as
TickerType
,
DBStatisticsHistogramType
as
HistogramType
,
DBStatisticsTickerType
as
TickerType
,
};
};
use
rocksdb
::
rocksdb
::
MemoryAllocator
;
use
rocksdb
::{
use
rocksdb
::{
BlockBasedOptions
,
Cache
,
ColumnFamilyOptions
,
CompactOptions
,
DBOptions
,
Env
,
BlockBasedOptions
,
Cache
,
ColumnFamilyOptions
,
CompactOptions
,
DBOptions
,
Env
,
FifoCompactionOptions
,
IndexType
,
LRUCacheOptions
,
ReadOptions
,
SeekKey
,
SliceTransform
,
FifoCompactionOptions
,
IndexType
,
LRUCacheOptions
,
ReadOptions
,
SeekKey
,
SliceTransform
,
...
...
tests/cases/test_table_properties.rs
View file @
cfcb93fb
...
@@ -132,7 +132,7 @@ impl ExampleFactory {
...
@@ -132,7 +132,7 @@ impl ExampleFactory {
}
}
impl
TablePropertiesCollectorFactory
for
ExampleFactory
{
impl
TablePropertiesCollectorFactory
for
ExampleFactory
{
fn
create_table_properties_collector
(
&
mut
self
,
_
:
u32
)
->
Box
<
TablePropertiesCollector
>
{
fn
create_table_properties_collector
(
&
mut
self
,
_
:
u32
)
->
Box
<
dyn
TablePropertiesCollector
>
{
Box
::
new
(
ExampleCollector
::
new
())
Box
::
new
(
ExampleCollector
::
new
())
}
}
}
}
...
...
tests/cases/test_titan.rs
View file @
cfcb93fb
...
@@ -82,7 +82,7 @@ impl TablePropertiesCollector for TitanCollector {
...
@@ -82,7 +82,7 @@ impl TablePropertiesCollector for TitanCollector {
struct
TitanCollectorFactory
{}
struct
TitanCollectorFactory
{}
impl
TablePropertiesCollectorFactory
for
TitanCollectorFactory
{
impl
TablePropertiesCollectorFactory
for
TitanCollectorFactory
{
fn
create_table_properties_collector
(
&
mut
self
,
_
:
u32
)
->
Box
<
TablePropertiesCollector
>
{
fn
create_table_properties_collector
(
&
mut
self
,
_
:
u32
)
->
Box
<
dyn
TablePropertiesCollector
>
{
Box
::
new
(
TitanCollector
::
default
())
Box
::
new
(
TitanCollector
::
default
())
}
}
}
}
...
...
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