2017-10-17 10:44:46 +00:00
|
|
|
#pragma once
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
#include <Dictionaries/CatBoostModel.h>
|
|
|
|
#include <Interpreters/ExternalLoader.h>
|
|
|
|
#include <common/logger_useful.h>
|
|
|
|
#include <memory>
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
2017-10-26 18:30:28 +00:00
|
|
|
/// Manages user-defined models.
|
2017-10-17 10:44:46 +00:00
|
|
|
class ExternalModels : public ExternalLoader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using ModelPtr = std::shared_ptr<IModel>;
|
|
|
|
|
|
|
|
/// Models will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
2017-11-28 11:00:07 +00:00
|
|
|
ExternalModels(
|
|
|
|
std::unique_ptr<IExternalLoaderConfigRepository> config_repository,
|
|
|
|
Context & context,
|
|
|
|
bool throw_on_error);
|
2017-10-17 10:44:46 +00:00
|
|
|
|
|
|
|
/// Forcibly reloads specified model.
|
|
|
|
void reloadModel(const std::string & name) { reload(name); }
|
|
|
|
|
|
|
|
ModelPtr getModel(const std::string & name) const
|
|
|
|
{
|
|
|
|
return std::static_pointer_cast<IModel>(getLoadable(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
std::unique_ptr<IExternalLoadable> create(const std::string & name, const Configuration & config,
|
|
|
|
const std::string & config_prefix) override;
|
|
|
|
|
2017-12-04 12:15:21 +00:00
|
|
|
using ExternalLoader::getObjectsMap;
|
|
|
|
|
|
|
|
friend class StorageSystemModels;
|
2017-10-17 10:44:46 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
Context & context;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|