OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InternalMLModelMetadataDataWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "Catalog/SysCatalog.h"
20 #include "ImportExport/Importer.h"
21 #include "QueryEngine/Execute.h"
22 
24 
25 namespace foreign_storage {
28 
30  const int db_id,
31  const ForeignTable* foreign_table)
32  : InternalSystemDataWrapper(db_id, foreign_table) {}
33 
34 namespace {
36  const std::vector<MLModelMetadata>& ml_models_metadata,
37  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
38  for (const auto& ml_model_metadata : ml_models_metadata) {
39  if (auto itr = import_buffers.find("model_name"); itr != import_buffers.end()) {
40  itr->second->addString(ml_model_metadata.getModelName());
41  }
42  if (auto itr = import_buffers.find("model_type"); itr != import_buffers.end()) {
43  itr->second->addString(ml_model_metadata.getModelTypeStr());
44  }
45  if (auto itr = import_buffers.find("predicted"); itr != import_buffers.end()) {
46  itr->second->addString(ml_model_metadata.getPredicted());
47  }
48  if (auto itr = import_buffers.find("features"); itr != import_buffers.end()) {
49  itr->second->addStringArray(ml_model_metadata.getFeatures());
50  }
51  if (auto itr = import_buffers.find("training_query"); itr != import_buffers.end()) {
52  itr->second->addString(ml_model_metadata.getTrainingQuery());
53  }
54  if (auto itr = import_buffers.find("num_logical_features");
55  itr != import_buffers.end()) {
56  itr->second->addBigint(ml_model_metadata.getNumLogicalFeatures());
57  }
58  if (auto itr = import_buffers.find("num_physical_features");
59  itr != import_buffers.end()) {
60  itr->second->addBigint(ml_model_metadata.getNumFeatures());
61  }
62  if (auto itr = import_buffers.find("num_categorical_features");
63  itr != import_buffers.end()) {
64  itr->second->addBigint(ml_model_metadata.getNumCategoricalFeatures());
65  }
66  if (auto itr = import_buffers.find("num_numeric_features");
67  itr != import_buffers.end()) {
68  itr->second->addBigint(ml_model_metadata.getNumLogicalFeatures() -
69  ml_model_metadata.getNumCategoricalFeatures());
70  }
71  if (auto itr = import_buffers.find("train_fraction"); itr != import_buffers.end()) {
72  itr->second->addDouble(ml_model_metadata.getDataSplitTrainFraction());
73  }
74  if (auto itr = import_buffers.find("eval_fraction"); itr != import_buffers.end()) {
75  itr->second->addDouble(ml_model_metadata.getDataSplitEvalFraction());
76  }
77  }
78 }
79 
80 } // namespace
81 
83  const std::string& table_name) {
84  CHECK_EQ(foreign_table_->tableName, table_name);
86  << "Unexpected table name: " << foreign_table_->tableName;
89 }
90 
92  const std::string& table_name,
93  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
94  CHECK_EQ(foreign_table_->tableName, table_name);
96  << "Unexpected table name: " << foreign_table_->tableName;
98 }
99 
100 } // namespace foreign_storage
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::string tableName
std::vector< MLModelMetadata > getModelMetadata() const
Definition: MLModel.h:83
void initializeObjectsForTable(const std::string &table_name) override
void populate_import_buffers_for_ml_model_metadata(const std::vector< MLModelMetadata > &ml_models_metadata, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
This file contains the class specification and related data structures for SysCatalog.
MLModelMap g_ml_models
Definition: MLModel.h:124
static constexpr const char * ML_MODEL_METADATA_SYS_TABLE_NAME
Definition: Catalog.h:124
void populateChunkBuffersForTable(const std::string &table_name, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers) override