2013-04-24 10:31:32 +00:00
|
|
|
#pragma once
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/IProfilingBlockInputStream.h>
|
2017-03-24 13:52:50 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeThreadBlockInputStream.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>
|
2013-04-24 10:31:32 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
|
2017-03-24 13:52:50 +00:00
|
|
|
/// Used to read data from single part.
|
|
|
|
/// To read data from multiple parts, a Storage creates multiple such objects.
|
2017-04-06 17:21:45 +00:00
|
|
|
/// TODO: Make special lightweight version of the reader for merges and other utilites, remove this from SelectExecutor.
|
2017-03-24 13:52:50 +00:00
|
|
|
class MergeTreeBlockInputStream : public MergeTreeBaseBlockInputStream
|
2013-04-24 10:31:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-24 13:52:50 +00:00
|
|
|
MergeTreeBlockInputStream(
|
|
|
|
MergeTreeData & storage,
|
|
|
|
const MergeTreeData::DataPartPtr & owned_data_part,
|
|
|
|
size_t max_block_size_rows,
|
|
|
|
size_t preferred_block_size_bytes,
|
2017-06-30 16:28:27 +00:00
|
|
|
size_t preferred_max_column_in_block_size_bytes,
|
2017-03-24 13:52:50 +00:00
|
|
|
Names column_names,
|
|
|
|
const MarkRanges & mark_ranges,
|
|
|
|
bool use_uncompressed_cache,
|
|
|
|
ExpressionActionsPtr prewhere_actions,
|
|
|
|
String prewhere_column,
|
|
|
|
bool check_columns,
|
|
|
|
size_t min_bytes_to_use_direct_io,
|
|
|
|
size_t max_read_buffer_size,
|
|
|
|
bool save_marks_in_cache,
|
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
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
~MergeTreeBlockInputStream() 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-01 07:20:54 +00:00
|
|
|
String getID() const override;
|
2014-06-26 00:58:14 +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
|
2017-03-24 13:52:50 +00:00
|
|
|
Names ordered_names;
|
2017-04-01 07:20:54 +00:00
|
|
|
NameSet column_name_set;
|
2017-03-24 13:52:50 +00:00
|
|
|
NamesAndTypesList columns;
|
2017-04-01 07:20:54 +00:00
|
|
|
NamesAndTypesList pre_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;
|
|
|
|
/// Forbids to change columns list of the part during reading
|
2017-07-28 17:34:02 +00:00
|
|
|
std::shared_lock<std::shared_mutex> part_columns_lock;
|
2017-04-06 17:21:45 +00:00
|
|
|
|
|
|
|
/// 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;
|
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
|
|
|
|
|
|
|
Logger * log = &Logger::get("MergeTreeBlockInputStream");
|
2013-04-24 10:31:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|