2014-03-13 12:48:07 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
|
#include <Storages/MergeTree/RangesInDataPart.h>
|
2015-04-12 04:39:20 +00:00
|
|
|
|
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
2017-01-14 09:00:19 +00:00
|
|
|
|
class PKCondition;
|
|
|
|
|
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
/** Выполняет запросы SELECT на данных из merge-дерева.
|
|
|
|
|
*/
|
|
|
|
|
class MergeTreeDataSelectExecutor
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
|
MergeTreeDataSelectExecutor(MergeTreeData & data_);
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
/** При чтении, выбирается набор кусков, покрывающий нужный диапазон индекса.
|
|
|
|
|
* max_block_number_to_read - если не ноль - не читать все куски, у которых правая граница больше этого порога.
|
|
|
|
|
*/
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
ASTPtr query,
|
|
|
|
|
const Context & context,
|
|
|
|
|
const Settings & settings,
|
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
|
size_t max_block_size,
|
|
|
|
|
unsigned threads,
|
|
|
|
|
size_t * inout_part_index, /// Если не nullptr, из этого счетчика берутся значения для виртуального столбца _part_index.
|
|
|
|
|
Int64 max_block_number_to_read) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
|
MergeTreeData & data;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
Logger * log;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
BlockInputStreams spreadMarkRangesAmongThreads(
|
|
|
|
|
RangesInDataParts parts,
|
|
|
|
|
size_t threads,
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
size_t max_block_size,
|
|
|
|
|
bool use_uncompressed_cache,
|
|
|
|
|
ExpressionActionsPtr prewhere_actions,
|
|
|
|
|
const String & prewhere_column,
|
|
|
|
|
const Names & virt_columns,
|
|
|
|
|
const Settings & settings) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +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,
|
|
|
|
|
const String & prewhere_column,
|
|
|
|
|
const Names & virt_columns,
|
|
|
|
|
const Settings & settings,
|
|
|
|
|
const Context & context) const;
|
2015-11-18 21:37:28 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
/// Получить приблизительное значение (оценку снизу - только по полным засечкам) количества строк, попадающего под индекс.
|
|
|
|
|
size_t getApproximateTotalRowsToRead(
|
|
|
|
|
const MergeTreeData::DataPartsVector & parts,
|
|
|
|
|
const PKCondition & key_condition,
|
|
|
|
|
const Settings & settings) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
/// Создать выражение "Sign == 1".
|
|
|
|
|
void createPositiveSignCondition(
|
|
|
|
|
ExpressionActionsPtr & out_expression,
|
|
|
|
|
String & out_column,
|
|
|
|
|
const Context & context) const;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|