ClickHouse/src/Storages/ReadInOrderOptimizer.h

35 lines
988 B
C++
Raw Normal View History

2019-12-10 23:18:24 +00:00
#pragma once
#include <Core/SortDescription.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/SelectQueryInfo.h>
namespace DB
{
/** Helper class, that can analyze MergeTree order key
* and required sort description to get their
* common prefix, which is needed for
2019-12-10 23:18:24 +00:00
* performing reading in order of PK.
*/
2020-12-12 16:42:15 +00:00
class Context;
2019-12-10 23:18:24 +00:00
class ReadInOrderOptimizer
{
public:
ReadInOrderOptimizer(
const ManyExpressionActions & elements_actions,
const SortDescription & required_sort_description,
const TreeRewriterResultPtr & syntax_result);
2019-12-10 23:18:24 +00:00
InputOrderInfoPtr getInputOrder(const StorageMetadataPtr & metadata_snapshot, ContextPtr context, UInt64 limit = 0) const;
2019-12-10 23:18:24 +00:00
private:
2020-02-14 07:12:04 +00:00
/// Actions for every element of order expression to analyze functions for monotonicity
2019-12-10 23:18:24 +00:00
ManyExpressionActions elements_actions;
NameSet forbidden_columns;
2021-05-21 17:01:21 +00:00
NameToNameMap array_join_result_to_source;
2019-12-11 01:34:39 +00:00
SortDescription required_sort_description;
2019-12-10 23:18:24 +00:00
};
2020-02-14 13:31:01 +00:00
}