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
dc16c9b1
Commit
dc16c9b1
authored
Jan 26, 2019
by
dorianzheng
Committed by
Huachao Huang
Jan 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix event listener bug (#267)
parent
27fe5818
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
14 deletions
+39
-14
c.cc
librocksdb_sys/crocksdb/c.cc
+11
-2
lib.rs
librocksdb_sys/src/lib.rs
+4
-0
event_listener.rs
src/event_listener.rs
+5
-0
table_properties.rs
src/table_properties.rs
+18
-12
test_event_listener.rs
tests/cases/test_event_listener.rs
+1
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
dc16c9b1
...
...
@@ -1832,6 +1832,11 @@ bool crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t*
/* CompactionJobInfo */
void
crocksdb_compactionjobinfo_status
(
const
crocksdb_compactionjobinfo_t
*
info
,
char
**
errptr
)
{
SaveError
(
errptr
,
info
->
rep
.
status
);
}
const
char
*
crocksdb_compactionjobinfo_cf_name
(
const
crocksdb_compactionjobinfo_t
*
info
,
size_t
*
size
)
{
*
size
=
info
->
rep
.
cf_name
.
size
();
...
...
@@ -4122,8 +4127,12 @@ const char* crocksdb_table_properties_collection_iter_key(
const
crocksdb_table_properties_t
*
crocksdb_table_properties_collection_iter_value
(
const
crocksdb_table_properties_collection_iterator_t
*
it
)
{
return
reinterpret_cast
<
const
crocksdb_table_properties_t
*>
(
it
->
cur_
->
second
.
get
());
if
(
it
->
cur_
->
second
)
{
return
reinterpret_cast
<
const
crocksdb_table_properties_t
*>
(
it
->
cur_
->
second
.
get
());
}
else
{
return
nullptr
;
}
}
/* Table Properties Collector */
...
...
librocksdb_sys/src/lib.rs
View file @
dc16c9b1
...
...
@@ -1534,6 +1534,10 @@ extern "C" {
pub
fn
crocksdb_flushjobinfo_triggered_writes_slowdown
(
info
:
*
const
DBFlushJobInfo
)
->
bool
;
pub
fn
crocksdb_flushjobinfo_triggered_writes_stop
(
info
:
*
const
DBFlushJobInfo
)
->
bool
;
pub
fn
crocksdb_compactionjobinfo_status
(
info
:
*
const
DBCompactionJobInfo
,
errptr
:
*
mut
*
mut
c_char
,
);
pub
fn
crocksdb_compactionjobinfo_cf_name
(
info
:
*
const
DBCompactionJobInfo
,
size
:
*
mut
size_t
,
...
...
src/event_listener.rs
View file @
dc16c9b1
...
...
@@ -60,6 +60,11 @@ impl FlushJobInfo {
pub
struct
CompactionJobInfo
(
DBCompactionJobInfo
);
impl
CompactionJobInfo
{
pub
fn
status
(
&
self
)
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_compactionjobinfo_status
(
&
self
.
0
))
}
Ok
(())
}
pub
fn
cf_name
(
&
self
)
->
&
str
{
unsafe
{
fetch_str!
(
crocksdb_compactionjobinfo_cf_name
(
&
self
.
0
))
}
}
...
...
src/table_properties.rs
View file @
dc16c9b1
...
...
@@ -81,19 +81,25 @@ impl<'a> Iterator for TablePropertiesCollectionIter<'a> {
fn
next
(
&
mut
self
)
->
Option
<
(
&
'a
str
,
&
'a
TableProperties
)
>
{
unsafe
{
if
!
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_valid
(
self
.inner
)
{
return
None
;
loop
{
if
!
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_valid
(
self
.inner
)
{
return
None
;
}
let
mut
klen
:
size_t
=
0
;
let
k
=
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_key
(
self
.inner
,
&
mut
klen
,
);
let
bytes
=
slice
::
from_raw_parts
(
k
,
klen
);
let
key
=
str
::
from_utf8
(
bytes
)
.unwrap
();
let
props
=
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_value
(
self
.inner
);
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_next
(
self
.inner
);
if
!
props
.is_null
()
{
let
val
=
TableProperties
::
from_ptr
(
props
);
return
Some
((
key
,
val
));
}
}
let
mut
klen
:
size_t
=
0
;
let
k
=
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_key
(
self
.inner
,
&
mut
klen
);
let
bytes
=
slice
::
from_raw_parts
(
k
,
klen
);
let
key
=
str
::
from_utf8
(
bytes
)
.unwrap
();
let
props
=
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_value
(
self
.inner
);
let
val
=
TableProperties
::
from_ptr
(
props
);
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_next
(
self
.inner
);
Some
((
key
,
val
))
}
}
}
...
...
tests/cases/test_event_listener.rs
View file @
dc16c9b1
...
...
@@ -45,6 +45,7 @@ impl EventListener for EventCounter {
}
fn
on_compaction_completed
(
&
self
,
info
:
&
CompactionJobInfo
)
{
info
.status
()
.unwrap
();
assert
!
(
!
info
.cf_name
()
.is_empty
());
let
input_file_count
=
info
.input_file_count
();
assert_ne!
(
input_file_count
,
0
);
...
...
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