2015-02-10 17:40:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Dictionaries/IDictionary.h>
|
2017-10-06 10:31:06 +00:00
|
|
|
#include <Interpreters/ExternalLoader.h>
|
2015-09-29 19:19:54 +00:00
|
|
|
#include <common/logger_useful.h>
|
2017-10-06 10:31:06 +00:00
|
|
|
#include <memory>
|
2017-09-09 23:17:38 +00:00
|
|
|
|
2015-02-10 17:40:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Manages user-defined dictionaries.
|
|
|
|
class ExternalDictionaries : public ExternalLoader
|
2015-02-10 17:40:40 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
public:
|
|
|
|
using DictPtr = std::shared_ptr<IDictionaryBase>;
|
2015-03-24 09:46:07 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
|
|
|
ExternalDictionaries(Context & context, bool throw_on_error);
|
2015-03-18 16:07:15 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Forcibly reloads specified dictionary.
|
|
|
|
void reloadDictionary(const std::string & name) { reload(name); }
|
2017-08-24 18:19:06 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
DictPtr getDictionary(const std::string & name) const
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
return std::static_pointer_cast<IDictionaryBase>(getLoadable(name));
|
|
|
|
}
|
2015-05-26 11:53:58 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
protected:
|
2015-06-09 16:12:51 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
LoadablePtr create(const std::string & name, const Configuration & config,
|
|
|
|
const std::string & config_prefix) override;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
using ExternalLoader::getObjectsMap;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
friend class StorageSystemDictionaries;
|
|
|
|
friend class DatabaseDictionary;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
private:
|
2015-02-10 17:40:40 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Context & context;
|
2015-02-10 17:40:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|