ClickHouse/src/Dictionaries/MongoDBDictionarySource.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
#include <Processors/Sources/MongoDBSource.h>
#include <Core/Block.h>
#include "DictionaryStructure.h"
#include "IDictionarySource.h"
2016-12-08 02:49:04 +00:00
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
}
namespace MongoDB
{
class Connection;
}
2016-01-12 02:21:15 +00:00
}
2016-12-08 02:49:04 +00:00
namespace DB
{
2020-02-25 18:10:48 +00:00
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
}
2020-02-25 18:20:08 +00:00
/// Allows loading dictionaries from a MongoDB collection
class MongoDBDictionarySource final : public IDictionarySource
{
2020-05-14 11:36:19 +00:00
public:
MongoDBDictionarySource(
2019-08-03 11:02:40 +00:00
const DictionaryStructure & dict_struct_,
2020-05-14 11:36:19 +00:00
const std::string & uri_,
2019-08-03 11:02:40 +00:00
const std::string & host_,
UInt16 port_,
const std::string & user_,
const std::string & password_,
const std::string & method_,
const std::string & db_,
const std::string & collection_,
2023-04-26 19:19:10 +00:00
const std::string & options,
2019-08-03 11:02:40 +00:00
const Block & sample_block_);
2016-12-08 02:49:04 +00:00
MongoDBDictionarySource(const MongoDBDictionarySource & other);
2017-03-09 04:26:17 +00:00
~MongoDBDictionarySource() override;
2022-05-20 19:49:31 +00:00
QueryPipeline loadAll() override;
2022-05-20 19:49:31 +00:00
QueryPipeline loadUpdatedAll() override
{
2021-04-10 18:48:36 +00:00
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method loadUpdatedAll is unsupported for MongoDBDictionarySource");
}
2016-12-08 02:49:04 +00:00
bool supportsSelectiveLoad() const override { return true; }
2022-05-20 19:49:31 +00:00
QueryPipeline loadIds(const std::vector<UInt64> & ids) override;
2022-05-20 19:49:31 +00:00
QueryPipeline loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
/// @todo: for MongoDB, modification date can somehow be determined from the `_id` object field
bool isModified() const override { return true; }
///Not yet supported
bool hasUpdateField() const override { return false; }
DictionarySourcePtr clone() const override { return std::make_shared<MongoDBDictionarySource>(*this); }
2016-12-08 02:49:04 +00:00
std::string toString() const override;
private:
const DictionaryStructure dict_struct;
2020-05-14 11:36:19 +00:00
const std::string uri;
2020-05-19 20:12:10 +00:00
std::string host;
UInt16 port;
std::string user;
const std::string password;
const std::string method;
2020-05-19 20:12:10 +00:00
std::string db;
const std::string collection;
2023-04-26 19:19:10 +00:00
const std::string options;
Block sample_block;
std::shared_ptr<Poco::MongoDB::Connection> connection;
};
}