blob: ec9eca77c10b1a023b3eaa03becd5919b40d7735 (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#pragma once
#include <Storages/MergeTree/MergeTreeIndices.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/KeyCondition.h>
#include <memory>
namespace DB
{
struct MergeTreeIndexGranuleMinMax final : public IMergeTreeIndexGranule
{
MergeTreeIndexGranuleMinMax(const String & index_name_, const Block & index_sample_block_);
MergeTreeIndexGranuleMinMax(
const String & index_name_,
const Block & index_sample_block_,
std::vector<Range> && hyperrectangle_);
~MergeTreeIndexGranuleMinMax() override = default;
void serializeBinary(WriteBuffer & ostr) const override;
void deserializeBinary(ReadBuffer & istr, MergeTreeIndexVersion version) override;
bool empty() const override { return hyperrectangle.empty(); }
String index_name;
Block index_sample_block;
std::vector<Range> hyperrectangle;
};
struct MergeTreeIndexAggregatorMinMax final : IMergeTreeIndexAggregator
{
MergeTreeIndexAggregatorMinMax(const String & index_name_, const Block & index_sample_block);
~MergeTreeIndexAggregatorMinMax() override = default;
bool empty() const override { return hyperrectangle.empty(); }
MergeTreeIndexGranulePtr getGranuleAndReset() override;
void update(const Block & block, size_t * pos, size_t limit) override;
String index_name;
Block index_sample_block;
std::vector<Range> hyperrectangle;
};
class MergeTreeIndexConditionMinMax final : public IMergeTreeIndexCondition
{
public:
MergeTreeIndexConditionMinMax(
const IndexDescription & index,
const SelectQueryInfo & query_info,
ContextPtr context);
bool alwaysUnknownOrTrue() const override;
bool mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule) const override;
~MergeTreeIndexConditionMinMax() override = default;
private:
DataTypes index_data_types;
KeyCondition condition;
};
class MergeTreeIndexMinMax : public IMergeTreeIndex
{
public:
explicit MergeTreeIndexMinMax(const IndexDescription & index_)
: IMergeTreeIndex(index_)
{}
~MergeTreeIndexMinMax() override = default;
MergeTreeIndexGranulePtr createIndexGranule() const override;
MergeTreeIndexAggregatorPtr createIndexAggregator() const override;
MergeTreeIndexConditionPtr createIndexCondition(
const SelectQueryInfo & query, ContextPtr context) const override;
bool mayBenefitFromIndexForIn(const ASTPtr & node) const override;
const char* getSerializedFileExtension() const override { return ".idx2"; }
MergeTreeIndexFormat getDeserializedFormat(const IDataPartStorage & data_part_storage, const std::string & path_prefix) const override; /// NOLINT
};
}
|