2015-10-09 14:51:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Core/Block.h>
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
2016-04-10 02:32:59 +00:00
|
|
|
#include <DB/Dictionaries/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
|
|
|
{
|
2016-12-11 09:43:16 +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
|
2015-10-09 14:51:31 +00:00
|
|
|
class MongoDBBlockInputStream final : public IProfilingBlockInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MongoDBBlockInputStream(
|
2016-12-11 09:43:16 +00:00
|
|
|
std::shared_ptr<Poco::MongoDB::Connection> & connection_,
|
|
|
|
std::unique_ptr<Poco::MongoDB::Cursor> cursor_,
|
|
|
|
const Block & sample_block,
|
|
|
|
const size_t max_block_size);
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
~MongoDBBlockInputStream() override;
|
2015-10-09 14:51:31 +00:00
|
|
|
|
|
|
|
String getName() const override { return "MongoDB"; }
|
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
String getID() const override;
|
2015-10-09 14:51:31 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-08 02:49:04 +00:00
|
|
|
Block readImpl() override;
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
static void insertDefaultValue(IColumn * column, const IColumn & sample_column)
|
2015-10-09 14:51:31 +00:00
|
|
|
{
|
2015-10-13 15:38:08 +00:00
|
|
|
column->insertFrom(sample_column, 0);
|
2015-10-09 14:51:31 +00:00
|
|
|
}
|
|
|
|
|
2016-12-11 09:43:16 +00:00
|
|
|
std::shared_ptr<Poco::MongoDB::Connection> connection;
|
|
|
|
std::unique_ptr<Poco::MongoDB::Cursor> cursor;
|
2016-12-08 02:49:04 +00:00
|
|
|
const size_t max_block_size;
|
2016-04-10 02:32:59 +00:00
|
|
|
ExternalResultDescription description;
|
2016-12-20 02:31:25 +00:00
|
|
|
bool all_read = false;
|
2015-10-09 14:51:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|