mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-29 18:33:58 +00:00
62247ffa3b
Summary: When using latest clang (3.6 or 3.7/trunck) rocksdb is failing with many errors. Almost all of them are missing override errors. This diff adds missing override keyword. No manual changes. Prerequisites: bear and clang 3.5 build with extra tools ```lang=bash % USE_CLANG=1 bear make all # generate a compilation database http://clang.llvm.org/docs/JSONCompilationDatabase.html % clang-modernize -p . -include . -add-override % make format ``` Test Plan: Make sure all tests are passing. ```lang=bash % #Use default fb code clang. % make check ``` Verify less error and no missing override errors. ```lang=bash % # Have trunk clang present in path. % ROCKSDB_NO_FBCODE=1 CC=clang CXX=clang++ make ``` Reviewers: igor, kradhakrishnan, rven, meyering, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D34077
96 lines
2.9 KiB
C++
96 lines
2.9 KiB
C++
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under the BSD-style license found in the
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
//
|
|
// This file defines a collection of statistics collectors.
|
|
#pragma once
|
|
|
|
#include "rocksdb/table_properties.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace rocksdb {
|
|
|
|
struct InternalKeyTablePropertiesNames {
|
|
static const std::string kDeletedKeys;
|
|
};
|
|
|
|
// Collecting the statistics for internal keys. Visible only by internal
|
|
// rocksdb modules.
|
|
class InternalKeyPropertiesCollector : public TablePropertiesCollector {
|
|
public:
|
|
virtual Status Add(const Slice& key, const Slice& value) override;
|
|
|
|
virtual Status Finish(UserCollectedProperties* properties) override;
|
|
|
|
virtual const char* Name() const override {
|
|
return "InternalKeyPropertiesCollector";
|
|
}
|
|
|
|
UserCollectedProperties GetReadableProperties() const override;
|
|
|
|
private:
|
|
uint64_t deleted_keys_ = 0;
|
|
};
|
|
|
|
class InternalKeyPropertiesCollectorFactory
|
|
: public TablePropertiesCollectorFactory {
|
|
public:
|
|
virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
|
|
return new InternalKeyPropertiesCollector();
|
|
}
|
|
|
|
virtual const char* Name() const override {
|
|
return "InternalKeyPropertiesCollectorFactory";
|
|
}
|
|
};
|
|
|
|
// When rocksdb creates a new table, it will encode all "user keys" into
|
|
// "internal keys", which contains meta information of a given entry.
|
|
//
|
|
// This class extracts user key from the encoded internal key when Add() is
|
|
// invoked.
|
|
class UserKeyTablePropertiesCollector : public TablePropertiesCollector {
|
|
public:
|
|
// transfer of ownership
|
|
explicit UserKeyTablePropertiesCollector(TablePropertiesCollector* collector)
|
|
: collector_(collector) {}
|
|
|
|
virtual ~UserKeyTablePropertiesCollector() {}
|
|
|
|
virtual Status Add(const Slice& key, const Slice& value) override;
|
|
|
|
virtual Status Finish(UserCollectedProperties* properties) override;
|
|
|
|
virtual const char* Name() const override { return collector_->Name(); }
|
|
|
|
UserCollectedProperties GetReadableProperties() const override;
|
|
|
|
protected:
|
|
std::unique_ptr<TablePropertiesCollector> collector_;
|
|
};
|
|
|
|
class UserKeyTablePropertiesCollectorFactory
|
|
: public TablePropertiesCollectorFactory {
|
|
public:
|
|
explicit UserKeyTablePropertiesCollectorFactory(
|
|
std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
|
|
: user_collector_factory_(user_collector_factory) {}
|
|
virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
|
|
return new UserKeyTablePropertiesCollector(
|
|
user_collector_factory_->CreateTablePropertiesCollector());
|
|
}
|
|
|
|
virtual const char* Name() const override {
|
|
return user_collector_factory_->Name();
|
|
}
|
|
|
|
private:
|
|
std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory_;
|
|
};
|
|
|
|
} // namespace rocksdb
|