ClickHouse/src/Storages/MergeTree/PartitionPruner.cpp

26 lines
790 B
C++
Raw Normal View History

2020-11-06 03:50:58 +00:00
#include <Storages/MergeTree/PartitionPruner.h>
namespace DB
{
bool PartitionPruner::canBePruned(const DataPart & part)
2020-11-06 03:50:58 +00:00
{
if (part.isEmpty())
2020-11-06 03:50:58 +00:00
return true;
const auto & partition_id = part.info.partition_id;
2020-11-06 03:50:58 +00:00
bool is_valid;
if (auto it = partition_filter_map.find(partition_id); it != partition_filter_map.end())
is_valid = it->second;
else
{
const auto & partition_value = part.partition.value;
2020-11-06 03:50:58 +00:00
std::vector<FieldRef> index_value(partition_value.begin(), partition_value.end());
is_valid = partition_condition.mayBeTrueInRange(
partition_value.size(), index_value.data(), index_value.data(), partition_key.data_types);
partition_filter_map.emplace(partition_id, is_valid);
}
return !is_valid;
}
}