diff --git a/HISTORY.md b/HISTORY.md index 2f20ecbe3..28f2b64f0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -7,6 +7,7 @@ * RollbackToSavePoint() in WriteBatch/WriteBatchWithIndex * Add NewCompactOnDeletionCollectorFactory() in utilities/table_properties_collectors, which allows rocksdb to mark a SST file as need-compaction when it observes at least D deletion entries in any N consecutive entries in that SST file. Note that this feature depends on an experimental NeedCompact() API --- the result of this API will not persist after DB restart. * Add DBOptions::delete_scheduler. Use NewDeleteScheduler() in include/rocksdb/delete_scheduler.h to create a DeleteScheduler that can be shared among multiple RocksDB instances to control the file deletion rate of SST files that exist in the first db_path. +* Add statistics::getHistogramString() to print detailed distribution of a histogram metric. ### Public API Changes * Deprecated WriteOptions::timeout_hint_us. We no longer support write timeout. If you really need this option, talk to us and we might consider returning it. diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 61a9958ae..79c77766a 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -295,7 +295,7 @@ class Statistics { virtual uint64_t getTickerCount(uint32_t tickerType) const = 0; virtual void histogramData(uint32_t type, HistogramData* const data) const = 0; - + virtual std::string getHistogramString(uint32_t type) const { return ""; } virtual void recordTick(uint32_t tickerType, uint64_t count = 0) = 0; virtual void setTickerCount(uint32_t tickerType, uint64_t count) = 0; virtual void measureTime(uint32_t histogramType, uint64_t time) = 0; diff --git a/util/statistics.cc b/util/statistics.cc index ba7670bb4..f06589a17 100644 --- a/util/statistics.cc +++ b/util/statistics.cc @@ -50,6 +50,12 @@ void StatisticsImpl::histogramData(uint32_t histogramType, histograms_[histogramType].Data(data); } +std::string StatisticsImpl::getHistogramString(uint32_t histogramType) const { + assert(enable_internal_stats_ ? histogramType < INTERNAL_HISTOGRAM_ENUM_MAX + : histogramType < HISTOGRAM_ENUM_MAX); + return histograms_[histogramType].ToString(); +} + void StatisticsImpl::setTickerCount(uint32_t tickerType, uint64_t count) { assert( enable_internal_stats_ ? diff --git a/util/statistics.h b/util/statistics.h index c56900acc..55914f59e 100644 --- a/util/statistics.h +++ b/util/statistics.h @@ -37,6 +37,7 @@ class StatisticsImpl : public Statistics { virtual uint64_t getTickerCount(uint32_t ticker_type) const override; virtual void histogramData(uint32_t histogram_type, HistogramData* const data) const override; + std::string getHistogramString(uint32_t histogram_type) const override; virtual void setTickerCount(uint32_t ticker_type, uint64_t count) override; virtual void recordTick(uint32_t ticker_type, uint64_t count) override;