blob: d9e97d91518b1bc7fb71396fe8f003b3f949ea3a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#pragma once
#include <unordered_map>
#include <city.h>
#include <base/types.h>
namespace DB
{
class IMergeTreeDataPart;
class ReadBuffer;
class SeekableReadBuffer;
class IDisk;
using DiskPtr = std::shared_ptr<IDisk>;
/// 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.
class IPartMetadataManager
{
public:
using uint128 = CityHash_v1_0_2::uint128;
explicit IPartMetadataManager(const IMergeTreeDataPart * part_);
virtual ~IPartMetadataManager() = default;
/// Read metadata content and return ReadBuffer object.
virtual std::unique_ptr<ReadBuffer> read(const String & file_name) const = 0;
/// Return true if metadata exists in part.
virtual bool exists(const String & file_name) const = 0;
/// Delete all metadatas in part.
/// If include_projection is true, also delete metadatas in projection parts.
virtual void deleteAll(bool include_projection) = 0;
/// Assert that all metadatas in part are deleted.
/// If include_projection is true, also assert that all metadatas in projection parts are deleted.
virtual void assertAllDeleted(bool include_projection) const = 0;
/// Update all metadatas in part.
/// If include_projection is true, also update metadatas in projection parts.
virtual void updateAll(bool include_projection) = 0;
/// Check all metadatas in part.
virtual std::unordered_map<String, uint128> check() const = 0;
/// Determine whether to compress by file extension
static bool isCompressedFromFileName(const String & file_name);
protected:
const IMergeTreeDataPart * part;
};
using PartMetadataManagerPtr = std::shared_ptr<IPartMetadataManager>;
}
|