1
0
Fork 0

fix access to cache object if cache is turned off (#2782)

This commit is contained in:
Jan 2017-07-12 22:11:50 +02:00 committed by Frank Celler
parent 71434ef566
commit 722870b70c
1 changed files with 13 additions and 4 deletions

View File

@ -1593,10 +1593,19 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
if (_options.table_factory) {
void* options = _options.table_factory->GetOptions();
if (options != nullptr) {
builder.add(
"rocksdb.block-cache-used",
VPackValue(static_cast<rocksdb::BlockBasedTableOptions*>(options)
->block_cache->GetUsage()));
auto* bto = static_cast<rocksdb::BlockBasedTableOptions*>(options);
if (bto != nullptr && bto->block_cache != nullptr) {
// block cache is present
builder.add(
"rocksdb.block-cache-used",
VPackValue(bto->block_cache->GetUsage()));
} else {
// no block cache present
builder.add(
"rocksdb.block-cache-used",
VPackValue(0));
}
}
}