aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/MergeTree/MergeTreeIndexHypothesis.h
blob: f10ec1a1def991e323ac3ee9949672baf6396aa8 (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
#pragma once

#include <Storages/MergeTree/MergeTreeIndices.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <memory>

namespace DB
{

class MergeTreeIndexHyposesis;

class MergeTreeIndexGranuleHypothesis : public IMergeTreeIndexGranule
{
public:
    explicit MergeTreeIndexGranuleHypothesis(
        const String & index_name_);

    MergeTreeIndexGranuleHypothesis(
        const String & index_name_,
        bool met_);

    void serializeBinary(WriteBuffer & ostr) const override;
    void deserializeBinary(ReadBuffer & istr, MergeTreeIndexVersion version) override;

    bool empty() const override { return is_empty; }

    ~MergeTreeIndexGranuleHypothesis() override = default;

    const String & index_name;
    bool is_empty = true;
    bool met = true;
};


class MergeTreeIndexAggregatorHypothesis : public IMergeTreeIndexAggregator
{
public:
    explicit MergeTreeIndexAggregatorHypothesis(
        const String & index_name_, const String & column_name_);

    ~MergeTreeIndexAggregatorHypothesis() override = default;

    bool empty() const override { return is_empty; }

    MergeTreeIndexGranulePtr getGranuleAndReset() override;

    void update(const Block & block, size_t * pos, size_t limit) override;

private:
    const String & index_name;
    String column_name;

    bool met = true;
    bool is_empty = true;
};

class MergeTreeIndexHypothesis : public IMergeTreeIndex
{
public:
    explicit MergeTreeIndexHypothesis(
        const IndexDescription & index_)
        : IMergeTreeIndex(index_)
    {}

    ~MergeTreeIndexHypothesis() override = default;

    bool isMergeable() const override { return true; }

    MergeTreeIndexGranulePtr createIndexGranule() const override;
    MergeTreeIndexAggregatorPtr createIndexAggregator() const override;

    MergeTreeIndexConditionPtr createIndexCondition(
        const SelectQueryInfo & query, ContextPtr context) const override;

    MergeTreeIndexMergedConditionPtr createIndexMergedCondition(
        const SelectQueryInfo & query_info, StorageMetadataPtr storage_metadata) const override;

    bool mayBenefitFromIndexForIn(const ASTPtr & node) const override;

    size_t max_rows = 0;
};

}