2019-01-21 14:02:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-24 12:44:58 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2019-01-21 14:02:03 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2019-01-30 17:41:06 +00:00
|
|
|
|
|
|
|
#include <Storages/Kafka/StorageKafka.h>
|
2019-08-28 13:21:19 +00:00
|
|
|
#include <Storages/Kafka/ReadBufferFromKafkaConsumer.h>
|
|
|
|
|
2019-01-21 14:02:03 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-01-24 12:44:58 +00:00
|
|
|
class KafkaBlockInputStream : public IBlockInputStream
|
2019-01-21 14:02:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-10-02 21:17:19 +00:00
|
|
|
KafkaBlockInputStream(
|
2020-06-03 10:00:15 +00:00
|
|
|
StorageKafka & storage_, const std::shared_ptr<Context> & context_, const Names & columns, size_t max_block_size_, bool commit_in_suffix = true);
|
2019-01-21 14:02:03 +00:00
|
|
|
~KafkaBlockInputStream() override;
|
|
|
|
|
2019-01-30 17:41:06 +00:00
|
|
|
String getName() const override { return storage.getName(); }
|
2019-05-22 19:38:43 +00:00
|
|
|
Block getHeader() const override;
|
2019-01-30 17:41:06 +00:00
|
|
|
|
2019-01-21 14:02:03 +00:00
|
|
|
void readPrefixImpl() override;
|
2019-05-22 19:38:43 +00:00
|
|
|
Block readImpl() override;
|
2019-01-21 14:02:03 +00:00
|
|
|
void readSuffixImpl() override;
|
|
|
|
|
2019-10-02 21:17:19 +00:00
|
|
|
void commit();
|
2020-05-22 16:58:08 +00:00
|
|
|
bool isStalled() const { return buffer->isStalled(); }
|
2019-10-02 21:17:19 +00:00
|
|
|
|
2019-01-21 14:02:03 +00:00
|
|
|
private:
|
|
|
|
StorageKafka & storage;
|
2020-06-03 10:00:15 +00:00
|
|
|
const std::shared_ptr<Context> context;
|
2019-05-22 19:38:43 +00:00
|
|
|
Names column_names;
|
2019-02-11 11:54:30 +00:00
|
|
|
UInt64 max_block_size;
|
2019-01-25 12:48:59 +00:00
|
|
|
|
2019-08-20 11:17:57 +00:00
|
|
|
ConsumerBufferPtr buffer;
|
2020-05-03 13:04:04 +00:00
|
|
|
bool broken = true;
|
|
|
|
bool finished = false;
|
|
|
|
bool commit_in_suffix;
|
2020-01-28 13:24:37 +00:00
|
|
|
|
2020-05-03 13:04:04 +00:00
|
|
|
const Block non_virtual_header;
|
|
|
|
const Block virtual_header;
|
2019-01-21 14:02:03 +00:00
|
|
|
};
|
|
|
|
|
2019-06-13 10:37:13 +00:00
|
|
|
}
|