1 | #pragma once |
2 | |
3 | #include "IDictionary.h" |
4 | #include "registerDictionaries.h" |
5 | #include <Parsers/ASTCreateQuery.h> |
6 | |
7 | |
8 | namespace Poco |
9 | { |
10 | |
11 | namespace Util |
12 | { |
13 | class AbstractConfiguration; |
14 | } |
15 | |
16 | class Logger; |
17 | |
18 | } |
19 | |
20 | |
21 | namespace DB |
22 | { |
23 | |
24 | class Context; |
25 | |
26 | class DictionaryFactory : private boost::noncopyable |
27 | { |
28 | public: |
29 | |
30 | static DictionaryFactory & instance(); |
31 | |
32 | /// Create dictionary from AbstractConfiguration parsed |
33 | /// from xml-file on filesystem. |
34 | DictionaryPtr create( |
35 | const std::string & name, |
36 | const Poco::Util::AbstractConfiguration & config, |
37 | const std::string & config_prefix, |
38 | const Context & context, |
39 | bool check_source_config = false) const; |
40 | |
41 | /// Create dictionary from DDL-query |
42 | DictionaryPtr create(const std::string & name, |
43 | const ASTCreateQuery & ast, |
44 | const Context & context) const; |
45 | |
46 | using Creator = std::function<DictionaryPtr( |
47 | const std::string & name, |
48 | const DictionaryStructure & dict_struct, |
49 | const Poco::Util::AbstractConfiguration & config, |
50 | const std::string & config_prefix, |
51 | DictionarySourcePtr source_ptr)>; |
52 | |
53 | bool isComplex(const std::string & layout_type) const; |
54 | |
55 | void registerLayout(const std::string & layout_type, Creator create_layout, bool is_complex); |
56 | |
57 | private: |
58 | using LayoutRegistry = std::unordered_map<std::string, Creator>; |
59 | LayoutRegistry registered_layouts; |
60 | using LayoutComplexity = std::unordered_map<std::string, bool>; |
61 | LayoutComplexity layout_complexity; |
62 | }; |
63 | |
64 | } |
65 | |