2014-03-13 12:48:07 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Storages/MergeTree/MergeTreeData.h>
|
2015-04-12 04:39:20 +00:00
|
|
|
|
#include <DB/Storages/MergeTree/MergeTreeReader.h>
|
|
|
|
|
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
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,
|
2014-12-17 11:53:17 +00:00
|
|
|
|
const Context & context,
|
2014-03-13 12:48:07 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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,
|
2015-02-15 02:31:48 +00:00
|
|
|
|
const Names & virt_columns,
|
|
|
|
|
const Settings & settings);
|
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,
|
2015-02-15 02:31:48 +00:00
|
|
|
|
const Names & virt_columns,
|
|
|
|
|
const Settings & settings);
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
/// Создать выражение "Sign == 1".
|
2014-03-19 10:45:13 +00:00
|
|
|
|
void createPositiveSignCondition(ExpressionActionsPtr & out_expression, String & out_column);
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2015-02-15 02:31:48 +00:00
|
|
|
|
MarkRanges markRangesFromPkRange(const MergeTreeData::DataPart::Index & index, PKCondition & key_condition, const Settings & settings);
|
2014-03-13 12:48:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|