2019-09-26 11:19:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/CatBoostModel.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2019-09-26 11:19:10 +00:00
|
|
|
#include <Interpreters/ExternalLoader.h>
|
|
|
|
#include <common/logger_useful.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
|
2019-09-26 11:19:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Manages user-defined models.
|
2021-04-10 23:33:54 +00:00
|
|
|
class ExternalModelsLoader : public ExternalLoader, WithContext
|
2019-09-26 11:19:10 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
using ModelPtr = std::shared_ptr<const IModel>;
|
|
|
|
|
|
|
|
/// Models will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
2021-04-10 23:33:54 +00:00
|
|
|
explicit ExternalModelsLoader(ContextPtr context_);
|
2019-09-26 11:19:10 +00:00
|
|
|
|
2021-04-16 09:56:40 +00:00
|
|
|
ModelPtr getModel(const std::string & model_name) const
|
2019-09-26 11:19:10 +00:00
|
|
|
{
|
2021-04-16 09:56:40 +00:00
|
|
|
return std::static_pointer_cast<const IModel>(load(model_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
void reloadModel(const std::string & model_name) const
|
|
|
|
{
|
|
|
|
loadOrReload(model_name);
|
2019-09-26 11:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
LoadablePtr create(const std::string & name, const Poco::Util::AbstractConfiguration & config,
|
2020-03-09 00:08:02 +00:00
|
|
|
const std::string & config_prefix, const std::string & repository_name) const override;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
|
|
|
friend class StorageSystemModels;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|