#pragma once #include #include #include namespace DB { /// MergedCondition for Indexhypothesis. class MergeTreeIndexhypothesisMergedCondition : public IMergeTreeIndexMergedCondition { public: MergeTreeIndexhypothesisMergedCondition( const SelectQueryInfo & query, const ConstraintsDescription & constraints, size_t granularity_); void addIndex(const MergeTreeIndexPtr & index) override; bool alwaysUnknownOrTrue() const override; bool mayBeTrueOnGranule(const MergeTreeIndexGranules & granules) const override; private: void addConstraints(const ConstraintsDescription & constraints_description); std::unique_ptr buildGraph(const std::vector & values) const; const ComparisonGraph * getGraph(const std::vector & values) const; ASTPtr expression_ast; std::unique_ptr expression_cnf; /// Part analysis can be done in parallel. /// So, we have shared answer and graph cache. mutable std::mutex cache_mutex; mutable std::unordered_map, std::unique_ptr> graph_cache; mutable std::unordered_map, bool> answer_cache; std::vector> index_to_compare_atomic_hypotheses; std::vector> index_to_atomic_hypotheses; std::vector atomic_constraints; }; }