2015-10-09 14:51:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2022-05-20 19:49:31 +00:00
|
|
|
#include <Processors/ISource.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
|
|
|
|
{
|
2020-06-26 14:28:00 +00:00
|
|
|
|
|
|
|
void authenticate(Poco::MongoDB::Connection & connection, const std::string & database, const std::string & user, const std::string & password);
|
|
|
|
|
|
|
|
std::unique_ptr<Poco::MongoDB::Cursor> createCursor(const std::string & database, const std::string & collection, const Block & sample_block_to_select);
|
|
|
|
|
2016-12-11 09:43:16 +00:00
|
|
|
/// Converts MongoDB Cursor to a stream of Blocks
|
2022-05-20 19:49:31 +00:00
|
|
|
class MongoDBSource final : public ISource
|
2015-10-09 14:51:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-08-05 18:08:52 +00:00
|
|
|
MongoDBSource(
|
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,
|
2022-04-19 08:59:47 +00:00
|
|
|
UInt64 max_block_size_);
|
2015-10-09 14:51:31 +00:00
|
|
|
|
2021-08-05 18:08:52 +00:00
|
|
|
~MongoDBSource() override;
|
2015-10-09 14:51:31 +00:00
|
|
|
|
|
|
|
String getName() const override { return "MongoDB"; }
|
|
|
|
|
|
|
|
private:
|
2021-08-05 18:08:52 +00:00
|
|
|
Chunk generate() override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2016-12-11 09:43:16 +00:00
|
|
|
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;
|
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
|
|
|
};
|
|
|
|
|
2021-08-06 08:41:45 +00:00
|
|
|
}
|