2020-05-20 09:40:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Storages/RabbitMQ/StorageRabbitMQ.h>
|
|
|
|
#include <Storages/RabbitMQ/ReadBufferFromRabbitMQConsumer.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-07-13 01:11:35 +00:00
|
|
|
|
2020-05-20 09:40:49 +00:00
|
|
|
class RabbitMQBlockInputStream : public IBlockInputStream
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
RabbitMQBlockInputStream(
|
|
|
|
StorageRabbitMQ & storage_,
|
2020-06-24 17:32:57 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot_,
|
2020-08-31 09:12:36 +00:00
|
|
|
Context & context_,
|
2020-08-28 08:52:02 +00:00
|
|
|
const Names & columns,
|
|
|
|
bool ack_in_suffix = true);
|
2020-05-20 09:40:49 +00:00
|
|
|
|
|
|
|
~RabbitMQBlockInputStream() override;
|
|
|
|
|
|
|
|
String getName() const override { return storage.getName(); }
|
|
|
|
Block getHeader() const override;
|
|
|
|
|
|
|
|
void readPrefixImpl() override;
|
|
|
|
Block readImpl() override;
|
2020-07-24 12:33:07 +00:00
|
|
|
void readSuffixImpl() override;
|
2020-05-20 09:40:49 +00:00
|
|
|
|
2020-08-28 08:52:02 +00:00
|
|
|
void updateChannel();
|
|
|
|
bool needManualChannelUpdate();
|
|
|
|
bool sendAck();
|
|
|
|
|
2020-05-20 09:40:49 +00:00
|
|
|
private:
|
|
|
|
StorageRabbitMQ & storage;
|
2020-06-24 17:32:57 +00:00
|
|
|
StorageMetadataPtr metadata_snapshot;
|
2020-08-31 09:12:36 +00:00
|
|
|
Context context;
|
2020-05-20 09:40:49 +00:00
|
|
|
Names column_names;
|
2020-08-28 08:52:02 +00:00
|
|
|
bool ack_in_suffix;
|
|
|
|
|
2020-07-13 01:11:35 +00:00
|
|
|
bool finished = false;
|
|
|
|
const Block non_virtual_header;
|
|
|
|
const Block virtual_header;
|
2020-05-20 09:40:49 +00:00
|
|
|
|
|
|
|
ConsumerBufferPtr buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|