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
20a331b1
Commit
20a331b1
authored
Jun 28, 2017
by
Huachao Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comment
parent
a7c9bd69
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
c.cc
librocksdb_sys/crocksdb/c.cc
+10
-9
lib.rs
librocksdb_sys/src/lib.rs
+4
-4
rocksdb.rs
src/rocksdb.rs
+1
-1
table_properties.rs
src/table_properties.rs
+4
-6
test_table_properties.rs
tests/test_table_properties.rs
+2
-1
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
20a331b1
...
@@ -2935,8 +2935,8 @@ struct crocksdb_user_collected_properties_t {
...
@@ -2935,8 +2935,8 @@ struct crocksdb_user_collected_properties_t {
};
};
struct
crocksdb_user_collected_properties_iterator_t
{
struct
crocksdb_user_collected_properties_iterator_t
{
const
UserCollectedProperties
*
rep_
=
nullptr
;
UserCollectedProperties
*
rep_
=
nullptr
;
UserCollectedProperties
::
const_
iterator
iter_
;
UserCollectedProperties
::
iterator
iter_
;
};
};
void
crocksdb_user_collected_properties_add
(
crocksdb_user_collected_properties_t
*
props
,
void
crocksdb_user_collected_properties_add
(
crocksdb_user_collected_properties_t
*
props
,
...
@@ -3038,8 +3038,7 @@ const char* crocksdb_table_properties_get_str(crocksdb_table_properties_t* props
...
@@ -3038,8 +3038,7 @@ const char* crocksdb_table_properties_get_str(crocksdb_table_properties_t* props
crocksdb_user_collected_properties_t
*
crocksdb_user_collected_properties_t
*
crocksdb_table_properties_get_user_properties
(
crocksdb_table_properties_t
*
props
)
{
crocksdb_table_properties_get_user_properties
(
crocksdb_table_properties_t
*
props
)
{
props
->
user_props_
.
rep_
=
props
->
user_props_
.
rep_
=
&
props
->
rep_
->
user_collected_properties
;
const_cast
<
UserCollectedProperties
*>
(
&
props
->
rep_
->
user_collected_properties
);
return
&
props
->
user_props_
;
return
&
props
->
user_props_
;
}
}
...
@@ -3058,8 +3057,8 @@ struct crocksdb_table_properties_collection_t {
...
@@ -3058,8 +3057,8 @@ struct crocksdb_table_properties_collection_t {
};
};
struct
crocksdb_table_properties_collection_iterator_t
{
struct
crocksdb_table_properties_collection_iterator_t
{
const
TablePropertiesCollection
*
rep_
=
nullptr
;
TablePropertiesCollection
*
rep_
=
nullptr
;
TablePropertiesCollection
::
const_
iterator
iter_
;
TablePropertiesCollection
::
iterator
iter_
;
crocksdb_table_properties_t
props_
;
crocksdb_table_properties_t
props_
;
};
};
...
@@ -3147,8 +3146,7 @@ struct crocksdb_table_properties_collector_t : public TablePropertiesCollector {
...
@@ -3147,8 +3146,7 @@ struct crocksdb_table_properties_collector_t : public TablePropertiesCollector {
virtual
UserCollectedProperties
GetReadableProperties
()
const
override
{
virtual
UserCollectedProperties
GetReadableProperties
()
const
override
{
// Seems rocksdb will not return the readable properties and we don't need them too.
// Seems rocksdb will not return the readable properties and we don't need them too.
UserCollectedProperties
props
;
return
UserCollectedProperties
();
return
props
;
}
}
const
char
*
Name
()
const
override
{
const
char
*
Name
()
const
override
{
...
@@ -3258,7 +3256,10 @@ void crocksdb_get_properties_of_tables_in_range(
...
@@ -3258,7 +3256,10 @@ void crocksdb_get_properties_of_tables_in_range(
ranges
.
emplace_back
(
Range
(
Slice
(
start_keys
[
i
],
start_keys_lens
[
i
]),
ranges
.
emplace_back
(
Range
(
Slice
(
start_keys
[
i
],
start_keys_lens
[
i
]),
Slice
(
limit_keys
[
i
],
limit_keys_lens
[
i
])));
Slice
(
limit_keys
[
i
],
limit_keys_lens
[
i
])));
}
}
auto
s
=
db
->
rep
->
GetPropertiesOfTablesInRange
(
cf
->
rep
,
&
ranges
[
0
],
ranges
.
size
(),
props
->
rep_
);
auto
s
=
db
->
rep
->
GetPropertiesOfTablesInRange
(
cf
->
rep
,
ranges
.
data
(),
ranges
.
size
(),
props
->
rep_
);
if
(
!
s
.
ok
())
{
if
(
!
s
.
ok
())
{
SaveError
(
errptr
,
s
);
SaveError
(
errptr
,
s
);
}
}
...
...
librocksdb_sys/src/lib.rs
View file @
20a331b1
...
@@ -902,9 +902,8 @@ extern "C" {
...
@@ -902,9 +902,8 @@ extern "C" {
pub
fn
crocksdb_table_properties_collection_iter_next
pub
fn
crocksdb_table_properties_collection_iter_next
(
it
:
*
mut
DBTablePropertiesCollectionIterator
);
(
it
:
*
mut
DBTablePropertiesCollectionIterator
);
pub
fn
crocksdb_table_properties_collection_iter_key
(
it
:
*
mut
DBTablePropertiesCollectionIterator
,
pub
fn
crocksdb_table_properties_collection_iter_key
(
klen
:
*
mut
size_t
)
it
:
*
mut
DBTablePropertiesCollectionIterator
,
klen
:
*
mut
size_t
)
->
*
const
uint8_t
;
->
*
const
uint8_t
;
pub
fn
crocksdb_table_properties_collection_iter_value
pub
fn
crocksdb_table_properties_collection_iter_value
(
it
:
*
mut
DBTablePropertiesCollectionIterator
)
->
*
mut
DBTableProperties
;
(
it
:
*
mut
DBTablePropertiesCollectionIterator
)
->
*
mut
DBTableProperties
;
...
@@ -921,7 +920,8 @@ extern "C" {
...
@@ -921,7 +920,8 @@ extern "C" {
c_int
,
c_int
,
uint64_t
,
uint64_t
,
uint64_t
),
uint64_t
),
finish
:
extern
"C"
fn
(
*
mut
c_void
,
finish
:
extern
"C"
fn
(
*
mut
c_void
,
*
mut
DBUserCollectedProperties
))
*
mut
DBUserCollectedProperties
))
->
*
mut
DBTablePropertiesCollector
;
->
*
mut
DBTablePropertiesCollector
;
...
...
src/rocksdb.rs
View file @
20a331b1
...
@@ -35,7 +35,7 @@ pub struct CFHandle {
...
@@ -35,7 +35,7 @@ pub struct CFHandle {
}
}
impl
CFHandle
{
impl
CFHandle
{
fn
get_id
(
&
self
)
->
u32
{
pub
fn
get_id
(
&
self
)
->
u32
{
unsafe
{
crocksdb_ffi
::
crocksdb_column_family_handle_get_id
(
self
.inner
)
}
unsafe
{
crocksdb_ffi
::
crocksdb_column_family_handle_get_id
(
self
.inner
)
}
}
}
}
}
...
...
src/table_properties.rs
View file @
20a331b1
...
@@ -169,9 +169,8 @@ impl TablePropertiesCollectionIter {
...
@@ -169,9 +169,8 @@ impl TablePropertiesCollectionIter {
fn
key
(
&
self
)
->
Result
<
String
,
String
>
{
fn
key
(
&
self
)
->
Result
<
String
,
String
>
{
unsafe
{
unsafe
{
let
mut
klen
:
size_t
=
0
;
let
mut
klen
:
size_t
=
0
;
let
k
=
let
k
=
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_key
(
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_key
(
self
.inner
,
self
.inner
,
&
mut
klen
as
*
mut
size_t
);
&
mut
klen
as
*
mut
size_t
);
let
bytes
=
slice
::
from_raw_parts
(
k
,
klen
);
let
bytes
=
slice
::
from_raw_parts
(
k
,
klen
);
String
::
from_utf8
(
bytes
.to_owned
())
.or_else
(|
e
|
Err
(
format!
(
"{}"
,
e
)))
String
::
from_utf8
(
bytes
.to_owned
())
.or_else
(|
e
|
Err
(
format!
(
"{}"
,
e
)))
}
}
...
@@ -226,9 +225,8 @@ impl UserCollectedPropertiesIter {
...
@@ -226,9 +225,8 @@ impl UserCollectedPropertiesIter {
fn
value
(
&
self
)
->
&
[
u8
]
{
fn
value
(
&
self
)
->
&
[
u8
]
{
unsafe
{
unsafe
{
let
mut
vlen
:
size_t
=
0
;
let
mut
vlen
:
size_t
=
0
;
let
v
=
let
v
=
crocksdb_ffi
::
crocksdb_user_collected_properties_iter_value
(
crocksdb_ffi
::
crocksdb_user_collected_properties_iter_value
(
self
.inner
,
self
.inner
,
&
mut
vlen
as
*
mut
size_t
);
&
mut
vlen
as
*
mut
size_t
);
slice
::
from_raw_parts
(
v
,
vlen
)
slice
::
from_raw_parts
(
v
,
vlen
)
}
}
}
}
...
...
tests/test_table_properties.rs
View file @
20a331b1
...
@@ -157,9 +157,10 @@ fn check_collection(collection: &TablePropertiesCollection,
...
@@ -157,9 +157,10 @@ fn check_collection(collection: &TablePropertiesCollection,
#[test]
#[test]
fn
test_table_properties_collector_factory
()
{
fn
test_table_properties_collector_factory
()
{
let
f
=
ExampleFactory
::
new
();
let
mut
opts
=
Options
::
new
();
let
mut
opts
=
Options
::
new
();
opts
.create_if_missing
(
true
);
opts
.create_if_missing
(
true
);
opts
.add_table_properties_collector_factory
(
Box
::
new
(
ExampleFactory
::
new
()
));
opts
.add_table_properties_collector_factory
(
Box
::
new
(
f
));
let
path
=
TempDir
::
new
(
"_rust_rocksdb_collectortest"
)
.expect
(
""
);
let
path
=
TempDir
::
new
(
"_rust_rocksdb_collectortest"
)
.expect
(
""
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
...
...
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