ClickHouse/dbms/include/DB/Dictionaries/MongoDBBlockInputStream.h

53 lines
1.1 KiB
C++
Raw Normal View History

#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
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 IProfilingBlockInputStream
{
public:
MongoDBBlockInputStream(
std::shared_ptr<Poco::MongoDB::Connection> & connection_,
std::unique_ptr<Poco::MongoDB::Cursor> cursor_,
const Block & sample_block,
const size_t max_block_size);
2016-12-08 02:49:04 +00:00
~MongoDBBlockInputStream() override;
String getName() const override { return "MongoDB"; }
2016-12-08 02:49:04 +00:00
String getID() const override;
private:
2016-12-08 02:49:04 +00:00
Block readImpl() override;
2016-12-08 02:49:04 +00:00
static void insertDefaultValue(IColumn * column, const IColumn & sample_column)
{
column->insertFrom(sample_column, 0);
}
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;
bool all_read = false;
};
}