2022-01-05 11:51:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-01-07 10:37:08 +00:00
|
|
|
#include <unordered_map>
|
2022-01-05 11:51:50 +00:00
|
|
|
#include <city.h>
|
|
|
|
#include <base/types.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class IMergeTreeDataPart;
|
|
|
|
|
2022-05-29 07:28:02 +00:00
|
|
|
class ReadBuffer;
|
2022-01-05 11:51:50 +00:00
|
|
|
class SeekableReadBuffer;
|
|
|
|
|
|
|
|
class IDisk;
|
|
|
|
using DiskPtr = std::shared_ptr<IDisk>;
|
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Interface for managing metadata of merge tree part.
|
|
|
|
/// IPartMetadataManager has two implementations:
|
|
|
|
/// - PartMetadataManagerOrdinary: manage metadata from disk directly. deleteAll/assertAllDeleted/updateAll/check
|
|
|
|
/// are all empty implementations because they are not needed for PartMetadataManagerOrdinary(those operations
|
|
|
|
/// are done implicitly when removing or renaming part directory).
|
|
|
|
/// - PartMetadataManagerWithCache: manage metadata from RocksDB cache and disk.
|
2022-01-05 11:51:50 +00:00
|
|
|
class IPartMetadataManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using uint128 = CityHash_v1_0_2::uint128;
|
|
|
|
|
|
|
|
explicit IPartMetadataManager(const IMergeTreeDataPart * part_);
|
|
|
|
|
|
|
|
virtual ~IPartMetadataManager() = default;
|
|
|
|
|
2022-05-29 07:28:02 +00:00
|
|
|
/// Read metadata content and return ReadBuffer object.
|
|
|
|
virtual std::unique_ptr<ReadBuffer> read(const String & file_name) const = 0;
|
2022-01-05 11:51:50 +00:00
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Return true if metadata exists in part.
|
2022-01-05 11:51:50 +00:00
|
|
|
virtual bool exists(const String & file_name) const = 0;
|
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Delete all metadatas in part.
|
|
|
|
/// If include_projection is true, also delete metadatas in projection parts.
|
2022-01-05 11:51:50 +00:00
|
|
|
virtual void deleteAll(bool include_projection) = 0;
|
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Assert that all metadatas in part are deleted.
|
|
|
|
/// If include_projection is true, also assert that all metadatas in projection parts are deleted.
|
2022-01-05 11:51:50 +00:00
|
|
|
virtual void assertAllDeleted(bool include_projection) const = 0;
|
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Update all metadatas in part.
|
|
|
|
/// If include_projection is true, also update metadatas in projection parts.
|
2022-01-05 11:51:50 +00:00
|
|
|
virtual void updateAll(bool include_projection) = 0;
|
|
|
|
|
2022-01-10 03:45:06 +00:00
|
|
|
/// Check all metadatas in part.
|
2022-01-07 10:37:08 +00:00
|
|
|
virtual std::unordered_map<String, uint128> check() const = 0;
|
|
|
|
|
2022-05-29 07:28:02 +00:00
|
|
|
/// Determine whether to compress by file extension
|
2022-08-28 02:19:14 +00:00
|
|
|
static bool isCompressedFromFileName(const String & file_name);
|
2022-05-29 07:28:02 +00:00
|
|
|
|
2022-01-05 11:51:50 +00:00
|
|
|
protected:
|
|
|
|
const IMergeTreeDataPart * part;
|
|
|
|
};
|
|
|
|
|
|
|
|
using PartMetadataManagerPtr = std::shared_ptr<IPartMetadataManager>;
|
|
|
|
}
|