2013-04-24 10:31:32 +00:00
|
|
|
#pragma once
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2019-10-01 16:50:08 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeThreadSelectBlockInputProcessor.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
#include <Storages/MergeTree/MarkRange.h>
|
2017-03-24 13:52:50 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeBlockReadUtils.h>
|
2018-04-11 14:31:54 +00:00
|
|
|
#include <Storages/SelectQueryInfo.h>
|
2013-04-24 10:31:32 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
|
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,
|
2017-03-24 13:52:50 +00:00
|
|
|
const MergeTreeData::DataPartPtr & owned_data_part,
|
2019-02-10 16:55:12 +00:00
|
|
|
UInt64 max_block_size_rows,
|
2017-03-24 13:52:50 +00:00
|
|
|
size_t preferred_block_size_bytes,
|
2017-06-30 16:28:27 +00:00
|
|
|
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,
|
2017-03-24 13:52:50 +00:00
|
|
|
bool use_uncompressed_cache,
|
2018-04-11 14:31:54 +00:00
|
|
|
const PrewhereInfoPtr & prewhere_info,
|
2017-03-24 13:52:50 +00:00
|
|
|
bool check_columns,
|
2019-12-18 15:54:45 +00:00
|
|
|
const MergeTreeReaderSettings & reader_settings,
|
2017-04-05 20:34:19 +00:00
|
|
|
const Names & virt_column_names = {},
|
|
|
|
size_t part_index_in_query = 0,
|
2017-03-24 13:52:50 +00:00
|
|
|
bool quiet = false);
|
2016-03-30 19:59:43 +00:00
|
|
|
|
2019-10-01 16:50:08 +00:00
|
|
|
~MergeTreeSelectProcessor() override;
|
2014-06-26 00:58:14 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "MergeTree"; }
|
2013-05-03 10:20:53 +00:00
|
|
|
|
2017-04-06 17:21:45 +00:00
|
|
|
/// Closes readers and unlock part locks
|
|
|
|
void finish();
|
2013-11-26 11:55:11 +00:00
|
|
|
|
2017-04-06 17:21:45 +00:00
|
|
|
protected:
|
2014-06-26 00:58:14 +00:00
|
|
|
|
2017-04-05 20:34:19 +00:00
|
|
|
bool getNewTask() override;
|
|
|
|
|
2013-04-24 10:31:32 +00:00
|
|
|
private:
|
2017-03-24 13:52:50 +00:00
|
|
|
|
2017-04-06 17:21:45 +00:00
|
|
|
/// 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.
|
2017-03-24 13:52:50 +00:00
|
|
|
Names ordered_names;
|
2017-04-01 07:20:54 +00:00
|
|
|
NameSet column_name_set;
|
2019-07-19 14:56:00 +00:00
|
|
|
|
|
|
|
MergeTreeReadTaskColumns task_columns;
|
2017-03-24 13:52:50 +00:00
|
|
|
|
2017-04-06 17:21:45 +00:00
|
|
|
/// Data part will not be removed if the pointer owns it
|
|
|
|
MergeTreeData::DataPartPtr data_part;
|
|
|
|
|
|
|
|
/// Mark ranges we should read (in ascending order)
|
|
|
|
MarkRanges all_mark_ranges;
|
2018-05-23 19:34:37 +00:00
|
|
|
/// Total number of marks we should read
|
|
|
|
size_t total_marks_count = 0;
|
2017-04-06 17:21:45 +00:00
|
|
|
/// 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;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-04-05 20:34:19 +00:00
|
|
|
bool check_columns;
|
2017-03-24 13:52:50 +00:00
|
|
|
String path;
|
2017-04-05 20:34:19 +00:00
|
|
|
bool is_first_task = true;
|
2017-09-07 21:04:48 +00:00
|
|
|
|
2019-10-01 16:50:08 +00:00
|
|
|
Logger * log = &Logger::get("MergeTreeSelectProcessor");
|
2013-04-24 10:31:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|