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>
|
2015-06-24 11:03:53 +00:00
|
|
|
|
#include <DB/Storages/MergeTree/RangesInDataPart.h>
|
2015-04-12 04:39:20 +00:00
|
|
|
|
|
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.
|
2015-09-20 11:54:58 +00:00
|
|
|
|
* max_block_number_to_read - если не ноль - не читать все куски, у которых правая граница больше этого порога.
|
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,
|
2015-09-20 11:54:58 +00:00
|
|
|
|
size_t max_block_size,
|
|
|
|
|
unsigned threads,
|
|
|
|
|
size_t * inout_part_index,
|
2015-11-18 21:37:28 +00:00
|
|
|
|
Int64 max_block_number_to_read) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
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,
|
2014-07-28 10:36:11 +00:00
|
|
|
|
const String & prewhere_column,
|
2015-02-15 02:31:48 +00:00
|
|
|
|
const Names & virt_columns,
|
2015-11-18 21:37:28 +00:00
|
|
|
|
const Settings & settings) const;
|
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,
|
2015-07-15 04:50:48 +00:00
|
|
|
|
const Settings & settings,
|
2015-11-18 21:37:28 +00:00
|
|
|
|
const Context & context) const;
|
|
|
|
|
|
|
|
|
|
/// Получить приблизительное значение (оценку снизу - только по полным засечкам) количества строк, попадающего под индекс.
|
|
|
|
|
size_t getApproximateTotalRowsToRead(
|
|
|
|
|
const MergeTreeData::DataPartsVector & parts,
|
|
|
|
|
const PKCondition & key_condition,
|
|
|
|
|
const Settings & settings) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
/// Создать выражение "Sign == 1".
|
2015-11-18 21:37:28 +00:00
|
|
|
|
void createPositiveSignCondition(
|
|
|
|
|
ExpressionActionsPtr & out_expression,
|
|
|
|
|
String & out_column,
|
|
|
|
|
const Context & context) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2015-11-18 21:37:28 +00:00
|
|
|
|
MarkRanges markRangesFromPkRange(
|
|
|
|
|
const MergeTreeData::DataPart::Index & index,
|
|
|
|
|
const PKCondition & key_condition,
|
|
|
|
|
const Settings & settings) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|