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
f8870b44
Commit
f8870b44
authored
Jan 26, 2019
by
DorianZheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix event listener bug (#267)
(cherry picked from commit
dc16c9b1
)
parent
c912ea07
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 @
f8870b44
...
@@ -1821,6 +1821,11 @@ bool crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t*
...
@@ -1821,6 +1821,11 @@ bool crocksdb_flushjobinfo_triggered_writes_stop(const crocksdb_flushjobinfo_t*
/* CompactionJobInfo */
/* CompactionJobInfo */
void
crocksdb_compactionjobinfo_status
(
const
crocksdb_compactionjobinfo_t
*
info
,
char
**
errptr
)
{
SaveError
(
errptr
,
info
->
rep
.
status
);
}
const
char
*
crocksdb_compactionjobinfo_cf_name
(
const
char
*
crocksdb_compactionjobinfo_cf_name
(
const
crocksdb_compactionjobinfo_t
*
info
,
size_t
*
size
)
{
const
crocksdb_compactionjobinfo_t
*
info
,
size_t
*
size
)
{
*
size
=
info
->
rep
.
cf_name
.
size
();
*
size
=
info
->
rep
.
cf_name
.
size
();
...
@@ -4086,8 +4091,12 @@ const char* crocksdb_table_properties_collection_iter_key(
...
@@ -4086,8 +4091,12 @@ const char* crocksdb_table_properties_collection_iter_key(
const
crocksdb_table_properties_t
*
const
crocksdb_table_properties_t
*
crocksdb_table_properties_collection_iter_value
(
crocksdb_table_properties_collection_iter_value
(
const
crocksdb_table_properties_collection_iterator_t
*
it
)
{
const
crocksdb_table_properties_collection_iterator_t
*
it
)
{
return
reinterpret_cast
<
const
crocksdb_table_properties_t
*>
(
if
(
it
->
cur_
->
second
)
{
it
->
cur_
->
second
.
get
());
return
reinterpret_cast
<
const
crocksdb_table_properties_t
*>
(
it
->
cur_
->
second
.
get
());
}
else
{
return
nullptr
;
}
}
}
/* Table Properties Collector */
/* Table Properties Collector */
...
...
librocksdb_sys/src/lib.rs
View file @
f8870b44
...
@@ -1507,6 +1507,10 @@ extern "C" {
...
@@ -1507,6 +1507,10 @@ extern "C" {
pub
fn
crocksdb_flushjobinfo_triggered_writes_slowdown
(
info
:
*
const
DBFlushJobInfo
)
->
bool
;
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_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
(
pub
fn
crocksdb_compactionjobinfo_cf_name
(
info
:
*
const
DBCompactionJobInfo
,
info
:
*
const
DBCompactionJobInfo
,
size
:
*
mut
size_t
,
size
:
*
mut
size_t
,
...
...
src/event_listener.rs
View file @
f8870b44
...
@@ -60,6 +60,11 @@ impl FlushJobInfo {
...
@@ -60,6 +60,11 @@ impl FlushJobInfo {
pub
struct
CompactionJobInfo
(
DBCompactionJobInfo
);
pub
struct
CompactionJobInfo
(
DBCompactionJobInfo
);
impl
CompactionJobInfo
{
impl
CompactionJobInfo
{
pub
fn
status
(
&
self
)
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_compactionjobinfo_status
(
&
self
.
0
))
}
Ok
(())
}
pub
fn
cf_name
(
&
self
)
->
&
str
{
pub
fn
cf_name
(
&
self
)
->
&
str
{
unsafe
{
fetch_str!
(
crocksdb_compactionjobinfo_cf_name
(
&
self
.
0
))
}
unsafe
{
fetch_str!
(
crocksdb_compactionjobinfo_cf_name
(
&
self
.
0
))
}
}
}
...
...
src/table_properties.rs
View file @
f8870b44
...
@@ -81,19 +81,25 @@ impl<'a> Iterator for TablePropertiesCollectionIter<'a> {
...
@@ -81,19 +81,25 @@ impl<'a> Iterator for TablePropertiesCollectionIter<'a> {
fn
next
(
&
mut
self
)
->
Option
<
(
&
'a
str
,
&
'a
TableProperties
)
>
{
fn
next
(
&
mut
self
)
->
Option
<
(
&
'a
str
,
&
'a
TableProperties
)
>
{
unsafe
{
unsafe
{
if
!
crocksdb_ffi
::
crocksdb_table_properties_collection_iter_valid
(
self
.inner
)
{
loop
{
return
None
;
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 @
f8870b44
...
@@ -45,6 +45,7 @@ impl EventListener for EventCounter {
...
@@ -45,6 +45,7 @@ impl EventListener for EventCounter {
}
}
fn
on_compaction_completed
(
&
self
,
info
:
&
CompactionJobInfo
)
{
fn
on_compaction_completed
(
&
self
,
info
:
&
CompactionJobInfo
)
{
info
.status
()
.unwrap
();
assert
!
(
!
info
.cf_name
()
.is_empty
());
assert
!
(
!
info
.cf_name
()
.is_empty
());
let
input_file_count
=
info
.input_file_count
();
let
input_file_count
=
info
.input_file_count
();
assert_ne!
(
input_file_count
,
0
);
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