ClickHouse/src/Storages/StorageMongoDB.h

56 lines
1.4 KiB
C++
Raw Normal View History

2020-05-13 23:20:45 +00:00
#pragma once
#include <ext/shared_ptr_helper.h>
#include <Storages/IStorage.h>
2020-06-26 14:28:00 +00:00
#include <Poco/MongoDB/Connection.h>
2020-05-13 23:20:45 +00:00
namespace DB
{
/* Implements storage in the MongoDB database.
* Use ENGINE = mysql(host_port, database_name, table_name, user_name, password)
* Read only.
*/
class StorageMongoDB final : public ext::shared_ptr_helper<StorageMongoDB>, public IStorage
{
friend struct ext::shared_ptr_helper<StorageMongoDB>;
public:
StorageMongoDB(
const StorageID & table_id_,
const std::string & host_,
short unsigned int port_,
const std::string & database_name_,
const std::string & collection_name_,
const std::string & username_,
const std::string & password_,
const ColumnsDescription & columns_,
2020-11-06 14:07:56 +00:00
const ConstraintsDescription & constraints_);
2020-05-13 23:20:45 +00:00
std::string getName() const override { return "MongoDB"; }
2020-08-03 13:54:14 +00:00
Pipe read(
2020-05-13 23:20:45 +00:00
const Names & column_names,
2020-06-26 14:28:00 +00:00
const StorageMetadataPtr & metadata_snapshot,
SelectQueryInfo & query_info,
2020-05-13 23:20:45 +00:00
const Context & context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
private:
std::string host;
short unsigned int port;
std::string database_name;
std::string collection_name;
std::string username;
std::string password;
std::shared_ptr<Poco::MongoDB::Connection> connection;
};
}