ClickHouse/src/Storages/MergeTree/MergeTreeMetadataCache.h

45 lines
1.1 KiB
C++
Raw Normal View History

2021-12-29 04:31:54 +00:00
#pragma once
2021-12-29 08:20:29 +00:00
#include "config_core.h"
2021-12-29 04:31:54 +00:00
2021-12-29 08:20:29 +00:00
#if USE_ROCKSDB
2021-12-29 04:31:54 +00:00
#include <base/types.h>
#include <Core/Types.h>
#include <Poco/Logger.h>
2021-12-29 08:20:29 +00:00
#include <rocksdb/table.h>
#include <rocksdb/db.h>
2021-12-29 04:31:54 +00:00
namespace DB
{
class MergeTreeMetadataCache
{
public:
using Status = rocksdb::Status;
2022-01-04 03:48:07 +00:00
explicit MergeTreeMetadataCache(rocksdb::DB * rocksdb_) : rocksdb{rocksdb_}
{
assert(rocksdb);
}
2022-01-13 07:27:41 +00:00
static std::unique_ptr<MergeTreeMetadataCache> create(const String & dir, size_t size);
2021-12-29 04:31:54 +00:00
MergeTreeMetadataCache(const MergeTreeMetadataCache &) = delete;
MergeTreeMetadataCache & operator=(const MergeTreeMetadataCache &) = delete;
Status put(const String & key, const String & value);
Status del(const String & key);
Status get(const String & key, String & value);
void getByPrefix(const String & prefix, Strings & keys, Strings & values);
2022-01-10 04:20:39 +00:00
uint64_t getEstimateNumKeys() const;
2021-12-29 04:31:54 +00:00
void shutdown();
private:
std::unique_ptr<rocksdb::DB> rocksdb;
Poco::Logger * log = &Poco::Logger::get("MergeTreeMetadataCache");
};
using MergeTreeMetadataCachePtr = std::shared_ptr<MergeTreeMetadataCache>;
}
#endif