ClickHouse/src/Dictionaries/DictionarySourceFactory.h

63 lines
1.6 KiB
C++
Raw Normal View History

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