8#ifndef MODEL_SQL_BUILDER_H
9#define MODEL_SQL_BUILDER_H
34 ModelSqlBuilder(
const string & i_providerNames,
const string & i_sqlDir,
const string & i_outputDir,
const string & i_sqliteDir);
40 bool isSqliteDb(
void)
const override {
return isSqlite; }
73 list<string> dbProviderLst;
74 unique_ptr<IDbExec> dbExec;
89 vector<string> dimVec;
92 vector<string> colVec;
95 vector<int> typeIdVec;
97 DbTblInfo(
void) : id(-1) { }
101 struct ParamTblInfo : DbTblInfo
104 vector<TypeDicRow>::const_iterator valueTypeIt;
114 struct OutTblInfo : DbTblInfo
117 vector<int> accIdVec;
120 vector<string> accNameVec;
123 vector<string> accColVec;
127 vector<ParamTblInfo> paramInfoVec;
130 vector<OutTblInfo> outInfoVec;
133 void prepare(MetaModelHolder & io_metaRows)
const;
136 void buildCreateModel(
const string & i_sqlProvider,
const MetaModelHolder & i_metaRows,
const string & i_filePath)
const;
139 static void createModel(IDbExec * i_dbExec, MetaModelHolder & io_metaRows);
142 void buildCreateModelTables(
const string & i_sqlProvider,
const MetaModelHolder & i_metaRows,
const string & i_filePath)
const;
145 void buildDropModelTables(
const MetaModelHolder & i_metaRows,
const string & i_filePath)
const;
148 void prepareWorkset(
const MetaModelHolder & i_metaRows, MetaSetLangHolder & io_metaSet)
const;
151 void doAddScalarWorksetParameter(
153 const string & i_name,
154 const string & i_dbTableName,
155 const vector<ParamTblInfo>::const_iterator & i_paramInfo,
157 const string & i_value
161 const void paramCreateTable(
162 const string & i_sqlProvider,
163 const string & i_dbTableName,
164 const string & i_runSetId,
165 const ParamTblInfo & i_tblInfo,
166 ModelSqlWriter & io_wr
170 const void accCreateTable(
171 const string & i_sqlProvider,
172 const string & i_dbTableName,
173 const OutTblInfo & i_tblInfo,
174 ModelSqlWriter & io_wr
178 const void valueCreateTable(
179 const string & i_sqlProvider,
180 const string & i_dbTableName,
181 const OutTblInfo & i_tblInfo,
182 ModelSqlWriter & io_wr
186 const void accAllCreateView(
187 const string & i_sqlProvider,
188 const string & i_viewName,
189 const OutTblInfo & i_tblInfo,
190 const string & i_accTablName,
191 const vector<TableAccRow> & i_accVec,
192 ModelSqlWriter & io_wr
196 const void paramCompatibilityView(
197 const string & i_sqlProvider,
198 const ModelDicRow & i_modelRow,
199 const string & i_viewName,
200 const string & i_srcTableName,
201 const vector<string> & i_colNames,
202 const vector<int> & i_dimsLowerBound,
203 int i_valueLowerBound,
204 ModelSqlWriter & io_wr
208 const void outputCompatibilityView(
209 const string & i_sqlProvider,
210 const ModelDicRow & i_modelRow,
211 const string & i_viewName,
212 const string & i_srcTableName,
213 const vector<string> & i_colNames,
214 const vector<int> & i_dimsLowerBound,
215 ModelSqlWriter & io_wr
219 void setWorksetRow(WorksetLstRow & io_wsRow)
const;
222 void setTypeDicRows(MetaModelHolder & io_metaRows)
const;
225 void setParamTableInfo(MetaModelHolder & io_metaRows);
228 void setOutTableInfo(MetaModelHolder & io_metaRows);
231 void setParamDicRows(MetaModelHolder & io_metaRows)
const;
234 void setTableDicRows(MetaModelHolder & io_metaRows)
const;
237 void setEntityDicRows(MetaModelHolder& io_metaRows)
const;
240 void setModelProfileRows(MetaModelHolder & io_metaRows)
const;
243 static void trimModelRows(MetaModelHolder & io_metaRows);
246 static void sortModelRows(MetaModelHolder & io_metaRows);
249 static void sortWorksetRows(MetaSetLangHolder & io_metaSet);
252 static void setColumnNames(MetaModelHolder & io_metaRows);
255 void setModelDicRow(ModelDicRow & io_mdRow)
const;
258 static const string makeTypeDigest(
const TypeDicRow & i_typeRow,
const MetaModelHolder & i_metaRows);
261 static const tuple<string, string> makeParamDigest(
const ParamDicRow & i_paramRow,
const MetaModelHolder & i_metaRows);
264 static const tuple<string, string> makeOutTableDigest(
const TableDicRow i_tableRow,
const MetaModelHolder & i_metaRows);
267 static const string makeEntityDigest(
const EntityDicRow i_entityRow,
const MetaModelHolder& i_metaRows);
270 static const string makeModelDigest(
const MetaModelHolder & i_metaRows);
class to build model creation sql from metadata rows.
Definition: modelSqlBuilder.h:31
void addWorksetParameter(const MetaModelHolder &i_metaRows, const MetaSetLangHolder &i_metaSet, const string &i_name, int i_subId, const string &i_value) override
append scalar parameter value to sql script for new working set creation
Definition: modelSqlBuilder.cpp:517
void build(MetaModelHolder &io_metaRows) override
update metadata and write sql script to create new model from supplied metadata rows
Definition: modelSqlBuilder.cpp:34
~ModelSqlBuilder() noexcept
release builder resources.
Definition: modelSqlBuilder.h:37
ModelSqlBuilder(const string &i_providerNames, const string &i_sqlDir, const string &i_outputDir, const string &i_sqliteDir)
create new model builder.
Definition: modelSqlBuilder.cpp:19
void buildCompatibilityViews(const MetaModelHolder &i_metaRows) const override
write sql script to create backward compatibility views
Definition: modelSqlBuilder.cpp:771
void setModelMetaRows(MetaModelHolder &io_metaRows) const override
set meta rows values and calculate digests for types, parameters, tables and model
Definition: modelSqlBuilderPrepare.cpp:10
bool isSqliteDb(void) const override
if true then create SQLite database
Definition: modelSqlBuilder.h:40
void beginWorkset(const MetaModelHolder &i_metaRows, MetaSetLangHolder &io_metaSet) override
start sql script to create new working set
Definition: modelSqlBuilder.cpp:450
void endWorkset(const MetaModelHolder &i_metaRows, const MetaSetLangHolder &i_metaSet) override
finish sql script to create new working set
Definition: modelSqlBuilder.cpp:485
OpenM++ CRC-32 impelementation, it is same CRC-32 as V.42, gzip, PNG.
OpenM++ data library: public interface.
OpenM++ common helper utilities.
OpenM++ common file utilities.
OpenM++ data library: public interface to produce model creation script.
OpenM++ data library: classes to translate output table accumulators and expressions into sql.
OpenM++ data library: class to produce insert sql statements for new model.
OpenM++ data library: wrapper around file stream to write into sql script file.
openM++ namespace
Definition: log.h:32
OpenM++ common file utilities.
public interface to build model creation script from metadata rows.
Definition: modelBuilder.h:22