### Public API change
* Remove obsolete implementation details FullKey and ParseFullKey from public API
* Add a public API RateLimiter::GetTotalPendingRequests() for the total number of requests that are pending for bytes in the rate limiter.
+* Made Statistics extend the Customizable class and added a CreateFromString method. Implementations of Statistics need to be registered with the ObjectRegistry and to implement a Name() method in order to be created via this method.
* Extended `FlushJobInfo` and `CompactionJobInfo` in listener.h to provide information about the blob files generated by a flush/compaction and garbage collected during compaction in Integrated BlobDB. Added struct members `blob_file_addition_infos` and `blob_file_garbage_infos` that contain this information.
* Extended parameter `output_file_names` of `CompactFiles` API to also include paths of the blob files generated by the compaction in Integrated BlobDB.
static Status CreateFromString(const ConfigOptions& opts,
const std::string& value,
std::shared_ptr<Statistics>* result);
+ // Default name of empty, for backwards compatibility. Derived classes should
+ // override this method.
+ // This default implementation will likely be removed in a future release
+ const char* Name() const override { return ""; }
virtual uint64_t getTickerCount(uint32_t tickerType) const = 0;
virtual void histogramData(uint32_t type,
HistogramData* const data) const = 0;
// Resets all ticker and histogram stats
virtual Status Reset() { return Status::NotSupported("Not implemented"); }
+#ifndef ROCKSDB_LITE
+ using Customizable::ToString;
+#endif // ROCKSDB_LITE
// String representation of the statistic object. Must be thread-safe.
virtual std::string ToString() const {
// Do nothing by default
// (found in the LICENSE.Apache file in the root directory).
//
+#include "rocksdb/statistics.h"
+
#include "port/stack_trace.h"
+#include "rocksdb/convenience.h"
+#include "rocksdb/utilities/options_type.h"
#include "test_util/testharness.h"
#include "test_util/testutil.h"
-#include "rocksdb/statistics.h"
-
namespace ROCKSDB_NAMESPACE {
class StatisticsTest : public testing::Test {};
}
}
+TEST_F(StatisticsTest, NoNameStats) {
+ static std::unordered_map<std::string, OptionTypeInfo> no_name_opt_info = {
+#ifndef ROCKSDB_LITE
+ {"inner",
+ OptionTypeInfo::AsCustomSharedPtr<Statistics>(
+ 0, OptionVerificationType::kByName,
+ OptionTypeFlags::kAllowNull | OptionTypeFlags::kCompareNever)},
+#endif // ROCKSDB_LITE
+ };
+
+ class DefaultNameStatistics : public Statistics {
+ public:
+ DefaultNameStatistics(const std::shared_ptr<Statistics>& stats = nullptr)
+ : inner(stats) {
+ RegisterOptions("", &inner, &no_name_opt_info);
+ }
+
+ uint64_t getTickerCount(uint32_t /*tickerType*/) const override {
+ return 0;
+ }
+ void histogramData(uint32_t /*type*/,
+ HistogramData* const /*data*/) const override {}
+ void recordTick(uint32_t /*tickerType*/, uint64_t /*count*/) override {}
+ void setTickerCount(uint32_t /*tickerType*/, uint64_t /*count*/) override {}
+ uint64_t getAndResetTickerCount(uint32_t /*tickerType*/) override {
+ return 0;
+ }
+ std::shared_ptr<Statistics> inner;
+ };
+ ConfigOptions options;
+ options.ignore_unsupported_options = false;
+ auto stats = std::make_shared<DefaultNameStatistics>();
+ ASSERT_STREQ(stats->Name(), "");
+#ifndef ROCKSDB_LITE
+ ASSERT_EQ("", stats->ToString(
+ options)); // A stats with no name with have no options...
+ ASSERT_OK(stats->ConfigureFromString(options, "inner="));
+ ASSERT_EQ("", stats->ToString(
+ options)); // A stats with no name with have no options...
+ ASSERT_NE(stats->inner, nullptr);
+ ASSERT_NE("", stats->inner->ToString(options)); // ... even if it does...
+#endif // ROCKSDB_LITE
+}
} // namespace ROCKSDB_NAMESPACE
int main(int argc, char** argv) {