From eeb44366bae1dfc26e01db9f77c30c2179c134a8 Mon Sep 17 00:00:00 2001 From: Holodov Alexander Date: Sat, 16 May 2015 12:34:28 +0400 Subject: [PATCH] C api: human-readable statistics --- db/c.cc | 8 ++++++++ include/rocksdb/c.h | 1 + 2 files changed, 9 insertions(+) diff --git a/db/c.cc b/db/c.cc index fbf2c4ef0..0138acf6a 100644 --- a/db/c.cc +++ b/db/c.cc @@ -1930,6 +1930,14 @@ void rocksdb_options_set_fifo_compaction_options( opt->rep.compaction_options_fifo = fifo->rep; } +char *rocksdb_options_statistics_get_string(rocksdb_options_t *opt) { + rocksdb::Statistics *statistics = opt->rep.statistics.get(); + if (statistics) { + return strdup(statistics->ToString().c_str()); + } + return nullptr; +} + /* TODO: DB::OpenForReadOnly diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 06cf65bd1..3a426d24c 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -601,6 +601,7 @@ extern void rocksdb_options_set_max_grandparent_overlap_factor( extern void rocksdb_options_set_max_bytes_for_level_multiplier_additional( rocksdb_options_t*, int* level_values, size_t num_levels); extern void rocksdb_options_enable_statistics(rocksdb_options_t*); +extern char *rocksdb_options_statistics_get_string(rocksdb_options_t *opt); extern void rocksdb_options_set_max_write_buffer_number(rocksdb_options_t*, int); extern void rocksdb_options_set_min_write_buffer_number_to_merge(rocksdb_options_t*, int);