ClickHouse/src/Storages/MergeTree/MergeTreeIndexHypothesisMergedCondition.h

41 lines
1.5 KiB
C++
Raw Normal View History

2021-05-02 19:16:40 +00:00
#pragma once
#include <Storages/MergeTree/MergeTreeIndices.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Interpreters/ComparisonGraph.h>
namespace DB
{
2021-11-21 19:14:20 +00:00
/// MergedCondition for Indexhypothesis.
class MergeTreeIndexhypothesisMergedCondition : public IMergeTreeIndexMergedCondition
2021-05-02 19:16:40 +00:00
{
public:
2021-11-21 19:14:20 +00:00
MergeTreeIndexhypothesisMergedCondition(
const SelectQueryInfo & query, const ConstraintsDescription & constraints, size_t granularity_);
2021-05-02 19:16:40 +00:00
2021-11-21 19:14:20 +00:00
void addIndex(const MergeTreeIndexPtr & index) override;
bool alwaysUnknownOrTrue() const override;
bool mayBeTrueOnGranule(const MergeTreeIndexGranules & granules) const override;
2021-05-02 19:16:40 +00:00
private:
2021-11-21 19:14:20 +00:00
void addConstraints(const ConstraintsDescription & constraints_description);
2023-03-17 13:38:01 +00:00
std::unique_ptr<ComparisonGraph<ASTPtr>> buildGraph(const std::vector<bool> & values) const;
const ComparisonGraph<ASTPtr> * getGraph(const std::vector<bool> & values) const;
2021-05-02 19:16:40 +00:00
ASTPtr expression_ast;
std::unique_ptr<CNFQuery> expression_cnf;
/// Part analysis can be done in parallel.
/// So, we have shared answer and graph cache.
mutable std::mutex cache_mutex;
2023-03-17 13:38:01 +00:00
mutable std::unordered_map<std::vector<bool>, std::unique_ptr<ComparisonGraph<ASTPtr>>> graph_cache;
2021-11-21 19:14:20 +00:00
mutable std::unordered_map<std::vector<bool>, bool> answer_cache;
2021-05-02 19:16:40 +00:00
std::vector<std::vector<ASTPtr>> index_to_compare_atomic_hypotheses;
std::vector<std::vector<CNFQuery::OrGroup>> index_to_atomic_hypotheses;
ASTs atomic_constraints;
2021-05-02 19:16:40 +00:00
};
}