1 | #pragma once |
---|---|
2 | |
3 | #include <Dictionaries/IDictionary.h> |
4 | #include <Interpreters/ExternalLoader.h> |
5 | #include <memory> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | class Context; |
11 | class IExternalLoaderConfigRepository; |
12 | |
13 | /// Manages user-defined dictionaries. |
14 | class ExternalDictionariesLoader : public ExternalLoader |
15 | { |
16 | public: |
17 | using DictPtr = std::shared_ptr<const IDictionaryBase>; |
18 | |
19 | /// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds. |
20 | ExternalDictionariesLoader(Context & context_); |
21 | |
22 | DictPtr getDictionary(const std::string & name) const |
23 | { |
24 | return std::static_pointer_cast<const IDictionaryBase>(load(name)); |
25 | } |
26 | |
27 | DictPtr tryGetDictionary(const std::string & name) const |
28 | { |
29 | return std::static_pointer_cast<const IDictionaryBase>(tryLoad(name)); |
30 | } |
31 | |
32 | protected: |
33 | LoadablePtr create(const std::string & name, const Poco::Util::AbstractConfiguration & config, |
34 | const std::string & key_in_config, const std::string & repository_name) const override; |
35 | |
36 | friend class StorageSystemDictionaries; |
37 | friend class DatabaseDictionary; |
38 | |
39 | private: |
40 | Context & context; |
41 | }; |
42 | |
43 | } |
44 |