mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-30 04:41:49 +00:00
1415f8820d
Summary: The primary motivation of the changes is to make it easier to figure out the inside of the tables. * rename "table stats" to "table properties" since now we have more than "integers" to store in the property block. * Add filter block size to the basic table properties. * Whenever a table is built, we'll log the table properties (the sample output is in Test Plan). * Make an api to expose deleted keys. Test Plan: Passed all existing test. and the sample output of table stats: ================================================================== Basic Properties ------------------------------------------------------------------ # data blocks: 1 # entries: 1 raw key size: 9 raw average key size: 9 raw value size: 9 raw average value size: 0 data block size: 25 index block size: 27 filter block size: 18 (estimated) table size: 70 filter policy: rocksdb.BuiltinBloomFilter ================================================================== User collected properties: InternalKeyPropertiesCollector ------------------------------------------------------------------ kDeletedKeys: 1 ================================================================== Reviewers: dhruba, haobo Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D14187
77 lines
2.2 KiB
C++
77 lines
2.2 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(
|
|
TableProperties::UserCollectedProperties* properties) override;
|
|
|
|
virtual const char* Name() const override {
|
|
return "InternalKeyPropertiesCollector";
|
|
}
|
|
|
|
TableProperties::UserCollectedProperties
|
|
GetReadableProperties() const override;
|
|
|
|
private:
|
|
uint64_t deleted_keys_ = 0;
|
|
};
|
|
|
|
// 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:
|
|
explicit UserKeyTablePropertiesCollector(
|
|
TablePropertiesCollector* collector) :
|
|
UserKeyTablePropertiesCollector(
|
|
std::shared_ptr<TablePropertiesCollector>(collector)
|
|
) {
|
|
}
|
|
|
|
explicit UserKeyTablePropertiesCollector(
|
|
std::shared_ptr<TablePropertiesCollector> collector) :
|
|
collector_(collector) {
|
|
}
|
|
|
|
virtual ~UserKeyTablePropertiesCollector() { }
|
|
|
|
virtual Status Add(const Slice& key, const Slice& value) override;
|
|
|
|
virtual Status Finish(
|
|
TableProperties::UserCollectedProperties* properties) override;
|
|
|
|
virtual const char* Name() const override { return collector_->Name(); }
|
|
|
|
TableProperties::UserCollectedProperties
|
|
GetReadableProperties() const override;
|
|
|
|
protected:
|
|
std::shared_ptr<TablePropertiesCollector> collector_;
|
|
};
|
|
|
|
} // namespace rocksdb
|