2014-03-13 12:48:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-06 20:18:34 +00:00
|
|
|
#include <Core/QueryProcessingStage.h>
|
|
|
|
#include <Storages/SelectQueryInfo.h>
|
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
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Executes SELECT queries on data from the merge tree.
|
2014-03-13 12:48:07 +00:00
|
|
|
*/
|
|
|
|
class MergeTreeDataSelectExecutor
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
MergeTreeDataSelectExecutor(MergeTreeData & data_);
|
2014-03-13 12:48:07 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** When reading, selects a set of parts that covers the desired range of the index.
|
|
|
|
* max_block_number_to_read - if not zero, do not read all the parts whose right border is greater than this threshold.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
size_t max_block_size,
|
2017-06-02 15:54:39 +00:00
|
|
|
unsigned num_streams,
|
2017-04-01 07:20:54 +00:00
|
|
|
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-06-02 15:54:39 +00:00
|
|
|
BlockInputStreams spreadMarkRangesAmongStreams(
|
2017-11-24 23:03:58 +00:00
|
|
|
RangesInDataParts && parts,
|
2017-06-02 15:54:39 +00:00
|
|
|
size_t num_streams,
|
2017-04-01 07:20:54 +00:00
|
|
|
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-06-02 15:54:39 +00:00
|
|
|
BlockInputStreams spreadMarkRangesAmongStreamsFinal(
|
2017-11-24 23:03:58 +00:00
|
|
|
RangesInDataParts && parts,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
|
|
|
size_t max_block_size,
|
|
|
|
bool use_uncompressed_cache,
|
|
|
|
ExpressionActionsPtr prewhere_actions,
|
|
|
|
const String & prewhere_column,
|
|
|
|
const Names & virt_columns,
|
2018-04-05 21:36:55 +00:00
|
|
|
const Settings & settings) const;
|
2015-11-18 21:37:28 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Get the approximate value (bottom estimate - only by full marks) of the number of rows falling under the index.
|
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-16 15:00:33 +00:00
|
|
|
/// Create the expression "Sign == 1".
|
2017-04-01 07:20:54 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|