ClickHouse/src/Storages/MergeTree/MergeTreeSelectProcessor.h

71 lines
2.4 KiB
C++
Raw Normal View History

2013-04-24 10:31:32 +00:00
#pragma once
#include <Storages/MergeTree/MergeTreeBaseSelectProcessor.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/MarkRange.h>
#include <Storages/MergeTree/MergeTreeBlockReadUtils.h>
#include <Storages/SelectQueryInfo.h>
2013-04-24 10:31:32 +00:00
2021-07-17 18:06:46 +00:00
2013-04-24 10:31:32 +00:00
namespace DB
{
2018-11-29 09:19:42 +00:00
/// Used to read data from single part with select query
/// Cares about PREWHERE, virtual columns, indexes etc.
/// To read data from multiple parts, Storage (MergeTree) creates multiple such objects.
2019-10-01 16:50:08 +00:00
class MergeTreeSelectProcessor : public MergeTreeBaseSelectProcessor
2013-04-24 10:31:32 +00:00
{
public:
2019-10-01 16:50:08 +00:00
MergeTreeSelectProcessor(
2018-10-17 03:13:00 +00:00
const MergeTreeData & storage,
const StorageSnapshotPtr & storage_snapshot_,
const MergeTreeData::DataPartPtr & owned_data_part,
2019-02-10 16:55:12 +00:00
UInt64 max_block_size_rows,
size_t preferred_block_size_bytes,
size_t preferred_max_column_in_block_size_bytes,
2020-03-09 02:55:28 +00:00
Names required_columns_,
2019-10-04 15:40:05 +00:00
MarkRanges mark_ranges,
bool use_uncompressed_cache,
const PrewhereInfoPtr & prewhere_info,
2021-06-25 14:49:28 +00:00
ExpressionActionsSettings actions_settings,
const MergeTreeReaderSettings & reader_settings,
2017-04-05 20:34:19 +00:00
const Names & virt_column_names = {},
2021-07-16 14:27:38 +00:00
size_t part_index_in_query_ = 0,
bool has_limit_below_one_block_ = false,
std::optional<ParallelReadingExtension> extension_ = {});
2019-10-01 16:50:08 +00:00
~MergeTreeSelectProcessor() override;
protected:
2021-08-04 15:18:03 +00:00
/// Defer initialization from constructor, because it may be heavy
/// and it's better to do it lazily in `getNewTaskImpl`, which is executing in parallel.
2021-08-04 15:18:03 +00:00
void initializeReaders();
void finish() override final;
/// Used by Task
2018-04-16 12:21:36 +00:00
Names required_columns;
2018-04-19 15:18:26 +00:00
/// Names from header. Used in order to order columns in read blocks.
Names ordered_names;
NameSet column_name_set;
2019-07-19 14:56:00 +00:00
MergeTreeReadTaskColumns task_columns;
/// Data part will not be removed if the pointer owns it
MergeTreeData::DataPartPtr data_part;
/// Cache getSampleBlock call, which might be heavy.
Block sample_block;
/// Mark ranges we should read (in ascending order)
MarkRanges all_mark_ranges;
/// Value of _part_index virtual column (used only in SelectExecutor)
2017-04-05 20:34:19 +00:00
size_t part_index_in_query = 0;
/// If true, every task will be created only with one range.
/// It reduces amount of read data for queries with small LIMIT.
bool has_limit_below_one_block = false;
size_t total_rows = 0;
2013-04-24 10:31:32 +00:00
};
}