Skip to content

Commit

Permalink
*: Remove external models (#5978)
Browse files Browse the repository at this point in the history
ref #4640
  • Loading branch information
ywqzzy authored Sep 22, 2022
1 parent 7c0472c commit 9e3e4fa
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 970 deletions.
530 changes: 0 additions & 530 deletions dbms/src/Dictionaries/CatBoostModel.cpp

This file was deleted.

100 changes: 0 additions & 100 deletions dbms/src/Dictionaries/CatBoostModel.h

This file was deleted.

40 changes: 1 addition & 39 deletions dbms/src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Common/TiFlashMetrics.h>
#include <Common/escapeForFileName.h>
#include <Common/formatReadable.h>
#include <Common/randomSeed.h>
#include <Common/setThreadName.h>
#include <DataStreams/FormatFactory.h>
#include <Databases/IDatabase.h>
Expand All @@ -32,7 +33,6 @@
#include <IO/ReadBufferFromFile.h>
#include <IO/UncompressedCache.h>
#include <Interpreters/Context.h>
#include <Interpreters/ExternalModels.h>
#include <Interpreters/ISecurityManager.h>
#include <Interpreters/ProcessList.h>
#include <Interpreters/QueryLog.h>
Expand Down Expand Up @@ -121,7 +121,6 @@ struct ContextShared
/// Separate mutex for access of dictionaries. Separate mutex to avoid locks when server doing request to itself.
mutable std::mutex embedded_dictionaries_mutex;
mutable std::mutex external_dictionaries_mutex;
mutable std::mutex external_models_mutex;

String path; /// Path to the primary data directory, with a slash at the end.
String tmp_path; /// The path to the temporary files that occur when processing the request.
Expand All @@ -132,7 +131,6 @@ struct ContextShared

Databases databases; /// List of databases and tables in them.
FormatFactory format_factory; /// Formats.
mutable std::shared_ptr<ExternalModels> external_models;
String default_profile_name; /// Default profile name used for default values.
String system_profile_name; /// Profile used by system processes
std::shared_ptr<ISecurityManager> security_manager; /// Known users.
Expand Down Expand Up @@ -1171,42 +1169,6 @@ Context & Context::getGlobalContext()
return *global_context;
}

const ExternalModels & Context::getExternalModels() const
{
return getExternalModelsImpl(false);
}

ExternalModels & Context::getExternalModels()
{
return getExternalModelsImpl(false);
}

ExternalModels & Context::getExternalModelsImpl(bool throw_on_error) const
{
std::lock_guard lock(shared->external_models_mutex);

if (!shared->external_models)
{
if (!this->global_context)
throw Exception("Logical error: there is no global context", ErrorCodes::LOGICAL_ERROR);

auto config_repository = runtime_components_factory->createExternalModelsConfigRepository();

shared->external_models = std::make_shared<ExternalModels>(
std::move(config_repository),
*this->global_context,
throw_on_error);
}

return *shared->external_models;
}

void Context::tryCreateExternalModels() const
{
static_cast<void>(getExternalModelsImpl(true));
}


void Context::setProgressCallback(ProgressCallback callback)
{
/// Callback is set to a session or to a query. In the session, only one query is processed at a time. Therefore, the lock is not needed.
Expand Down
7 changes: 0 additions & 7 deletions dbms/src/Interpreters/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace DB
struct ContextShared;
class IRuntimeComponentsFactory;
class QuotaForIntervals;
class ExternalModels;
class BackgroundProcessingPool;
class MergeList;
class MarkCache;
Expand Down Expand Up @@ -286,10 +285,6 @@ class Context
/// Set a setting by name. Read the value in text form from a string (for example, from a config, or from a URL parameter).
void setSetting(const String & name, const std::string & value);

const ExternalModels & getExternalModels() const;
ExternalModels & getExternalModels();
void tryCreateExternalModels() const;

/// I/O formats.
BlockInputStreamPtr getInputFormat(const String & name, ReadBuffer & buf, const Block & sample, size_t max_block_size) const;
BlockOutputStreamPtr getOutputFormat(const String & name, WriteBuffer & buf, const Block & sample) const;
Expand Down Expand Up @@ -495,8 +490,6 @@ class Context
*/
void checkDatabaseAccessRightsImpl(const std::string & database_name) const;

ExternalModels & getExternalModelsImpl(bool throw_on_error) const;

StoragePtr getTableImpl(const String & database_name, const String & table_name, Exception * exception) const;

SessionKey getSessionKey(const String & session_id) const;
Expand Down
83 changes: 0 additions & 83 deletions dbms/src/Interpreters/ExternalModels.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions dbms/src/Interpreters/ExternalModels.h

This file was deleted.

2 changes: 0 additions & 2 deletions dbms/src/Interpreters/IRuntimeComponentsFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class IRuntimeComponentsFactory
// Repositories with configurations of user-defined objects (dictionaries, models)
virtual std::unique_ptr<IExternalLoaderConfigRepository> createExternalDictionariesConfigRepository() = 0;

virtual std::unique_ptr<IExternalLoaderConfigRepository> createExternalModelsConfigRepository() = 0;

virtual ~IRuntimeComponentsFactory() {}
};

Expand Down
5 changes: 0 additions & 5 deletions dbms/src/Interpreters/RuntimeComponentsFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class RuntimeComponentsFactory : public IRuntimeComponentsFactory
{
return std::make_unique<ExternalLoaderConfigRepository>();
}

std::unique_ptr<IExternalLoaderConfigRepository> createExternalModelsConfigRepository() override
{
return std::make_unique<ExternalLoaderConfigRepository>();
}
};

} // namespace DB
Loading

0 comments on commit 9e3e4fa

Please sign in to comment.