ClickHouse/dbms/include/DB/Storages/MergeTree/MergeTreeDataSelectExecutor.h

81 lines
2.2 KiB
C
Raw Normal View History

2014-03-13 12:48:07 +00:00
#pragma once
#include <DB/Storages/MergeTree/MergeTreeData.h>
#include <DB/Storages/MergeTree/MergeTreeBlockInputStream.h>
namespace DB
{
/** Выполняет запросы SELECT на данных из merge-дерева.
*/
class MergeTreeDataSelectExecutor
{
public:
MergeTreeDataSelectExecutor(MergeTreeData & data_);
/** При чтении, выбирается набор кусков, покрывающий нужный диапазон индекса.
2014-07-30 12:10:34 +00:00
* Если inout_part_index != nullptr, из этого счетчика берутся значения для виртуального столбца _part_index.
2014-03-13 12:48:07 +00:00
*/
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const Settings & settings,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
2014-07-30 12:10:34 +00:00
unsigned threads = 1,
size_t * inout_part_index = nullptr);
2014-03-13 12:48:07 +00:00
private:
MergeTreeData & data;
Logger * log;
struct RangesInDataPart
{
MergeTreeData::DataPartPtr data_part;
2014-07-30 12:10:34 +00:00
size_t part_index_in_query;
2014-03-13 12:48:07 +00:00
MarkRanges ranges;
RangesInDataPart() {}
2014-07-30 12:10:34 +00:00
RangesInDataPart(MergeTreeData::DataPartPtr data_part_, size_t part_index_in_query_)
: data_part(data_part_), part_index_in_query(part_index_in_query_)
2014-03-13 12:48:07 +00:00
{
}
};
typedef std::vector<RangesInDataPart> RangesInDataParts;
size_t min_marks_for_seek;
size_t min_marks_for_concurrent_read;
size_t max_marks_to_use_cache;
BlockInputStreams spreadMarkRangesAmongThreads(
RangesInDataParts parts,
size_t threads,
const Names & column_names,
size_t max_block_size,
bool use_uncompressed_cache,
ExpressionActionsPtr prewhere_actions,
2014-07-28 10:36:11 +00:00
const String & prewhere_column,
2014-07-30 12:10:34 +00:00
const Names & virt_columns);
2014-03-13 12:48:07 +00:00
BlockInputStreams spreadMarkRangesAmongThreadsFinal(
RangesInDataParts parts,
size_t threads,
const Names & column_names,
size_t max_block_size,
bool use_uncompressed_cache,
ExpressionActionsPtr prewhere_actions,
2014-07-28 10:36:11 +00:00
const String & prewhere_column,
2014-07-30 12:10:34 +00:00
const Names & virt_columns);
2014-03-13 12:48:07 +00:00
/// Создать выражение "Sign == 1".
void createPositiveSignCondition(ExpressionActionsPtr & out_expression, String & out_column);
2014-03-13 12:48:07 +00:00
MarkRanges markRangesFromPkRange(const MergeTreeData::DataPart::Index & index, PKCondition & key_condition);
};
}