ClickHouse/src/Storages/RabbitMQ/RabbitMQBlockInputStream.h
2020-09-07 14:48:50 +00:00

54 lines
1.2 KiB
C++

#pragma once
#include <DataStreams/IBlockInputStream.h>
#include <Interpreters/Context.h>
#include <Storages/RabbitMQ/StorageRabbitMQ.h>
#include <Storages/RabbitMQ/ReadBufferFromRabbitMQConsumer.h>
namespace DB
{
class RabbitMQBlockInputStream : public IBlockInputStream
{
public:
RabbitMQBlockInputStream(
StorageRabbitMQ & storage_,
const StorageMetadataPtr & metadata_snapshot_,
const Context & context_,
const Names & columns,
size_t max_block_size_,
bool ack_in_suffix = true);
~RabbitMQBlockInputStream() override;
String getName() const override { return storage.getName(); }
Block getHeader() const override;
void readPrefixImpl() override;
Block readImpl() override;
void readSuffixImpl() override;
bool needChannelUpdate();
void updateChannel();
bool sendAck();
private:
StorageRabbitMQ & storage;
StorageMetadataPtr metadata_snapshot;
Context context;
Names column_names;
const size_t max_block_size;
bool ack_in_suffix;
bool finished = false;
const Block non_virtual_header;
Block sample_block;
const Block virtual_header;
ConsumerBufferPtr buffer;
};
}