MergeTreeDataSelectExecutor.h 2.0 KB
Newer Older
M
Merge  
Michael Kolupaev 已提交
1 2 3
#pragma once

#include <DB/Storages/MergeTree/MergeTreeData.h>
A
Merge  
Alexey Milovidov 已提交
4
#include <DB/Storages/MergeTree/MergeTreeReader.h>
A
Merge  
Andrey Mironov 已提交
5
#include <DB/Storages/MergeTree/RangesInDataPart.h>
A
Merge  
Alexey Milovidov 已提交
6

M
Merge  
Michael Kolupaev 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19

namespace DB
{


/** Выполняет запросы SELECT на данных из merge-дерева.
  */
class MergeTreeDataSelectExecutor
{
public:
	MergeTreeDataSelectExecutor(MergeTreeData & data_);

	/** При чтении, выбирается набор кусков, покрывающий нужный диапазон индекса.
M
Merge  
Michael Kolupaev 已提交
20
	  * Если inout_part_index != nullptr, из этого счетчика берутся значения для виртуального столбца _part_index.
M
Merge  
Michael Kolupaev 已提交
21 22 23 24
	  */
	BlockInputStreams read(
		const Names & column_names,
		ASTPtr query,
25
		const Context & context,
M
Merge  
Michael Kolupaev 已提交
26 27 28
		const Settings & settings,
		QueryProcessingStage::Enum & processed_stage,
		size_t max_block_size = DEFAULT_BLOCK_SIZE,
M
Merge  
Michael Kolupaev 已提交
29 30
		unsigned threads = 1,
		size_t * inout_part_index = nullptr);
M
Merge  
Michael Kolupaev 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43

private:
	MergeTreeData & data;

	Logger * log;

	BlockInputStreams spreadMarkRangesAmongThreads(
		RangesInDataParts parts,
		size_t threads,
		const Names & column_names,
		size_t max_block_size,
		bool use_uncompressed_cache,
		ExpressionActionsPtr prewhere_actions,
M
Merge  
Michael Kolupaev 已提交
44
		const String & prewhere_column,
45 46
		const Names & virt_columns,
		const Settings & settings);
M
Merge  
Michael Kolupaev 已提交
47 48 49 50 51 52 53 54

	BlockInputStreams spreadMarkRangesAmongThreadsFinal(
		RangesInDataParts parts,
		size_t threads,
		const Names & column_names,
		size_t max_block_size,
		bool use_uncompressed_cache,
		ExpressionActionsPtr prewhere_actions,
M
Merge  
Michael Kolupaev 已提交
55
		const String & prewhere_column,
56
		const Names & virt_columns,
57 58
		const Settings & settings,
		const Context & context);
M
Merge  
Michael Kolupaev 已提交
59 60

	/// Создать выражение "Sign == 1".
61
	void createPositiveSignCondition(ExpressionActionsPtr & out_expression, String & out_column, const Context & context);
M
Merge  
Michael Kolupaev 已提交
62

63
	MarkRanges markRangesFromPkRange(const MergeTreeData::DataPart::Index & index, PKCondition & key_condition, const Settings & settings);
M
Merge  
Michael Kolupaev 已提交
64 65 66
};

}