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
76587cac
Unverified
Commit
76587cac
authored
Jan 09, 2018
by
zhangjinpeng1987
Committed by
GitHub
Jan 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more api for CompactionJobInfo (#183)
parent
aa576395
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
0 deletions
+71
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+20
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+12
-0
lib.rs
librocksdb_sys/src/lib.rs
+4
-0
event_listener.rs
src/event_listener.rs
+16
-0
test_event_listener.rs
tests/test_event_listener.rs
+19
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
76587cac
...
...
@@ -1712,6 +1712,26 @@ int crocksdb_compactionjobinfo_output_level(
return
info
->
rep
.
output_level
;
}
uint64_t
crocksdb_compactionjobinfo_input_records
(
const
crocksdb_compactionjobinfo_t
*
info
)
{
return
info
->
rep
.
stats
.
num_input_records
;
}
uint64_t
crocksdb_compactionjobinfo_output_records
(
const
crocksdb_compactionjobinfo_t
*
info
)
{
return
info
->
rep
.
stats
.
num_output_records
;
}
uint64_t
crocksdb_compactionjobinfo_total_input_bytes
(
const
crocksdb_compactionjobinfo_t
*
info
)
{
return
info
->
rep
.
stats
.
total_input_bytes
;
}
uint64_t
crocksdb_compactionjobinfo_total_output_bytes
(
const
crocksdb_compactionjobinfo_t
*
info
)
{
return
info
->
rep
.
stats
.
total_output_bytes
;
}
/* ExternalFileIngestionInfo */
const
char
*
crocksdb_externalfileingestioninfo_cf_name
(
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
76587cac
...
...
@@ -644,6 +644,18 @@ crocksdb_compactionjobinfo_num_corrupt_keys(
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_compactionjobinfo_output_level
(
const
crocksdb_compactionjobinfo_t
*
);
extern
C_ROCKSDB_LIBRARY_API
uint64_t
crocksdb_compactionjobinfo_input_records
(
const
crocksdb_compactionjobinfo_t
*
);
extern
C_ROCKSDB_LIBRARY_API
uint64_t
crocksdb_compactionjobinfo_output_records
(
const
crocksdb_compactionjobinfo_t
*
);
extern
C_ROCKSDB_LIBRARY_API
uint64_t
crocksdb_compactionjobinfo_total_input_bytes
(
const
crocksdb_compactionjobinfo_t
*
info
);
extern
C_ROCKSDB_LIBRARY_API
uint64_t
crocksdb_compactionjobinfo_total_output_bytes
(
const
crocksdb_compactionjobinfo_t
*
info
);
/* External file ingestion info */
...
...
librocksdb_sys/src/lib.rs
View file @
76587cac
...
...
@@ -1462,6 +1462,10 @@ extern "C" {
info
:
*
const
DBCompactionJobInfo
,
)
->
uint64_t
;
pub
fn
crocksdb_compactionjobinfo_output_level
(
info
:
*
const
DBCompactionJobInfo
)
->
c_int
;
pub
fn
crocksdb_compactionjobinfo_input_records
(
info
:
*
const
DBCompactionJobInfo
)
->
uint64_t
;
pub
fn
crocksdb_compactionjobinfo_output_records
(
info
:
*
const
DBCompactionJobInfo
)
->
uint64_t
;
pub
fn
crocksdb_compactionjobinfo_total_input_bytes
(
info
:
*
const
DBCompactionJobInfo
)
->
uint64_t
;
pub
fn
crocksdb_compactionjobinfo_total_output_bytes
(
info
:
*
const
DBCompactionJobInfo
)
->
uint64_t
;
pub
fn
crocksdb_externalfileingestioninfo_cf_name
(
info
:
*
const
DBIngestionInfo
,
...
...
src/event_listener.rs
View file @
76587cac
...
...
@@ -92,6 +92,22 @@ impl CompactionJobInfo {
pub
fn
output_level
(
&
self
)
->
i32
{
unsafe
{
crocksdb_ffi
::
crocksdb_compactionjobinfo_output_level
(
&
self
.
0
)
}
}
pub
fn
input_records
(
&
self
)
->
u64
{
unsafe
{
crocksdb_ffi
::
crocksdb_compactionjobinfo_input_records
(
&
self
.
0
)
}
}
pub
fn
output_records
(
&
self
)
->
u64
{
unsafe
{
crocksdb_ffi
::
crocksdb_compactionjobinfo_output_records
(
&
self
.
0
)
}
}
pub
fn
total_input_bytes
(
&
self
)
->
u64
{
unsafe
{
crocksdb_ffi
::
crocksdb_compactionjobinfo_total_input_bytes
(
&
self
.
0
)
}
}
pub
fn
total_output_bytes
(
&
self
)
->
u64
{
unsafe
{
crocksdb_ffi
::
crocksdb_compactionjobinfo_total_output_bytes
(
&
self
.
0
)
}
}
}
pub
struct
IngestionInfo
(
DBIngestionInfo
);
...
...
tests/test_event_listener.rs
View file @
76587cac
...
...
@@ -25,6 +25,10 @@ struct EventCounter {
compaction
:
Arc
<
AtomicUsize
>
,
ingestion
:
Arc
<
AtomicUsize
>
,
drop_count
:
Arc
<
AtomicUsize
>
,
input_records
:
Arc
<
AtomicUsize
>
,
output_records
:
Arc
<
AtomicUsize
>
,
input_bytes
:
Arc
<
AtomicUsize
>
,
output_bytes
:
Arc
<
AtomicUsize
>
,
}
impl
Drop
for
EventCounter
{
...
...
@@ -65,6 +69,14 @@ impl EventListener for EventCounter {
assert
!
(
info
.output_level
()
>=
0
);
self
.compaction
.fetch_add
(
1
,
Ordering
::
SeqCst
);
self
.input_records
.fetch_add
(
info
.input_records
()
as
usize
,
Ordering
::
SeqCst
);
self
.output_records
.fetch_add
(
info
.output_records
()
as
usize
,
Ordering
::
SeqCst
);
self
.input_bytes
.fetch_add
(
info
.total_input_bytes
()
as
usize
,
Ordering
::
SeqCst
);
self
.output_bytes
.fetch_add
(
info
.total_output_bytes
()
as
usize
,
Ordering
::
SeqCst
);
}
fn
on_external_file_ingested
(
&
self
,
info
:
&
IngestionInfo
)
{
...
...
@@ -109,6 +121,13 @@ fn test_event_listener_basic() {
assert_ne!
(
counter
.compaction
.load
(
Ordering
::
SeqCst
),
0
);
drop
(
db
);
assert_eq!
(
counter
.drop_count
.load
(
Ordering
::
SeqCst
),
1
);
assert
!
(
counter
.input_records
.load
(
Ordering
::
SeqCst
)
>
counter
.output_records
.load
(
Ordering
::
SeqCst
)
);
assert
!
(
counter
.input_bytes
.load
(
Ordering
::
SeqCst
)
>
counter
.output_bytes
.load
(
Ordering
::
SeqCst
)
);
}
#[test]
...
...
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