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
20d39998
Commit
20d39998
authored
Dec 06, 2017
by
Huachao Huang
Committed by
zhangjinpeng1987
Dec 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and test when disable statistics (#172)
parent
5e3bfdc7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
c.cc
librocksdb_sys/crocksdb/c.cc
+8
-2
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+10
-0
test_statistics.rs
tests/test_statistics.rs
+32
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
20d39998
...
...
@@ -1607,7 +1607,10 @@ size_t crocksdb_options_get_block_cache_usage(crocksdb_options_t *opt) {
if
(
opt
&&
opt
->
rep
.
table_factory
!=
nullptr
)
{
void
*
table_opt
=
opt
->
rep
.
table_factory
->
GetOptions
();
if
(
table_opt
&&
strcmp
(
opt
->
rep
.
table_factory
->
Name
(),
block_base_table_str
)
==
0
)
{
return
static_cast
<
BlockBasedTableOptions
*>
(
table_opt
)
->
block_cache
->
GetUsage
();
auto
opts
=
static_cast
<
BlockBasedTableOptions
*>
(
table_opt
);
if
(
opts
->
block_cache
)
{
return
opts
->
block_cache
->
GetUsage
();
}
}
}
return
0
;
...
...
@@ -1966,7 +1969,10 @@ void crocksdb_options_enable_statistics(crocksdb_options_t* opt, unsigned char v
}
void
crocksdb_options_reset_statistics
(
crocksdb_options_t
*
opt
)
{
opt
->
rep
.
statistics
->
Reset
();
auto
statistics
=
opt
->
rep
.
statistics
.
get
();
if
(
statistics
)
{
statistics
->
Reset
();
}
}
void
crocksdb_options_set_num_levels
(
crocksdb_options_t
*
opt
,
int
n
)
{
...
...
tests/test_rocksdb_options.rs
View file @
20d39998
...
...
@@ -369,6 +369,16 @@ fn test_get_block_cache_usage() {
assert
!
(
db
.get_options
()
.get_block_cache_usage
()
>
0
);
}
#[test]
fn
test_disable_block_cache
()
{
let
mut
cf_opts
=
ColumnFamilyOptions
::
new
();
assert_eq!
(
cf_opts
.get_block_cache_usage
(),
0
);
let
mut
block_opts
=
BlockBasedOptions
::
new
();
block_opts
.set_no_block_cache
(
true
);
cf_opts
.set_block_based_table_factory
(
&
block_opts
);
assert_eq!
(
cf_opts
.get_block_cache_usage
(),
0
);
}
#[test]
fn
test_set_level_compaction_dynamic_level_bytes
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_level_compaction_dynamic_level_bytes"
)
.expect
(
""
);
...
...
tests/test_statistics.rs
View file @
20d39998
...
...
@@ -52,3 +52,35 @@ fn test_db_statistics() {
.unwrap
();
assert_eq!
(
get_micros
.max
,
0.0
);
}
#[test]
fn
test_disable_db_statistics
()
{
let
path
=
TempDir
::
new
(
"_rust_rocksdb_statistics"
)
.expect
(
""
);
let
mut
opts
=
DBOptions
::
new
();
opts
.create_if_missing
(
true
);
opts
.enable_statistics
(
false
);
let
db
=
DB
::
open
(
opts
,
path
.path
()
.to_str
()
.unwrap
())
.unwrap
();
let
wopts
=
WriteOptions
::
new
();
db
.put_opt
(
b
"k0"
,
b
"a"
,
&
wopts
)
.unwrap
();
db
.put_opt
(
b
"k1"
,
b
"b"
,
&
wopts
)
.unwrap
();
db
.put_opt
(
b
"k2"
,
b
"c"
,
&
wopts
)
.unwrap
();
db
.flush
(
true
/* sync */
)
.unwrap
();
// flush memtable to sst file.
assert_eq!
(
db
.get
(
b
"k0"
)
.unwrap
()
.unwrap
(),
b
"a"
);
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"b"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"c"
);
assert_eq!
(
db
.get_statistics_ticker_count
(
TickerType
::
BlockCacheHit
),
0
);
assert_eq!
(
db
.get_and_reset_statistics_ticker_count
(
TickerType
::
BlockCacheHit
),
0
);
assert
!
(
db
.get_statistics_histogram_string
(
HistogramType
::
GetMicros
)
.is_none
()
);
assert
!
(
db
.get_statistics_histogram
(
HistogramType
::
GetMicros
)
.is_none
()
);
}
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