ClickHouse/dbms/Dictionaries/DictionaryFactory.h

67 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include "IDictionary.h"
2019-12-15 06:34:43 +00:00
#include "registerDictionaries.h"
2019-10-10 17:33:01 +00:00
#include <Parsers/ASTCreateQuery.h>
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
}
class Logger;
}
namespace DB
{
2015-02-03 17:03:35 +00:00
class Context;
2020-01-27 12:43:28 +00:00
/** Create dictionary according to its layout.
*/
class DictionaryFactory : private boost::noncopyable
{
public:
static DictionaryFactory & instance();
/// Create dictionary from AbstractConfiguration parsed
/// from xml-file on filesystem.
2019-10-10 17:33:01 +00:00
DictionaryPtr create(
const std::string & name,
const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix,
const Context & context,
bool check_source_config = false) const;
2019-10-10 17:33:01 +00:00
/// Create dictionary from DDL-query
2019-10-10 17:33:01 +00:00
DictionaryPtr create(const std::string & name,
const ASTCreateQuery & ast,
const Context & context) const;
using Creator = std::function<DictionaryPtr(
const std::string & name,
const DictionaryStructure & dict_struct,
const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix,
DictionarySourcePtr source_ptr)>;
bool isComplex(const std::string & layout_type) const;
void registerLayout(const std::string & layout_type, Creator create_layout, bool is_complex);
private:
using LayoutRegistry = std::unordered_map<std::string, Creator>;
LayoutRegistry registered_layouts;
using LayoutComplexity = std::unordered_map<std::string, bool>;
LayoutComplexity layout_complexity;
};
}