ClickHouse/dbms/Dictionaries/MongoDBBlockInputStream.h

47 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
#include <Core/Block.h>
#include <DataStreams/IBlockInputStream.h>
2019-02-15 11:46:07 +00:00
#include <Core/ExternalResultDescription.h>
2016-12-08 02:49:04 +00:00
namespace Poco
2016-12-08 02:49:04 +00:00
{
namespace MongoDB
{
class Connection;
class Cursor;
}
2016-12-08 02:49:04 +00:00
}
namespace DB
{
/// Converts MongoDB Cursor to a stream of Blocks
class MongoDBBlockInputStream final : public IBlockInputStream
{
public:
MongoDBBlockInputStream(
std::shared_ptr<Poco::MongoDB::Connection> & connection_,
std::unique_ptr<Poco::MongoDB::Cursor> cursor_,
const Block & sample_block,
2019-08-03 11:02:40 +00:00
const UInt64 max_block_size_);
~MongoDBBlockInputStream() override;
String getName() const override { return "MongoDB"; }
Block getHeader() const override { return description.sample_block.cloneEmpty(); }
private:
Block readImpl() override;
std::shared_ptr<Poco::MongoDB::Connection> connection;
std::unique_ptr<Poco::MongoDB::Cursor> cursor;
2019-02-10 16:55:12 +00:00
const UInt64 max_block_size;
ExternalResultDescription description;
bool all_read = false;
};
}