#pragma once #include "config.h" #if USE_MONGODB #include #include #include #include #include #include namespace Poco { namespace MongoDB { class Connection; class Document; class Cursor; class OpMsgCursor; } } namespace DB { struct MongoDBPocoLegacyArrayInfo { size_t num_dimensions; Field default_value; std::function parser; }; void authenticate(Poco::MongoDB::Connection & connection, const std::string & database, const std::string & user, const std::string & password); bool isMongoDBWireProtocolOld(Poco::MongoDB::Connection & connection_, const std::string & database_name_); /// Deprecated, will be removed soon. class MongoDBPocoLegacyCursor { public: MongoDBPocoLegacyCursor( const std::string & database, const std::string & collection, const Block & sample_block_to_select, const Poco::MongoDB::Document & query, Poco::MongoDB::Connection & connection); Poco::MongoDB::Document::Vector nextDocuments(Poco::MongoDB::Connection & connection); Int64 cursorID() const; private: const bool is_wire_protocol_old; std::unique_ptr old_cursor; std::unique_ptr new_cursor; Int64 cursor_id = 0; }; /// Converts MongoDB Cursor to a stream of Blocks. Deprecated, will be removed soon. class MongoDBPocoLegacySource final : public ISource { public: MongoDBPocoLegacySource( std::shared_ptr & connection_, const String & database_name_, const String & collection_name_, const Poco::MongoDB::Document & query_, const Block & sample_block, UInt64 max_block_size_); ~MongoDBPocoLegacySource() override; String getName() const override { return "MongoDB"; } private: Chunk generate() override; std::shared_ptr connection; MongoDBPocoLegacyCursor cursor; const UInt64 max_block_size; ExternalResultDescription description; bool all_read = false; std::unordered_map array_info; }; } #endif