ClickHouse/dbms/include/DB/Storages/MergeTree/MergeTreeThreadBlockInputStream.h

76 lines
2.1 KiB
C++
Raw Normal View History

2015-06-24 11:03:53 +00:00
#pragma once
#include <DB/DataStreams/IProfilingBlockInputStream.h>
#include <DB/Storages/MergeTree/MergeTreeData.h>
#include <DB/Storages/MergeTree/PKCondition.h>
namespace DB
{
2016-11-20 12:43:20 +00:00
class MergeTreeReader;
class MergeTreeReadPool;
struct MergeTreeReadTask;
class UncompressedCache;
class MarkCache;
2015-06-24 11:03:53 +00:00
/** Used in conjunction with MergeTreeReadPool, asking it for more work to do and performing whatever reads it is asked
* to perform. */
2015-06-24 11:03:53 +00:00
class MergeTreeThreadBlockInputStream : public IProfilingBlockInputStream
{
/// "thread" index (there are N threads and each thread is assigned index in interval [0..N-1])
2015-07-23 13:11:27 +00:00
std::size_t thread;
2015-06-24 11:03:53 +00:00
public:
MergeTreeThreadBlockInputStream(
2015-07-23 13:11:27 +00:00
const std::size_t thread,
2016-11-20 12:43:20 +00:00
const std::shared_ptr<MergeTreeReadPool> & pool, const std::size_t min_marks_to_read, const std::size_t block_size,
2015-06-24 11:03:53 +00:00
MergeTreeData & storage, const bool use_uncompressed_cache, const ExpressionActionsPtr & prewhere_actions,
2016-11-20 12:43:20 +00:00
const String & prewhere_column, const Settings & settings, const Names & virt_column_names);
2015-06-24 11:03:53 +00:00
2016-11-20 12:43:20 +00:00
~MergeTreeThreadBlockInputStream() override;
2015-06-24 11:03:53 +00:00
2016-11-20 12:43:20 +00:00
String getName() const override { return "MergeTreeThread"; }
2016-11-20 12:43:20 +00:00
String getID() const override;
2015-06-24 11:03:53 +00:00
protected:
/// Будем вызывать progressImpl самостоятельно.
void progress(const Progress & value) override {}
2016-11-20 12:43:20 +00:00
Block readImpl() override;
2015-06-24 11:03:53 +00:00
private:
/// Requests read task from MergeTreeReadPool and signals whether it got one
2016-11-20 12:43:20 +00:00
bool getNewTask();
2015-06-24 11:03:53 +00:00
2016-11-20 12:43:20 +00:00
Block readFromPart();
2015-07-03 15:08:21 +00:00
2016-11-20 12:43:20 +00:00
void injectVirtualColumns(Block & block);
2015-07-03 15:08:21 +00:00
2016-11-20 12:43:20 +00:00
std::shared_ptr<MergeTreeReadPool> pool;
const std::size_t block_size_marks;
2015-06-24 11:03:53 +00:00
const std::size_t min_marks_to_read;
MergeTreeData & storage;
const bool use_uncompressed_cache;
ExpressionActionsPtr prewhere_actions;
const String prewhere_column;
const std::size_t min_bytes_to_use_direct_io;
const std::size_t max_read_buffer_size;
const Names virt_column_names;
Logger * log;
using MergeTreeReaderPtr = std::unique_ptr<MergeTreeReader>;
2016-11-20 12:43:20 +00:00
std::shared_ptr<UncompressedCache> owned_uncompressed_cache;
std::shared_ptr<MarkCache> owned_mark_cache;
2015-06-24 11:03:53 +00:00
2016-11-20 12:43:20 +00:00
std::shared_ptr<MergeTreeReadTask> task;
2015-06-24 11:03:53 +00:00
MergeTreeReaderPtr reader;
MergeTreeReaderPtr pre_reader;
};
}