ClickHouse/dbms/src/Storages/MergeTree/MergeTreeBaseSelectProcessor.h

87 lines
2.5 KiB
C++
Raw Normal View History

#pragma once
2017-12-01 13:32:37 +00:00
#include <DataStreams/IBlockInputStream.h>
#include <Storages/MergeTree/MergeTreeBlockReadUtils.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/SelectQueryInfo.h>
2019-10-04 15:40:05 +00:00
#include <Processors/Sources/SourceWithProgress.h>
namespace DB
{
class MergeTreeReader;
class UncompressedCache;
class MarkCache;
2019-10-10 14:16:15 +00:00
/// Base class for MergeTreeThreadSelectProcessor and MergeTreeSelectProcessor
2019-10-04 15:40:05 +00:00
class MergeTreeBaseSelectProcessor : public SourceWithProgress
{
public:
2019-10-01 16:50:08 +00:00
MergeTreeBaseSelectProcessor(
Block header,
2019-08-03 11:02:40 +00:00
const MergeTreeData & storage_,
const PrewhereInfoPtr & prewhere_info_,
UInt64 max_block_size_rows_,
UInt64 preferred_block_size_bytes_,
UInt64 preferred_max_column_in_block_size_bytes_,
UInt64 min_bytes_to_use_direct_io_,
UInt64 max_read_buffer_size_,
bool use_uncompressed_cache_,
bool save_marks_in_cache_ = true,
const Names & virt_column_names_ = {});
2019-10-01 16:50:08 +00:00
~MergeTreeBaseSelectProcessor() override;
2018-04-16 12:21:36 +00:00
static void executePrewhereActions(Block & block, const PrewhereInfoPtr & prewhere_info);
protected:
Chunk generate() final;
2019-10-04 15:40:05 +00:00
/// Creates new this->task, and initializes readers.
virtual bool getNewTask() = 0;
virtual Chunk readFromPart();
Chunk readFromPartImpl();
2019-07-19 14:56:00 +00:00
2019-10-10 14:16:15 +00:00
/// Two versions for header and chunk.
static void injectVirtualColumns(Block & block, MergeTreeReadTask * task, const Names & virtual_columns);
static void injectVirtualColumns(Chunk & chunk, MergeTreeReadTask * task, const Names & virtual_columns);
2019-10-10 14:16:15 +00:00
static Block getHeader(Block block, const PrewhereInfoPtr & prewhere_info, const Names & virtual_columns);
void initializeRangeReaders(MergeTreeReadTask & task);
protected:
2018-10-17 03:13:00 +00:00
const MergeTreeData & storage;
PrewhereInfoPtr prewhere_info;
UInt64 max_block_size_rows;
UInt64 preferred_block_size_bytes;
UInt64 preferred_max_column_in_block_size_bytes;
UInt64 min_bytes_to_use_direct_io;
UInt64 max_read_buffer_size;
bool use_uncompressed_cache;
bool save_marks_in_cache;
Names virt_column_names;
2019-10-10 14:16:15 +00:00
/// This header is used for chunks from readFromPart().
Block header_without_virtual_columns;
std::unique_ptr<MergeTreeReadTask> task;
std::shared_ptr<UncompressedCache> owned_uncompressed_cache;
std::shared_ptr<MarkCache> owned_mark_cache;
using MergeTreeReaderPtr = std::unique_ptr<MergeTreeReader>;
MergeTreeReaderPtr reader;
MergeTreeReaderPtr pre_reader;
};
}