ClickHouse/src/Storages/MergeTree/MergeTreeIndexMinMax.h

87 lines
2.4 KiB
C++
Raw Normal View History

2019-01-08 17:27:44 +00:00
#pragma once
2019-01-17 12:11:36 +00:00
#include <Storages/MergeTree/MergeTreeIndices.h>
2019-01-08 17:27:44 +00:00
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/KeyCondition.h>
#include <memory>
namespace DB
{
2019-06-19 15:30:48 +00:00
struct MergeTreeIndexGranuleMinMax : public IMergeTreeIndexGranule
2019-01-08 17:27:44 +00:00
{
2020-05-28 12:37:05 +00:00
MergeTreeIndexGranuleMinMax(const String & index_name_, const Block & index_sample_block_);
MergeTreeIndexGranuleMinMax(
const String & index_name_,
const Block & index_sample_block_,
std::vector<Range> && hyperrectangle_);
2019-06-19 15:30:48 +00:00
~MergeTreeIndexGranuleMinMax() override = default;
2019-01-08 17:27:44 +00:00
void serializeBinary(WriteBuffer & ostr) const override;
void deserializeBinary(ReadBuffer & istr) override;
2019-01-09 14:15:23 +00:00
2020-03-10 14:56:55 +00:00
bool empty() const override { return hyperrectangle.empty(); }
2019-01-08 17:27:44 +00:00
2020-05-28 12:37:05 +00:00
String index_name;
2020-05-27 18:38:34 +00:00
Block index_sample_block;
2020-03-10 14:56:55 +00:00
std::vector<Range> hyperrectangle;
2019-03-08 19:52:21 +00:00
};
2019-06-19 15:30:48 +00:00
struct MergeTreeIndexAggregatorMinMax : IMergeTreeIndexAggregator
2019-03-08 19:52:21 +00:00
{
2020-05-28 12:37:05 +00:00
MergeTreeIndexAggregatorMinMax(const String & index_name_, const Block & index_sample_block);
2019-06-19 15:30:48 +00:00
~MergeTreeIndexAggregatorMinMax() override = default;
2019-03-08 19:52:21 +00:00
2020-03-10 14:56:55 +00:00
bool empty() const override { return hyperrectangle.empty(); }
2019-03-08 19:52:21 +00:00
MergeTreeIndexGranulePtr getGranuleAndReset() override;
void update(const Block & block, size_t * pos, size_t limit) override;
2019-01-08 17:27:44 +00:00
2020-05-28 12:37:05 +00:00
String index_name;
2020-05-27 18:38:34 +00:00
Block index_sample_block;
2020-03-10 14:56:55 +00:00
std::vector<Range> hyperrectangle;
2019-01-08 17:27:44 +00:00
};
2019-01-27 18:23:08 +00:00
2019-06-19 15:30:48 +00:00
class MergeTreeIndexConditionMinMax : public IMergeTreeIndexCondition
2019-01-08 17:27:44 +00:00
{
public:
2019-06-19 15:30:48 +00:00
MergeTreeIndexConditionMinMax(
2020-05-28 13:09:03 +00:00
const IndexDescription & index,
2019-01-09 17:05:52 +00:00
const SelectQueryInfo & query,
2020-05-27 18:38:34 +00:00
const Context & context);
2019-01-08 17:27:44 +00:00
bool alwaysUnknownOrTrue() const override;
bool mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule) const override;
2019-06-19 15:30:48 +00:00
~MergeTreeIndexConditionMinMax() override = default;
2019-01-08 17:27:44 +00:00
private:
2020-05-27 18:38:34 +00:00
DataTypes index_data_types;
2019-01-08 17:27:44 +00:00
KeyCondition condition;
};
2019-06-19 15:30:48 +00:00
class MergeTreeIndexMinMax : public IMergeTreeIndex
2019-01-08 17:27:44 +00:00
{
public:
2020-05-28 13:09:03 +00:00
MergeTreeIndexMinMax(const IndexDescription & index_)
2020-05-27 18:38:34 +00:00
: IMergeTreeIndex(index_)
{}
2019-01-08 17:27:44 +00:00
2019-06-19 15:30:48 +00:00
~MergeTreeIndexMinMax() override = default;
2019-01-08 17:27:44 +00:00
MergeTreeIndexGranulePtr createIndexGranule() const override;
2019-03-08 19:52:21 +00:00
MergeTreeIndexAggregatorPtr createIndexAggregator() const override;
2019-01-08 17:27:44 +00:00
2019-06-19 15:30:48 +00:00
MergeTreeIndexConditionPtr createIndexCondition(
2019-01-09 17:05:52 +00:00
const SelectQueryInfo & query, const Context & context) const override;
2019-01-08 17:27:44 +00:00
2019-02-25 08:43:19 +00:00
bool mayBenefitFromIndexForIn(const ASTPtr & node) const override;
2019-01-08 17:27:44 +00:00
};
}