2015-01-26 15:27:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-11-28 11:37:12 +00:00
|
|
|
#include "IDictionarySource.h"
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Core/Block.h>
|
2016-01-12 02:21:15 +00:00
|
|
|
|
2017-11-27 17:34:43 +00:00
|
|
|
#include <unordered_map>
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
namespace Poco
|
2015-01-26 15:27:51 +00:00
|
|
|
{
|
2018-11-28 11:37:12 +00:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
2017-11-27 17:34:43 +00:00
|
|
|
|
2018-11-28 11:37:12 +00:00
|
|
|
class Logger;
|
2015-01-26 15:27:51 +00:00
|
|
|
}
|
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class Context;
|
2016-12-12 06:02:35 +00:00
|
|
|
struct DictionaryStructure;
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2015-02-10 14:50:43 +00:00
|
|
|
/// creates IDictionarySource instance from config and DictionaryStructure
|
2019-08-22 03:24:05 +00:00
|
|
|
class DictionarySourceFactory : private boost::noncopyable
|
2015-01-26 15:27:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-22 03:24:05 +00:00
|
|
|
static DictionarySourceFactory & instance();
|
|
|
|
|
2020-08-15 03:10:57 +00:00
|
|
|
/// 'default_database' - the database when dictionary itself was created.
|
|
|
|
/// It is used as default_database for ClickHouse dictionary source when no explicit database was specified.
|
|
|
|
/// Does not make sense for other sources.
|
2017-11-27 17:34:43 +00:00
|
|
|
using Creator = std::function<DictionarySourcePtr(
|
|
|
|
const DictionaryStructure & dict_struct,
|
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
|
|
|
Block & sample_block,
|
2019-12-10 17:27:29 +00:00
|
|
|
const Context & context,
|
2020-08-15 03:10:57 +00:00
|
|
|
const std::string & default_database,
|
2019-12-10 17:27:29 +00:00
|
|
|
bool check_config)>;
|
2017-11-27 17:34:43 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DictionarySourceFactory();
|
2016-04-10 10:24:07 +00:00
|
|
|
|
2017-11-27 17:34:43 +00:00
|
|
|
void registerSource(const std::string & source_type, Creator create_source);
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DictionarySourcePtr create(
|
2018-11-28 11:37:12 +00:00
|
|
|
const std::string & name,
|
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
|
|
|
const DictionaryStructure & dict_struct,
|
2019-12-10 17:27:29 +00:00
|
|
|
const Context & context,
|
2020-08-15 03:10:57 +00:00
|
|
|
const std::string & default_database,
|
2019-12-10 17:27:29 +00:00
|
|
|
bool check_config) const;
|
2017-11-27 17:34:43 +00:00
|
|
|
|
|
|
|
private:
|
2017-11-27 19:06:10 +00:00
|
|
|
using SourceRegistry = std::unordered_map<std::string, Creator>;
|
|
|
|
SourceRegistry registered_sources;
|
2017-11-27 17:34:43 +00:00
|
|
|
|
|
|
|
Poco::Logger * log;
|
2015-01-26 15:27:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|