2015-10-09 14:51:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2019-02-15 11:46:07 +00:00
|
|
|
#include <Core/ExternalResultDescription.h>
|
2016-12-08 02:49:04 +00:00
|
|
|
|
|
|
|
|
2016-12-11 09:43:16 +00:00
|
|
|
namespace Poco
|
2016-12-08 02:49:04 +00:00
|
|
|
{
|
2018-12-10 15:25:45 +00:00
|
|
|
namespace MongoDB
|
|
|
|
{
|
|
|
|
class Connection;
|
|
|
|
class Cursor;
|
|
|
|
}
|
2016-12-08 02:49:04 +00:00
|
|
|
}
|
2015-10-13 15:38:08 +00:00
|
|
|
|
2015-10-09 14:51:31 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2016-12-11 09:43:16 +00:00
|
|
|
/// Converts MongoDB Cursor to a stream of Blocks
|
2019-01-23 14:48:50 +00:00
|
|
|
class MongoDBBlockInputStream final : public IBlockInputStream
|
2015-10-09 14:51:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
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_);
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
~MongoDBBlockInputStream() override;
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "MongoDB"; }
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2018-10-12 02:41:54 +00:00
|
|
|
Block getHeader() const override { return description.sample_block.cloneEmpty(); }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2015-10-09 14:51:31 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
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;
|
2017-04-01 07:20:54 +00:00
|
|
|
ExternalResultDescription description;
|
|
|
|
bool all_read = false;
|
2015-10-09 14:51:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|