1#pragma once
2
3#include <Dictionaries/IDictionary.h>
4#include <Interpreters/ExternalLoader.h>
5#include <memory>
6
7
8namespace DB
9{
10class Context;
11class IExternalLoaderConfigRepository;
12
13/// Manages user-defined dictionaries.
14class ExternalDictionariesLoader : public ExternalLoader
15{
16public:
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
32protected:
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
39private:
40 Context & context;
41};
42
43}
44