Documentation ¶
Overview ¶
Package db to support openM++ model database operations.
Database may contain multiple openM++ models and consists of two parts: (a) metadata to describe models: data types, input parameters, output tables, etc. (b) actual modeling data itself: database tables for input parameters and output tables.
To run the model we need to have a set of model input parameters, called "input working set" or "workset". User can "open" workset in read-write mode and modify model input parameters. To use that set as model run input user must "close" it by marking workset as read-only. After model run user can again open workset as read-write and continue input editing. Each workset has a name (unique inside of the model) and set id (database unique positive int).
Result of model run stored in output tables and also include copy of all input parameters used to run the model. That pair of input and output data called "run" and identified by run id (database unique positive int).
Index ¶
- Constants
- func CheckOpenmppSchemaVersion(dbConn *sql.DB) error
- func CopyParameterFromRun(dbConn *sql.DB, modelDef *ModelMeta, ws *WorksetRow, paramName string, ...) error
- func CopyParameterFromWorkset(dbConn *sql.DB, modelDef *ModelMeta, dstWs *WorksetRow, paramName string, ...) error
- func DeleteModel(dbConn *sql.DB, modelId int) error
- func DeleteProfile(dbConn *sql.DB, name string) error
- func DeleteProfileOption(dbConn *sql.DB, name, key string) error
- func DeleteRun(dbConn *sql.DB, runId int) error
- func DeleteTask(dbConn *sql.DB, taskId int) error
- func DeleteWorkset(dbConn *sql.DB, setId int) error
- func DeleteWorksetAllParameters(dbConn *sql.DB, setId int) error
- func DeleteWorksetParameter(dbConn *sql.DB, modelId int, setName, paramName string) (int, error)
- func GetModelId(dbConn *sql.DB, name, digest string) (bool, int, error)
- func GetModelRunOptions(dbConn *sql.DB, modelId int) (map[int]map[string]string, error)
- func GetProfileList(dbConn *sql.DB) ([]string, error)
- func GetRunListText(dbConn *sql.DB, modelId int, langCode string) ([]RunRow, []RunTxtRow, error)
- func GetRunOptions(dbConn *sql.DB, runId int) (map[string]string, error)
- func GetTaskListText(dbConn *sql.DB, modelId int, langCode string) ([]TaskRow, []TaskTxtRow, error)
- func GetTaskSetIds(dbConn *sql.DB, taskId int) ([]int, error)
- func GetWorksetListText(dbConn *sql.DB, modelId int, langCode string) ([]WorksetRow, []WorksetTxtRow, error)
- func GetWorksetParam(dbConn *sql.DB, setId int, paramHid int) (int, int, error)
- func GetWorksetParamList(dbConn *sql.DB, setId int) ([]int, []int, []int, error)
- func GetWorksetRunIds(dbConn *sql.DB, setId int) ([]int, error)
- func IfEmptyMakeDefault(modelName, sqlitePath, dbConnStr, dbDriver string) (string, string)
- func IfEmptyMakeDefaultReadOnly(modelName, sqlitePath, dbConnStr, dbDriver string) (string, string)
- func IsRunCompleted(status string) bool
- func IsUnsafeQuote(c rune) bool
- func MakeSqliteDefault(sqlitePath string) string
- func MakeSqliteDefaultReadOnly(sqlitePath string) string
- func NameOfRunStatus(status string) string
- func OpenmppSchemaVersion(dbConn *sql.DB) (int, error)
- func RenameRun(dbConn *sql.DB, runId int, newRunName string) (bool, error)
- func RenameTask(dbConn *sql.DB, taskId int, newTaskName string) (bool, error)
- func RenameWorkset(dbConn *sql.DB, setId int, newSetName string, isAnyReadonly bool) (bool, error)
- func SelectFirst(dbConn *sql.DB, query string, cvt func(row *sql.Row) error) error
- func SelectRows(dbConn *sql.DB, query string, cvt func(rows *sql.Rows) error) error
- func SelectRowsTo(dbConn *sql.DB, query string, cvt func(rows *sql.Rows) (bool, error)) error
- func ToQuoted(src string) string
- func TrxSelectFirst(dbTrx *sql.Tx, query string, cvt func(row *sql.Row) error) error
- func TrxSelectRows(dbTrx *sql.Tx, query string, cvt func(rows *sql.Rows) error) error
- func TrxUpdate(dbTrx *sql.Tx, query string) error
- func TrxUpdateStatement(dbTrx *sql.Tx, query string, put func() (bool, []interface{}, error)) error
- func Update(dbConn *sql.DB, query string) error
- func UpdateLanguage(dbConn *sql.DB, langDef *LangMeta) error
- func UpdateModel(dbConn *sql.DB, dbFacet Facet, modelDef *ModelMeta) (bool, error)
- func UpdateModelText(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, modelTxt *ModelTxtMeta) error
- func UpdateModelWord(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, mwDef *ModelWordMeta) error
- func UpdateProfile(dbConn *sql.DB, profile *ProfileMeta) error
- func UpdateProfileOption(dbConn *sql.DB, name, key, val string) error
- func UpdateRunParameterText(dbConn *sql.DB, modelDef *ModelMeta, runId int, ...) error
- func UpdateRunStatus(dbConn *sql.DB, runId int, status string) error
- func UpdateRunValueDigest(dbConn *sql.DB, runId int) (string, error)
- func UpdateWorksetParameterText(dbConn *sql.DB, modelDef *ModelMeta, setName string, ...) error
- func UpdateWorksetReadonly(dbConn *sql.DB, setId int, isReadonly bool) error
- func UpdateWorksetReadonlyByName(dbConn *sql.DB, modelId int, name string, isReadonly bool) error
- func WriteMicrodataFrom(dbConn *sql.DB, dbFacet Facet, modelDef *ModelMeta, runMeta *RunMeta, ...) error
- func WriteOutputTableFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteTableLayout, ...) error
- func WriteParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteParamLayout, ...) error
- type CalcMaps
- type CalculateLayout
- type CalculateMicroLayout
- type CalculateTableLayout
- type CellAcc
- type CellAccConverter
- func (cellCvt *CellAccConverter) CsvFileName() (string, error)
- func (cellCvt *CellAccConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellAccConverter) IsUseEnumId() bool
- func (cellCvt *CellAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- func (cellCvt *CellAccConverter) ToCell() (func(row []string) (interface{}, error), error)
- func (cellCvt *CellAccConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellAccConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellAccLocaleConverter
- type CellAllAcc
- type CellAllAccConverter
- func (cellCvt *CellAllAccConverter) CsvFileName() (string, error)
- func (cellCvt *CellAllAccConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellAllAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellAllAccConverter) IsUseEnumId() bool
- func (cellCvt *CellAllAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- func (cellCvt *CellAllAccConverter) ToCell() (func(row []string) (interface{}, error), error)
- func (cellCvt *CellAllAccConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellAllAccConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellAllAccLocaleConverter
- type CellCodeAcc
- type CellCodeAllAcc
- type CellCodeExpr
- type CellCodeMicro
- type CellCodeMicroCalc
- type CellCodeParam
- type CellCodeTableCalc
- type CellEntityConverter
- type CellExpr
- type CellExprConverter
- func (cellCvt *CellExprConverter) CsvFileName() (string, error)
- func (cellCvt *CellExprConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellExprConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellExprConverter) IsUseEnumId() bool
- func (cellCvt *CellExprConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- func (cellCvt *CellExprConverter) ToCell() (func(row []string) (interface{}, error), error)
- func (cellCvt *CellExprConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellExprConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellExprLocaleConverter
- type CellIntKeys
- type CellMicro
- type CellMicroCalc
- type CellMicroCalcConverter
- func (cellCvt *CellMicroCalcConverter) CsvFileName() (string, error)
- func (cellCvt *CellMicroCalcConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellMicroCalcConverter) IdToCodeCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellMicroCalcConverter) IsUseEnumId() bool
- func (cellCvt *CellMicroCalcConverter) SetCalcIdNameMap(calcLt []CalculateLayout) error
- func (cellCvt *CellMicroCalcConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellMicroCalcConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellMicroConverter
- func (cellCvt *CellMicroConverter) CodeToIdCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellMicroConverter) CsvFileName() (string, error)
- func (cellCvt *CellMicroConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellMicroConverter) IdToCodeCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellMicroConverter) IsUseEnumId() bool
- func (cellCvt *CellMicroConverter) ToCell() (func(row []string) (interface{}, error), error)
- func (cellCvt *CellMicroConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellMicroConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellMicroLocaleConverter
- type CellParam
- type CellParamConverter
- func (cellCvt *CellParamConverter) CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellParamConverter) CsvFileName() (string, error)
- func (cellCvt *CellParamConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellParamConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellParamConverter) IsUseEnumId() bool
- func (cellCvt *CellParamConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- func (cellCvt *CellParamConverter) ToCell() (func(row []string) (interface{}, error), error)
- func (cellCvt *CellParamConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellParamConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellParamLocaleConverter
- type CellTableCalc
- type CellTableCalcConverter
- func (cellCvt *CellTableCalcConverter) CsvFileName() (string, error)
- func (cellCvt *CellTableCalcConverter) CsvHeader() ([]string, error)
- func (cellCvt *CellTableCalcConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt *CellTableCalcConverter) IsUseEnumId() bool
- func (cellCvt *CellTableCalcConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- func (cellCvt *CellTableCalcConverter) SetCalcIdNameMap(calcLt []CalculateTableLayout) error
- func (cellCvt *CellTableCalcConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
- func (cellCvt *CellTableCalcConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
- type CellTableConverter
- type CellToCodeConverter
- type CellToIdConverter
- type CsvConverter
- type CsvIntKeysConverter
- type CsvLocaleConverter
- type CsvToCellConverter
- type DescrNote
- type EntityAttrRow
- type EntityAttrTxtRow
- type EntityDicRow
- type EntityGenMeta
- type EntityGroupLstRow
- type EntityGroupMeta
- type EntityGroupPcRow
- type EntityGroupTxtRow
- type EntityMeta
- type EntityRunPub
- type EntityTxtRow
- type Facet
- type FilterColumn
- type FilterIdColumn
- type FilterOp
- type GroupLstRow
- type GroupMeta
- type GroupPcRow
- type GroupTxtRow
- type LangLstRow
- type LangMeta
- type LangNote
- type ModelDicDescrNote
- type ModelDicRow
- type ModelMeta
- func (src *ModelMeta) Clone() (*ModelMeta, error)
- func (modelDef *ModelMeta) EntityByKey(entityId int) (int, bool)
- func (modelDef *ModelMeta) EntityByName(name string) (int, bool)
- func (modelDef *ModelMeta) EntityHidById(entityId int) int
- func (dst *ModelMeta) FromJson(srcJson []byte) (bool, error)
- func (modelDef *ModelMeta) OutTableByHid(tableHid int) (int, bool)
- func (modelDef *ModelMeta) OutTableByKey(tableId int) (int, bool)
- func (modelDef *ModelMeta) OutTableByName(name string) (int, bool)
- func (modelDef *ModelMeta) OutTableHidById(tableId int) int
- func (modelDef *ModelMeta) ParamByHid(paramHid int) (int, bool)
- func (modelDef *ModelMeta) ParamByKey(paramId int) (int, bool)
- func (modelDef *ModelMeta) ParamByName(name string) (int, bool)
- func (modelDef *ModelMeta) ParamHidById(paramId int) int
- func (modelDef *ModelMeta) TypeByKey(typeId int) (int, bool)
- func (modelDef *ModelMeta) TypeOfDouble() (int, bool)
- type ModelTxtMeta
- type ModelTxtRow
- type ModelWordMeta
- type OrderByColumn
- type ParamDicRow
- type ParamDimsRow
- type ParamDimsTxtRow
- type ParamImportRow
- type ParamMeta
- type ParamRunSetPub
- type ParamRunSetTxtPub
- type ParamTxtRow
- type ParamValuePub
- type ProfileMeta
- type ReadCalculteMicroLayout
- type ReadCalculteTableLayout
- type ReadCompareMicroLayout
- type ReadCompareTableLayout
- type ReadLayout
- type ReadMicroLayout
- type ReadPageLayout
- func CalculateMicrodata(dbConn *sql.DB, modelDef *ModelMeta, microLt *ReadCalculteMicroLayout, ...) (*list.List, *ReadPageLayout, error)
- func CalculateOutputTable(dbConn *sql.DB, modelDef *ModelMeta, tableLt *ReadCalculteTableLayout, ...) (*list.List, *ReadPageLayout, error)
- func ReadMicrodataCalculateTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadMicroLayout, ...) (*ReadPageLayout, error)
- func ReadMicrodataTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadMicroLayout, ...) (*ReadPageLayout, error)
- func ReadOutputTableCalculteTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, ...) (*ReadPageLayout, error)
- func ReadOutputTableTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, ...) (*ReadPageLayout, error)
- func ReadParameterTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadParamLayout, ...) (*ReadPageLayout, error)
- func SelectToList(dbConn *sql.DB, query string, layout ReadPageLayout, ...) (*list.List, *ReadPageLayout, error)
- type ReadParamLayout
- type ReadSubIdLayout
- type ReadTableLayout
- type RunEntityRow
- type RunMeta
- func (run *RunMeta) EntityGenByDigest(digest string) (int, bool)
- func (run *RunMeta) EntityGenByEntityId(entityId int) (int, bool)
- func (meta *RunMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*RunPub, error)
- func (meta *RunMeta) UpdateRun(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, doubleFmt string) (bool, error)
- func (meta *RunMeta) UpdateRunText(dbConn *sql.DB, modelDef *ModelMeta, runId int, langDef *LangMeta) error
- type RunParamTxtRow
- type RunProgress
- type RunPub
- type RunRow
- func GetFirstRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastCompletedRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastRunByName(dbConn *sql.DB, modelId int, name string) (*RunRow, error)
- func GetRun(dbConn *sql.DB, runId int) (*RunRow, error)
- func GetRunByDigest(dbConn *sql.DB, digest string) (*RunRow, error)
- func GetRunByDigestStampName(dbConn *sql.DB, modelId int, rdsn string) (*RunRow, error)
- func GetRunByName(dbConn *sql.DB, modelId int, name string) (*RunRow, error)
- func GetRunByStamp(dbConn *sql.DB, modelId int, stamp string) (*RunRow, error)
- func GetRunList(dbConn *sql.DB, modelId int) ([]RunRow, error)
- func GetRunListByDigestStampName(dbConn *sql.DB, modelId int, rdsn string) ([]RunRow, error)
- type RunTxtRow
- type TableAccRow
- type TableAccTxtRow
- type TableDicRow
- type TableDimsRow
- type TableDimsTxtRow
- type TableExprRow
- type TableExprTxtRow
- type TableMeta
- type TableRunPub
- type TableTxtRow
- type TaskDef
- type TaskDefPub
- type TaskMeta
- func (meta *TaskMeta) MergeTaskDef(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- func (meta *TaskMeta) ReplaceTaskDef(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- func (meta *TaskMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*TaskPub, error)
- func (meta *TaskMeta) UpdateTaskFull(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- type TaskPub
- type TaskRow
- type TaskRunRow
- func GetTaskFirstRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskLastCompletedRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskLastRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskRun(dbConn *sql.DB, taskRunId int) (*TaskRunRow, error)
- func GetTaskRunByName(dbConn *sql.DB, taskId int, name string) (*TaskRunRow, error)
- func GetTaskRunByStamp(dbConn *sql.DB, taskId int, stamp string) (*TaskRunRow, error)
- func GetTaskRunByStampOrName(dbConn *sql.DB, taskId int, trsn string) (*TaskRunRow, error)
- func GetTaskRunListByStampOrName(dbConn *sql.DB, taskId int, trsn string) ([]TaskRunRow, error)
- type TaskRunSetRow
- type TaskRunSetTxt
- type TaskTxtRow
- type TypeDicRow
- type TypeEnumRow
- type TypeEnumTxtRow
- type TypeMeta
- type TypeTxtRow
- type WorksetCreatePub
- type WorksetHdrPub
- type WorksetMeta
- func (meta *WorksetMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetPub, error)
- func (meta *WorksetMeta) UpdateWorkset(dbConn *sql.DB, modelDef *ModelMeta, isReplace bool, langDef *LangMeta) error
- func (meta *WorksetMeta) UpdateWorksetParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, isReplaceMeta bool, param *ParamRunSetPub, ...) (int, error)
- type WorksetParamTxtRow
- type WorksetPub
- type WorksetRow
- type WorksetTxtRow
- type WriteLayout
- type WriteMicroLayout
- type WriteParamLayout
- type WriteTableLayout
Constants ¶
const ( SQLiteDbDriver = "SQLite" // default db driver name SQLiteTimeout = 86400 // default SQLite busy timeout Sqlite3DbDriver = "sqlite3" // SQLite db driver name OdbcDbDriver = "odbc" // ODBC db driver name )
Database connection values
const ( InitRunStatus = "i" // i = initial status ProgressRunStatus = "p" // p = run in progress WaitRunStatus = "w" // w = wait: run in progress, under external supervision DoneRunStatus = "s" // s = completed successfully ExitRunStatus = "x" // x = exit and not completed ErrorRunStatus = "e" // e = error failure DeleteRunStatus = "d" // d = deleted model run )
Model run status (run_lst table) and modeling task run status (task_run_lst table):
if task status = w (wait) then model wait and NOT completed until other process set status to one of finals: s,x,e model check if any new sets inserted into task_set and run it as they arrive
const CALCULATED_ID_OFFSET = 12000 // calculated exprssion id offset, for example for Expr1 calculated expression id is 12001
const IsOdbcSupported = false
IsOdbcSupported indicate support of ODBC connections built-in
const MaxSchemaVersion = 105
MaxSchemaVersion is a maximum compatible db schema version
const MinSchemaVersion = 105
MinSchemaVersion is a minimal compatible db schema version
const TotalEnumCode = "all"
TotalEnumCode is predefined enum code for "total" enum
Variables ¶
This section is empty.
Functions ¶
func CheckOpenmppSchemaVersion ¶
CheckOpenmppSchemaVersion return error if it is not openM++ db or schema version incompatible
func CopyParameterFromRun ¶
func CopyParameterFromRun(dbConn *sql.DB, modelDef *ModelMeta, ws *WorksetRow, paramName string, isReplace bool, rs *RunRow) error
CopyParameterFromRun copy parameter metadata and parameter values into workset from model run.
If isReplace is true and parameter already exist in destination workset then error returned. If isReplace is false then delete existing metadata and new insert new from model run. Destination workset must be in read-write state. Source model run must be completed, run status one of: s=success, x=exit, e=error.
func CopyParameterFromWorkset ¶
func CopyParameterFromWorkset(dbConn *sql.DB, modelDef *ModelMeta, dstWs *WorksetRow, paramName string, isReplace bool, srcWs *WorksetRow) error
CopyParameterFromWorkset copy parameter metadata and parameter values from one workset to another.
If isReplace is true and parameter already exist in destination workset then error returned. If isReplace is false then delete existing metadata and new insert new from source workset. Destination workset must be in read-write state, source workset must be read-only.
func DeleteModel ¶
Delete existing model metadata and drop model data tables from database.
func DeleteProfile ¶
DeleteProfile delete rows from profile in profile_lst and profile_option tables.
func DeleteProfileOption ¶
DeleteProfileOption delete row from profile_option table.
func DeleteRun ¶
Delete model run: delete metadata, parameters run values and output tables run values from database.
func DeleteTask ¶
Delete modeling task and task run history from database. Only task itself is deleted, model runs and worksets are not affected.
func DeleteWorkset ¶
DeleteWorkset delete workset metadata and workset parameter values from database.
func DeleteWorksetAllParameters ¶ added in v1.6.3
DeleteWorksetAllParameters delete all parameters metadata and values from workset.
Workset must be read-write in order to delete all parameters. If workset does not exist then nothing deleted and no errors returned, it is empty operation.
func DeleteWorksetParameter ¶
DeleteWorksetParameter do delete parameter metadata and values from workset.
If parameter not exist in workset then nothing deleted. Workset must be read-write in order to delete parameter. It is return parameter Hid = 0 if nothing deleted.
func GetModelId ¶
GetModelId return model id if exists.
Model selected by name and/or digest, i.e.: ("modelOne", "abcd20120817160459148") if digest is empty then first model with min(model_id) is used
func GetModelRunOptions ¶
GetModelOptions return model run_option table rows as map of maps: map(run_id, map(key, value)).
func GetProfileList ¶
GetProfileList return profile names: profile_lst table rows.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
func GetRunListText ¶
GetRunListText return list of model runs with description and notes: run_lst and run_txt rows.
If langCode not empty then only specified language selected else all languages
func GetRunOptions ¶
GetRunOptions return run_option table rows as (key, value) map.
func GetTaskListText ¶
GetTaskListText return list of modeling tasks with description and notes: task_lst and task_txt rows.
If langCode not empty then only specified language selected else all languages
func GetTaskSetIds ¶
GetTaskSetIds return modeling task set id's by task id from task_set db table
func GetWorksetListText ¶
func GetWorksetListText(dbConn *sql.DB, modelId int, langCode string) ([]WorksetRow, []WorksetTxtRow, error)
GetWorksetListText return list of model worksets, description and notes: workset_lst and workset_txt rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetParam ¶ added in v1.6.3
GetWorksetParam return sub-values count and default sub-value id for workset parameter: SELECT sub_count, default_sub_id FROM workset_parameter
func GetWorksetParamList ¶
GetWorksetParamList return Hid, sub-values count and default sub-value id for all parameters included in that workset: SELECT parameter_hid, sub_count, default_sub_id FROM workset_parameter
func GetWorksetRunIds ¶
GetWorksetRunIds return ids of model run results (run_id) where input parameters are from specified working set.
Only successfully completed run ids returned, not failed, not "in progress". This method is "local" to database and if data transfered between databases it very likely return wrong results. This method is not recommended, use modeling task to establish relationship between input set and model run.
func IfEmptyMakeDefault ¶
return SQLite connection string and driver name based on model name:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
func IfEmptyMakeDefaultReadOnly ¶ added in v1.9.0
return read-only SQLite connection string and driver name based on model name:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
func IsRunCompleted ¶
IsRunCompleted return true if run status one of: s=success, x=exit, e=error
func IsUnsafeQuote ¶ added in v1.9.0
return true if character is can be interpreted as sql ' quote MSSQL silently replace following utf-16 chars with 'single' quote:
ʹ 697 Modifier Letter Prime ʼ 700 Modifier Letter Apostrophe ˈ 712 Modifier Letter Vertical Line ′ 8242 Prime ' 65287 Fullwidth Apostrophe
func MakeSqliteDefault ¶
return default SQLite connection string based on model.sqlite file path:
Database=model.sqlite; Timeout=86400; OpenMode=ReadWrite;
func MakeSqliteDefaultReadOnly ¶ added in v1.9.0
return default read-only SQLite connection string based on model.sqlite file path:
Database=model.sqlite; Timeout=86400; OpenMode=ReadOnly;
func NameOfRunStatus ¶ added in v1.10.0
NameOfRunStatus return short name by run run status code: s=success, x=exit, e=error
func OpenmppSchemaVersion ¶
OpenmppSchemaVersion return db schema: select id_value from id_lst where id_key = 'openmpp'
func RenameTask ¶ added in v1.6.3
RenameTask do rename task if new name is not empty "" string
func RenameWorkset ¶ added in v1.6.3
RenameWorkset do rename workset if new name is not empty "" string.
If isAnyReadonly parameter is true then do rename regarless of workset read-only status else return error if workset is not read-write.
func SelectFirst ¶
SelectFirst select first db row and pass it to cvt() for row.Scan()
func SelectRows ¶
SelectRows select db rows and pass each to cvt() for rows.Scan()
func SelectRowsTo ¶ added in v1.9.7
SelectRowsTo select db rows and pass each row to cvt(). cvt() return true to continue or false to stop rows processing.
func TrxSelectFirst ¶
TrxSelectFirst select first db row in transaction scope and pass it to cvt() for row.Scan()
func TrxSelectRows ¶
TrxSelectRows select db rows in transaction scope and pass each to cvt() for rows.Scan()
func TrxUpdateStatement ¶
TrxUpdateStatement execute sql statement in transaction scope until put() return true
func UpdateLanguage ¶
UpdateLanguage insert new or update existing language and words in lang_lst and lang_word tables. Language ids updated with actual id's from database
func UpdateModel ¶
UpdateModel insert new model metadata in database, return true if model inserted or false if already exist.
If model with same digest already exist then call simply return existing model metadata (no changes made in database). Parameters and output tables Hid's and db table names updated with actual database values If new model inserted then modelDef updated with actual id's (model id, parameter Hid...) If parameter (output table) not exist then create db tables for parameter values (output table values) If db table names is "" empty then make db table names for parameter values (output table values)
func UpdateModelText ¶
func UpdateModelText(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, modelTxt *ModelTxtMeta) error
delete existing and insert new model text (description and notes) in database.
Model id, type Hid, parameter Hid, table Hid, language id updated with actual database id's
func UpdateModelWord ¶
func UpdateModelWord(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, mwDef *ModelWordMeta) error
UpdateModelWord insert new or update existing model language-specific strings in model_word table.
func UpdateProfile ¶
func UpdateProfile(dbConn *sql.DB, profile *ProfileMeta) error
UpdateProfile insert new or replace existing profile in profile_lst and profile_option tables.
It always replacing all existing rows by delete from profile_lst and profile_option where profile_name = profile.Name and insert new rows into profile_lst and profile_option tables.
func UpdateProfileOption ¶
UpdateProfileOption insert new or replace existing profile option in profile_option table. It is also will insert profile name into profile_lst table if such name does not already exist.
func UpdateRunParameterText ¶ added in v1.9.3
func UpdateRunParameterText(dbConn *sql.DB, modelDef *ModelMeta, runId int, paramTxtPub []ParamRunSetTxtPub, langDef *LangMeta) error
UpdateRunParameterText merge (insert or update) run parameter value notes into run_parameter_txt table.
New parameter notes merged with existing db rows by update or insert if rows not exist db tables. If run does not exist then function does nothing. Run status must be completed (success, exit or error) otherwise error returned. If input array of ParamRunSetTxtPub is empty then it is empty operation and return is success.
func UpdateRunStatus ¶ added in v1.10.0
UpdateRunStatus updates run status to the one of run completed: s=success, x=exit, e=error.
func UpdateRunValueDigest ¶
UpdateRunValueDigest does recalculate and update run_lst table with new run value digest and return it. If run not exist or status is not success or exit then digest is "" empty (not updated).
func UpdateWorksetParameterText ¶ added in v1.9.3
func UpdateWorksetParameterText(dbConn *sql.DB, modelDef *ModelMeta, setName string, paramTxtPub []ParamRunSetTxtPub, langDef *LangMeta) error
UpdateWorksetParameterText merge parameter value notes into workset_parameter_txt table.
Set name is used to find workset and set id updated with actual database value. Workset must exist and must be read-write for replace or merge.
Parameter must exist exist in the model otherwise it is an error. If parameter not exist in workset then function does nothing (it is empty operation). If input array of ParamRunSetTxtPub is empty then it is empty operation and return is success.
func UpdateWorksetReadonly ¶
UpdateWorksetReadonly update workset readonly status.
func UpdateWorksetReadonlyByName ¶
UpdateWorksetReadonlyByName update workset readonly status by workset name.
func WriteMicrodataFrom ¶ added in v1.13.0
func WriteMicrodataFrom( dbConn *sql.DB, dbFacet Facet, modelDef *ModelMeta, runMeta *RunMeta, layout *WriteMicroLayout, from func() (interface{}, error), ) error
WriteMicrodataFrom insert microdata values into model run until from() return not nil CellMicro value.
Model run should not already contain microdata values: microdata can be inserted only once in model run and cannot be updated after. Entity generation digest is used to find existing entity generation, it cannot be empty "" string otherwise error returned. Entity generation metadata updated with actual database values of generation Hid
Double format is used for float model types digest calculation, if non-empty format supplied.
Return run entity metadata rows.
func WriteOutputTableFrom ¶ added in v1.9.7
func WriteOutputTableFrom( dbConn *sql.DB, modelDef *ModelMeta, layout *WriteTableLayout, accFrom func() (interface{}, error), exprFrom func() (interface{}, error), ) error
WriteOutputTableFrom insert output table values (accumulators or expressions) into model run from accFrom() and exprFrom() readers.
Model run must exist and be in completed state (i.e. success or error state). Model run should not already contain output table values: it can be inserted only once in model run and cannot be updated after. Accumulators and expressions values must come in the order of primary key otherwise digest calculated incorrectly. Double format is used for float model types digest calculation, if non-empty format supplied.
func WriteParameterFrom ¶ added in v1.9.7
func WriteParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteParamLayout, from func() (interface{}, error)) error
WriteParameterFrom insert or update parameter values in workset or insert parameter values into model run until from() return not nil CellParam value.
If this is model run update (layout.IsToRun is true) then model run must exist and be in completed state (i.e. success or error state). Model run should not already contain parameter values: parameter can be inserted only once in model run and cannot be updated after.
If workset already contain parameter values then values updated else inserted. If only "page" of workset parameter rows supplied (layout.IsPage is true) then each row deleted by primary key before insert else all rows deleted by one delete by set id.
Double format is used for float model types digest calculation, if non-empty format supplied.
Types ¶
type CalcMaps ¶ added in v1.16.0
type CalcMaps struct { IdToDigest map[int]string // map of run id's to run digests DigestToId map[string]int // map of run digests to run id's CalcIdToName map[int]string // map of calculation id to name CalcNameToId map[string]int // map of calculation name to id }
calculation maps between runs digest and id and calculations name and id
func EmptyCalcMaps ¶ added in v1.16.0
func EmptyCalcMaps() CalcMaps
return empty value of calculation maps
type CalculateLayout ¶ added in v1.15.4
type CalculateLayout struct { Calculate string // expression to calculate, ex.: Expr0[base] - Expr0[variant] CalcId int // calculated expression id, calc_id column in csv, ex.: 0, 12001, 24001 Name string // calculated expression name, calc_name column in csv, ex.: Expr0, AVG_Expr0, RATIO_Expro0 }
CalculateLayout describes calculation expression for parameters, output table values or microdata entity. It can be comparison calculation for multiple model runs, ex.: Expr0[base] - Expr0[variant].
type CalculateMicroLayout ¶ added in v1.16.0
type CalculateMicroLayout struct { Calculation []CalculateLayout // aggregation measures, ex.: OM_MIN(Salary), OM_AVG(Income[base] - Income[variant]) GroupBy []string // attributes to group by }
CalculateMicroLayout describes aggregations of microdata.
It can be comparison aggregations and/or calculation aggregations. Comparison aggregation must contain [base] and [variant] attribute(s), ex.: OM_AVG(Income[base] - Income[variant]). Calculation aggregation is attribute(s) aggregation expression, ex.: OM_MAX(Income) / OM_MIN(Salary).
type CalculateTableLayout ¶ added in v1.15.4
type CalculateTableLayout struct { CalculateLayout // expression to calculate and layout IsAggr bool // if true then select output table accumulator else expression }
CalculateLayout describes calculation of output table values. It can be comparison calculation for multiple model runs, ex.: Expr0[base] - Expr0[variant].
type CellAcc ¶
type CellAcc struct { AccId int // output table accumulator id SubId int // output table subvalue id // contains filtered or unexported fields }
CellAcc is value of output table accumulator.
type CellAccConverter ¶ added in v1.9.2
type CellAccConverter struct {
CellTableConverter // model metadata and output table name
}
CellAccConverter is a converter for output table accumulator to implement CsvConverter interface.
func (*CellAccConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt *CellAccConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store output table accumulator rows
func (*CellAccConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt *CellAccConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: acc_name,sub_id,dim0,dim1,acc_value or if IsIdCsv is true then: acc_id,sub_id,dim0,dim1,acc_value
func (*CellAccConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt *CellAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (acc_id, sub_id, dimensions, value) to cell of codes: (acc_id, sub_id, dimensions as enum code, value)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (*CellAccConverter) IsUseEnumId ¶ added in v1.13.0
func (cellCvt *CellAccConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellAccConverter) KeyIds ¶ added in v1.9.7
func (cellCvt *CellAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (acc_id, sub_id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
func (*CellAccConverter) ToCell ¶ added in v1.17.3
func (cellCvt *CellAccConverter) ToCell() (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table accumulator cell (dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (*CellAccConverter) ToCsvIdRow ¶ added in v1.13.0
func (cellCvt *CellAccConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from output table cell (acc_id, sub_id, dimensions, value) to csv id's row []string.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter simply does Sprint() for each dimension item id, accumulator id, subvalue number and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellAccConverter) ToCsvRow ¶ added in v1.13.0
func (cellCvt *CellAccConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from output table cell (acc_id, sub_id, dimensions, value) to csv row []string (acc_name, sub_id, dimensions, value).
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code.
type CellAccLocaleConverter ¶ added in v1.17.6
type CellAccLocaleConverter struct { CellAccConverter Lang string // language code, expected to compatible with BCP 47 language tag LangDef *LangMeta // language metadata to find translations DimsTxt []TableDimsTxtRow // output table dimension text rows: table_dims_txt join to model_table_dic EnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic AccTxt []TableAccTxtRow // output table accumulator text rows: table_acc_txt join to model_table_dic }
Converter for output table accumulators to implement CsvLocaleConverter interface.
func (*CellAccLocaleConverter) CsvHeader ¶ added in v1.17.6
func (cellCvt *CellAccLocaleConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: acc_name,sub_id,Age,Sex,acc_value
func (*CellAccLocaleConverter) ToCsvRow ¶ added in v1.17.6
func (cellCvt *CellAccLocaleConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
Return converter from output table cell (acc_id, sub_id, dimensions, value) to language-specific csv []string row of accumulator description, sub_id, dimension enum labels and value.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum label. Value and dimesions of built-in types converted to locale-specific strings, e.g.: 1234.56 => 1 234,56
type CellAllAcc ¶
type CellAllAcc struct { DimIds []int // dimensions item as enum ids or int values if dimension type simple SubId int // output table subvalue id IsNull []bool // if true then value is NULL Value []float64 // accumulator value(s) }
CellAllAcc is value of multiple output table accumulators.
type CellAllAccConverter ¶ added in v1.9.2
type CellAllAccConverter struct { CellTableConverter // model metadata and output table name ValueName string // If ValueName is "" empty then all accumulators use for csv else one }
CellAllAccConverter is a converter for multiple output table accumulators to implement CsvConverter interface.
func (*CellAllAccConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt *CellAllAccConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store all accumulators rows
func (*CellAllAccConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt *CellAllAccConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names, for example: sub_id,dim0,dim1,acc0,acc1 If ValueName is "" empty then use all accumulators for csv else only one where accumulator name is ValueName
func (*CellAllAccConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt *CellAllAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (sub_id, dimensions, acc0, acc1, acc2) to cell of codes: (sub_id, dimensions as enum code, acc0, acc1, acc2)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (*CellAllAccConverter) IsUseEnumId ¶ added in v1.13.0
func (cellCvt *CellAllAccConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellAllAccConverter) KeyIds ¶ added in v1.9.7
func (cellCvt *CellAllAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (sub id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
func (*CellAllAccConverter) ToCell ¶ added in v1.17.3
func (cellCvt *CellAllAccConverter) ToCell() (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table accumulator cell (dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (*CellAllAccConverter) ToCsvIdRow ¶ added in v1.13.0
func (cellCvt *CellAllAccConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from output table cell (sub_id, dimensions, acc0, acc1, acc2) to csv id's row []string.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all values are empty or zero. Converter simply does Sprint() for each dimension item id, subvalue number and value(s). Converter will return error if len(row) not equal to number of fields in csv record. If ValueName is "" empty then all accumulators converted else one
func (*CellAllAccConverter) ToCsvRow ¶ added in v1.13.0
func (cellCvt *CellAllAccConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from output table cell (sub_id, dimensions, acc0, acc1, acc2) to csv row []string (sub_id, dimensions, acc0 value, acc1 value,....).
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all values are empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code. If ValueName is "" empty then all accumulators converted else one
type CellAllAccLocaleConverter ¶ added in v1.17.6
type CellAllAccLocaleConverter struct { CellAllAccConverter Lang string // language code, expected to compatible with BCP 47 language tag LangDef *LangMeta // language metadata to find translations DimsTxt []TableDimsTxtRow // output table dimension text rows: table_dims_txt join to model_table_dic EnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic AccTxt []TableAccTxtRow // output table accumulator text rows: table_acc_txt join to model_table_dic }
Converter for output table accumulators to implement CsvLocaleConverter interface.
func (*CellAllAccLocaleConverter) CsvHeader ¶ added in v1.17.6
func (cellCvt *CellAllAccLocaleConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names, for example: sub_id,Age,Sex,AVG Income,SE Income For example: acc_name,sub_id,Age,Sex,acc_value
func (*CellAllAccLocaleConverter) ToCsvRow ¶ added in v1.17.6
func (cellCvt *CellAllAccLocaleConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from output table cell (sub_id, dimensions, acc0, acc1, acc2) to language-specific csv []string row of (sub_id, dimension enum labels, acc0 value, acc1 value,....).
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all values are empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum label. If ValueName is "" empty then all accumulators converted else one Values and dimesions of built-in types converted to locale-specific strings, e.g.: 1234.56 => 1 234,56
type CellCodeAcc ¶
type CellCodeAcc struct { AccId int // output table accumulator id SubId int // output table subvalue id // contains filtered or unexported fields }
CellCodeAcc is value of output table accumulator. Dimension(s) items are enum codes, not enum ids.
type CellCodeAllAcc ¶
type CellCodeAllAcc struct { Dims []string // dimensions as enum codes or string of item if dimension type simple then SubId int // output table subvalue id IsNull []bool // if true then value is NULL Value []float64 // accumulator value(s) }
CellCodeAllAcc is value of multiple output table accumulators. Dimension(s) items are enum codes, not enum ids.
type CellCodeExpr ¶
type CellCodeExpr struct { ExprId int // output table expression id // contains filtered or unexported fields }
CellCodeExpr is value of output table expression. Dimension(s) items are enum codes, not enum ids.
type CellCodeMicro ¶ added in v1.13.0
type CellCodeMicro struct { Key uint64 // microdata key, part of row primary key: entity_key Attr []attrValue // attributes value: built-in type value or enum code }
CellCodeMicro is a row of entity microdata: entity_key and attribute values, if attribute type is enum based value is enum code
type CellCodeMicroCalc ¶ added in v1.16.0
type CellCodeMicroCalc struct { Attr []attrValue // group by attributes and calculated value attribute, using enum codes for enum based attributes CalcName string // aggregation name RunDigest string // model run digest }
CellCodeMicroCalc is value of entity microdata calculated expression. if attribute type is enum based value is enum code
type CellCodeParam ¶
type CellCodeParam struct { SubId int // parameter subvalue id // contains filtered or unexported fields }
CellCodeParam is value of input parameter. Dimension(s) items are enum codes, not enum ids.
type CellCodeTableCalc ¶ added in v1.15.4
type CellCodeTableCalc struct { CalcName string // calculated expression name RunDigest string // model run digest // contains filtered or unexported fields }
CellCodeTableCalc is value of output table calculated expression. Dimension(s) items are enum codes, not enum ids.
type CellEntityConverter ¶ added in v1.16.0
type CellEntityConverter struct { ModelDef *ModelMeta // model metadata Name string // model entity name EntityGen *EntityGenMeta // model run entity generation IsIdCsv bool // if true then use enum id's else use enum codes DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double IsNoZeroCsv bool // if true then do not write zero values into csv output IsNoNullCsv bool // if true then do not write NULL values into csv output // contains filtered or unexported fields }
CellMicroConverter is a parent for for entity microdata converters.
type CellExpr ¶
type CellExpr struct { ExprId int // output table expression id // contains filtered or unexported fields }
CellExpr is value of output table expression.
type CellExprConverter ¶ added in v1.9.2
type CellExprConverter struct {
CellTableConverter // model metadata and output table name
}
CellExprConverter is a converter for output table expression to implement CsvConverter interface.
func (*CellExprConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt *CellExprConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store output table expression rows
func (*CellExprConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt *CellExprConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: expr_name,dim0,dim1,expr_value or if IsIdCsv is true: expr_id,dim0,dim1,expr_value
func (*CellExprConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt *CellExprConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (expr_id, dimensions enum ids, value) to cell of codes: (expr_id, dimensions as enum codes, value).
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (*CellExprConverter) IsUseEnumId ¶ added in v1.13.0
func (cellCvt *CellExprConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellExprConverter) KeyIds ¶ added in v1.9.7
func (cellCvt *CellExprConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (expr_id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
func (*CellExprConverter) ToCell ¶ added in v1.17.3
func (cellCvt *CellExprConverter) ToCell() (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table expression cell (dimensions and value).
Converter return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (*CellExprConverter) ToCsvIdRow ¶ added in v1.13.0
func (cellCvt *CellExprConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from output table cell (expr_id, dimensions, value) to csv id's row []string.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter simply does Sprint() for each dimension item id, expression id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellExprConverter) ToCsvRow ¶ added in v1.13.0
func (cellCvt *CellExprConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from output table cell (expr_id, dimensions, value) to csv row []string (expr_name, dimensions, value).
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code.
type CellExprLocaleConverter ¶ added in v1.17.4
type CellExprLocaleConverter struct { CellExprConverter Lang string // language code, expected to compatible with BCP 47 language tag LangDef *LangMeta // language metadata to find translations DimsTxt []TableDimsTxtRow // output table dimension text rows: table_dims_txt join to model_table_dic EnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic ExprTxt []TableExprTxtRow // output table expression text rows: table_expr_txt join to model_table_dic }
Converter for output table expression to implement CsvLocaleConverter interface.
func (*CellExprLocaleConverter) CsvHeader ¶ added in v1.17.6
func (cellCvt *CellExprLocaleConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: expr_name,Age,Sex,expr_value
func (*CellExprLocaleConverter) ToCsvRow ¶ added in v1.17.4
func (cellCvt *CellExprLocaleConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
Return converter from output table cell (expr_id, dimensions, value) to language-specific csv []string row of dimension enum labels and value.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and cell value is empty or zero. Converter return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum label. Value and dimesions of built-in types converted to locale-specific strings, e.g.: 1234.56 => 1 234,56
type CellIntKeys ¶ added in v1.13.0
type CellIntKeys interface { // KeyIds return converter to copy row primary key into key []int. // Row primary keys are: // parameter: (sub_id, dimension ids) // accumulators: (acc_id, sub_id, dimension ids) // all accumulators: (sub_id, dimension ids) // expressions: (expr_id, dimension ids) KeyIds(name string) (func(interface{}, []int) error, error) }
CellIntKeys provide method to get a copy of cell keys as []int for parameter or output table row, for example, return [parameter row sub id and dimension ids].
type CellMicro ¶ added in v1.13.0
type CellMicro struct { Key uint64 // microdata key, part of row primary key: entity_key Attr []attrValue // attributes value: built-in type value or enum id }
CellMicro is a row of entity microdata: entity_key and attribute values, if attribute type is enum based value is enum id
type CellMicroCalc ¶ added in v1.16.0
type CellMicroCalc struct { Attr []attrValue // group by attributes and calculated value attribute, using enum id's for enum based attributes CalcId int // aggregation id RunId int // model run id }
CellMicroCalc is value of entity microdata calculated expression. if attribute type is enum based value is enum id
type CellMicroCalcConverter ¶ added in v1.16.0
type CellMicroCalcConverter struct { CellEntityConverter // model metadata, entity generation and and attributes CalcMaps // map between runs digest and id and calculations name and id GroupBy []string // attributes to group by // contains filtered or unexported fields }
CellMicroCalcConverter is a converter for calculated microdata row to implement CsvConverter interface.
func (*CellMicroCalcConverter) CsvFileName ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store calculated microdata rows
func (*CellMicroCalcConverter) CsvHeader ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file column names: names of group by attributes. For example: run_digest,calc_name,AgeGroup,Income,calc_value Or: run_id,calc_id,AgeGroup,Income,calc_value
func (*CellMicroCalcConverter) IdToCodeCell ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) IdToCodeCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from calculated microdata cell of ids: (run id, calc_id, group by attributes as built-in values or enum id's, calculated value attribute) into cell of codes: (run_digest, CalcName, group by attributes as enum codes or built-in values, calc_value).
If attribute type is enum based then attribute enum id converted to enum code. If attribute type is built-in (bool, int, float) then return attribute value as is, no conversion.
func (*CellMicroCalcConverter) IsUseEnumId ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellMicroCalcConverter) SetCalcIdNameMap ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) SetCalcIdNameMap(calcLt []CalculateLayout) error
Set calculation name to Id and Id to name maps
func (*CellMicroCalcConverter) ToCsvIdRow ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from microdata cell: (microdata key, attributes as enum id or built-in type value) to csv id's row []string.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter simply does Sprint() for key and each attribute value, if value is NULL then empty "" string used. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellMicroCalcConverter) ToCsvRow ¶ added in v1.16.0
func (cellCvt *CellMicroCalcConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from microdata cell: (microdata key, attributes as enum code or built-in type value) to csv row []string.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter simply does Sprint() for key and each attribute value, if value is NULL then empty "" string used. If attribute type is float and double format is not empty "" string then converter does Sprintf(using double format). If attribute type is enum based then converter return enum code for attribute enum id. Converter will return error if len(row) not equal to number of fields in csv record.
type CellMicroConverter ¶ added in v1.13.0
type CellMicroConverter struct {
CellEntityConverter // model metadata, entity generation and and attributes
}
CellMicroConverter is a converter for entity microdata row to implement CsvConverter interface.
func (*CellMicroConverter) CodeToIdCell ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) CodeToIdCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
CodeToIdCell return converter from parameter cell of codes: (entity key, attributes as built-in values or enum codes) to cell of ids: (entity key, attributes as built-in values or enum id's)
If attribute type is enum based then attribute enum codes converted to enum ids. If attribute type is built-in (bool, int, float) then attribute value converted from string to attribute type.
func (*CellMicroConverter) CsvFileName ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store entity microdata rows
func (*CellMicroConverter) CsvHeader ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: key,AgeGroup,Income.
func (*CellMicroConverter) IdToCodeCell ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) IdToCodeCell(modelDef *ModelMeta, _ string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from microdata cell of ids: (entity key, attributes as built-in values or enum id's) into cell of codes: (entity key, attributes as built-in values or enum codes)
If attribute type is enum based then attribute enum id converted to enum code. If attribute type is built-in (bool, int, float) then return attribute value as is, no conversion.
func (*CellMicroConverter) IsUseEnumId ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for attributes
func (*CellMicroConverter) ToCell ¶ added in v1.17.3
func (cellCvt *CellMicroConverter) ToCell() (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to microdata cell (key, attributes value).
If attribute type is enum based then csv row contains enum code and it is converted into cell attribute enum id. It does return error if len(row) not equal to number of fields in cell db-record. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellMicroConverter) ToCsvIdRow ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from microdata cell: (microdata key, attributes as enum id or built-in type value) to csv id's row []string.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all attributes values are empty or zero, only attributes of type float or integer or string are considered as "value" attributes. Converter simply does Sprint() for key and each attribute value, if value is NULL then empty "" string used. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellMicroConverter) ToCsvRow ¶ added in v1.13.0
func (cellCvt *CellMicroConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from microdata cell: (microdata key, attributes as enum id or built-in type value) to csv row []string.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all values of float or integer or string type are empty or zero. Converter simply does Sprint() for key and each attribute value, if value is NULL then empty "" string used. If attribute type is float and double format is not empty "" string then converter does Sprintf(using double format). If attribute type is enum based then converter return enum code for attribute enum id. Converter will return error if len(row) not equal to number of fields in csv record.
type CellMicroLocaleConverter ¶ added in v1.17.6
type CellMicroLocaleConverter struct { CellMicroConverter Lang string // language code, expected to compatible with BCP 47 language tag LangDef *LangMeta // language metadata to find translations EnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic AttrTxt []EntityAttrTxtRow // entity attributes text rows: entity_attr_txt join to model_entity_dic table // contains filtered or unexported fields }
Converter for entity microdata to implement CsvLocaleConverter interface.
func (*CellMicroLocaleConverter) CsvHeader ¶ added in v1.17.6
func (cellCvt *CellMicroLocaleConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: key,Age Group,Taxable Income.
func (*CellMicroLocaleConverter) ToCsvRow ¶ added in v1.17.6
func (cellCvt *CellMicroLocaleConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
Return converter from microdata cell: (microdata key, attributes as enum id or built-in type value) to language-specific csv []string row of dimension enum labels and value.
Converter return isNotEmpty flag, it return false if IsNoZero or IsNoNull is set and all values of float or integer or string type are empty or zero. Converter will return error if len(row) not equal to number of fields in csv record. Microdata row key and attribute values of built-in type converted to locale-specific strings, e.g.: 1234.56 => 1 234,56. If value is NULL then empty "" string used. If attribute type is enum based then csv vslur is enum label.
type CellParam ¶
type CellParam struct { SubId int // parameter subvalue id // contains filtered or unexported fields }
CellParam is value of input parameter.
type CellParamConverter ¶ added in v1.9.2
type CellParamConverter struct { ModelDef *ModelMeta // model metadata Name string // parameter name IsIdCsv bool // if true then use enum id's else use enum codes DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double // contains filtered or unexported fields }
CellParamConverter is a converter for input parameter to implement CsvConverter interface.
func (*CellParamConverter) CodeToIdCell ¶ added in v1.9.2
func (cellCvt *CellParamConverter) CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
CodeToIdCell return converter from parameter cell of codes: (sub id, dimensions as enum code, value) to cell of ids: (sub id, dimensions, value)
If dimension type is enum based then dimensions enum codes converted to enum ids. If dimension type is simple (bool or int) then dimension code converted from string to dimension type. If parameter type is enum based then cell value enum code converted to enum id.
func (*CellParamConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt *CellParamConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store parameter rows
func (*CellParamConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt *CellParamConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: sub_id,dim0,dim1,param_value.
func (*CellParamConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt *CellParamConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from parameter cell of ids: (sub id, dimensions, value) to cell of codes: (sub id, dimensions as enum code, value)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string. If parameter type is enum based then cell value enum id converted to enum code.
func (*CellParamConverter) IsUseEnumId ¶ added in v1.13.0
func (cellCvt *CellParamConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellParamConverter) KeyIds ¶ added in v1.9.7
func (cellCvt *CellParamConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (sub id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
func (*CellParamConverter) ToCell ¶ added in v1.17.3
func (cellCvt *CellParamConverter) ToCell() (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to parameter cell (sub id, dimensions, value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids). If parameter type is enum based then csv row value is enum code and it is converted into value enum id.
func (*CellParamConverter) ToCsvIdRow ¶ added in v1.13.0
func (cellCvt *CellParamConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
Return converter from parameter cell (sub id, dimensions, value) to csv id's row []string.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter simply does Sprint() for each sub-value id, dimension item id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellParamConverter) ToCsvRow ¶ added in v1.13.0
func (cellCvt *CellParamConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
Return converter from parameter cell (sub id, dimensions, value) to csv row []string.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter will return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code. If parameter type is enum based then csv row value is enum code.
type CellParamLocaleConverter ¶ added in v1.17.3
type CellParamLocaleConverter struct { CellParamConverter Lang string // language code, expected to compatible with BCP 47 language tag DimsTxt []ParamDimsTxtRow // parameter dimension text rows: parameter_dims_txt join to model_parameter_dic EnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic }
Converter for input parameter to implement CsvLocaleConverter interface.
func (*CellParamLocaleConverter) CsvHeader ¶ added in v1.17.6
func (cellCvt *CellParamLocaleConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names. For example: sub_id,Age,Sex,param_value.
func (*CellParamLocaleConverter) ToCsvRow ¶ added in v1.17.3
func (cellCvt *CellParamLocaleConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
Return converter from parameter cell (sub id, dimensions, value) to language-specific csv []string row of enum labels and value.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter will return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum label. If parameter type is enum based then csv row value is enum label. Value and dimesions of built-in types converted to locale-specific strings, e.g.: 1234.56 => 1 234,56
type CellTableCalc ¶ added in v1.15.4
type CellTableCalc struct { CalcId int // calculated expression id RunId int // model run id // contains filtered or unexported fields }
CellTableCalc is value of output table calculated expression.
type CellTableCalcConverter ¶ added in v1.15.4
type CellTableCalcConverter struct { CellTableConverter // model metadata and output table name CalcMaps // map between runs digest and id and calculations name and id }
CellTableCalcConverter is a converter for output table calculated cell to implement CsvConverter interface.
func (*CellTableCalcConverter) CsvFileName ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) CsvFileName() (string, error)
CsvFileName return file name of csv file to store output table calculated rows
func (*CellTableCalcConverter) CsvHeader ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) CsvHeader() ([]string, error)
CsvHeader return first line for csv file: column names, it's look like: run_digest,calc_id,dim0,dim1,calc_value
func (*CellTableCalcConverter) IdToCodeCell ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table calculated cell of ids: (run_id, calc_id, dimensions enum ids, calc_value) to cell of codes: (run_digest, CalcName, dimensions as enum codes, calc_value).
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (*CellTableCalcConverter) IsUseEnumId ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) IsUseEnumId() bool
return true if csv converter is using enum id's for dimensions
func (*CellTableCalcConverter) KeyIds ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (run_id, calc_id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
func (*CellTableCalcConverter) SetCalcIdNameMap ¶ added in v1.15.6
func (cellCvt *CellTableCalcConverter) SetCalcIdNameMap(calcLt []CalculateTableLayout) error
Set calculation name to Id and Id to name maps
func (*CellTableCalcConverter) ToCsvIdRow ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) ToCsvIdRow() (func(interface{}, []string) (bool, error), error)
ToCsvIdRow return converter from output table calculated cell (run_id, calc_id, dimensions, calc_value) to csv id's row []string.
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter simply does Sprint() for each dimension item id, run id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (*CellTableCalcConverter) ToCsvRow ¶ added in v1.15.4
func (cellCvt *CellTableCalcConverter) ToCsvRow() (func(interface{}, []string) (bool, error), error)
ToCsvRow return converter from output table calculated cell (run_id, calc_id, dimensions, calc_value) to csv row []string (run digest, calc_name, dimensions, calc_value).
Converter return isNotEmpty flag, it is always true if there were no error during conversion. Converter will return error if len(row) not equal to number of fields in csv record. Converter will return error if run_id not exist in the list of model runs (in run_lst table). Double format string is used if parameter type is float, double, long double. If dimension type is enum based then csv row is enum code.
type CellTableConverter ¶ added in v1.13.0
type CellTableConverter struct { ModelDef *ModelMeta // model metadata Name string // output table name IsIdCsv bool // if true then use enum id's else use enum codes DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double IsNoZeroCsv bool // if true then do not write zero values into csv output IsNoNullCsv bool // if true then do not write NULL values into csv output // contains filtered or unexported fields }
CellTableConverter is a parent for for output table converters.
type CellToCodeConverter ¶
type CellToCodeConverter interface { // IdToCodeCell return converter from id cell to code cell. // Cell is dimensions and value of parameter or output table. // It does convert from enum id to code for all dimensions and enum-based parameter value. IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error) }
CellToCodeConverter provide methods to convert parameters or output table row from enum id to enum code. If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string. If parameter type is enum based then cell value enum id converted to enum code.
type CellToIdConverter ¶
type CellToIdConverter interface { // CodeToIdCell return converter from code cell to id cell. // Cell is dimensions and value of parameter or output table. // It does convert from enum code to id for all dimensions and enum-based parameter value. CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error) }
CellToIdConverter provide methods to convert parameters or output table row from enum code to enum id. If dimension type is enum based then dimensions enum codes converted to enum ids. If dimension type is simple (bool or int) then dimension code converted from string to dimension type. If parameter type is enum based then cell value enum code converted to enum id.
type CsvConverter ¶
type CsvConverter interface { // return file name of csv file to store parameter or output table rows CsvFileName() (string, error) // return true if csv converter is using enum id's for dimensions or attributes IsUseEnumId() bool // return first line of csv file with column names: expr_name,dim0,dim1,expr_value. // if IsIdCsv is true: expr_id,dim0,dim1,expr_value // if isAllAcc is true: sub_id,dim0,dim1,acc0,acc1,acc2 CsvHeader() ([]string, error) // return converter from cell of parameter, output table or microdata to csv id's row []string. // converter simply sprint() dimension id's and value into []string buffer. // converter return isNotEmpty flag if cell value is not empty. ToCsvIdRow() (func(interface{}, []string) (bool, error), error) // return converter from cell of parameter, output table or microdata to csv row []string. // it does convert from enum id to code for all dimensions into []string buffer. // if this is a enum-based parameter value then it is also converted to enum code. // converter return isNotEmpty flag if cell value is not empty. ToCsvRow() (func(interface{}, []string) (bool, error), error) }
CsvConverter provide methods to convert parameter row, output table row or microdata row from or to row []string for csv file. Double format string is used for values or if value type is float, double, long double. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id. If parameter type is enum based then cell value is enum id and csv row value is enum code.
type CsvIntKeysConverter ¶ added in v1.13.0
type CsvIntKeysConverter interface { CsvConverter // convert parameter row or output table row to row []string for csv file CellIntKeys // provide a method to get row keys as []int, for example, get sub id and dimension ids }
CsvConverter provide methods to convert parameters or output table data to row []string for csv file.
type CsvLocaleConverter ¶ added in v1.17.4
type CsvLocaleConverter interface { // return converter from cell of parameter, output table or microdata to csv row []string. // If dimension type is enum based then csv row is enum label. // If parameter type is enum based then csv row value is enum label. // Value and dimesions of built-in types converted to locale-specific strings, e.g.: 1234.56 => 1 234,56 ToCsvRow() (func(interface{}, []string) (bool, error), error) // return first line of csv file with column names, for example: expr_name,Age,City,expr_value. CsvHeader() ([]string, error) }
Provide locale-specific methods to convert parameter row, output table row or microdata row to []string row for csv file. For example convert dimension enum id to enum label in specific language or use locale format for numeric values: 1234.56 => 1 234,56
type CsvToCellConverter ¶ added in v1.17.3
type CsvToCellConverter interface { // return converter from csv row []string to parameter, output table or microdata cell (dimensions and value or microdata key and attributes value) ToCell() (func(row []string) (interface{}, error), error) }
Convert from csv row []string to parameter, output table or microdata cell (dimensions and value or microdata key and attributes value).
type DescrNote ¶
type DescrNote struct { LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
DescrNote is a holder for language code, descripriton and notes
type EntityAttrRow ¶ added in v1.13.0
type EntityAttrRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL AttrId int // attr_id INT NOT NULL Name string // attr_name VARCHAR(255) NOT NULL TypeId int // model_type_id INT NOT NULL IsInternal bool // is_internal SMALLINT NOT NULL // contains filtered or unexported fields }
EntityAttrRow is db row of entity_attr join to model_entity_dic table
type EntityAttrTxtRow ¶ added in v1.13.0
type EntityAttrTxtRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL AttrId int // attr_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
EntityAttrTxtRow is db row of entity_attr_txt join to model_entity_dic table
type EntityDicRow ¶ added in v1.13.0
type EntityDicRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL EntityHid int // entity_hid INT NOT NULL, -- unique entity id Name string // entity_name VARCHAR(255) NOT NULL Digest string // entity_digest VARCHAR(32) NOT NULL }
EntityDicRow is db row of entity_dic join to model_entity_dic table.
EntityHid (entity_dic.entity_hid) is db-unique id of the entity, use digest to find same table in other db. EntityId (model_entity_dic.model_entity_id) is model-unique entity id, assigned by model compiler.
type EntityGenMeta ¶ added in v1.13.0
type EntityGenMeta struct { GenAttr []entityGenAttrRow // entity generation attributes: entity_gen_attr join to entity_gen // contains filtered or unexported fields }
EntityGenMeta is a holder of entity generation db rows from entity_gen, model_entity_dic, entity_gen_attr and run_entity tables Entity generation is a model entity with set of attributes included in particular model run(s). Model run typically include less attributes in microdata output than entity has in model metadata.
func GetEntityGenList ¶ added in v1.13.0
func GetEntityGenList(dbConn *sql.DB, runId int) ([]EntityGenMeta, error)
GetEntityGenList return entity generation rows by run id: entity_gen and entity_gen_attr table rows.
type EntityGroupLstRow ¶ added in v1.17.6
type EntityGroupLstRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL GroupId int // group_id INT NOT NULL Name string // group_name VARCHAR(255) NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL }
EntityGroupLstRow is db row of entity_group_lst table
type EntityGroupMeta ¶ added in v1.17.6
type EntityGroupMeta struct { EntityGroupLstRow // entity attribute group rows: entity_group_lst GroupPc []EntityGroupPcRow // group parent-child relationship rows: entity_group_pc }
EntityGroupMeta is db rows to describe parent-child group of entity attributes, it is join of entity_group_lst to entity_group_pc
type EntityGroupPcRow ¶ added in v1.17.6
type EntityGroupPcRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL GroupId int // group_id INT NOT NULL ChildPos int // child_pos INT NOT NULL ChildGroupId int // child_group_id INT, -- if not IS NULL then child group AttrId int // attr_id INT, -- if not IS NULL then entity attribute index }
EntityGroupPcRow is db row of entity_group_pc table
type EntityGroupTxtRow ¶ added in v1.17.6
type EntityGroupTxtRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL GroupId int // group_id INT NOT NULL DescrNote // language, description, notes }
EntityGroupTxtRow is db row of entity_group_txt table
type EntityMeta ¶ added in v1.13.0
type EntityMeta struct { EntityDicRow // model entity row: entity_dic join to model_entity_dic table Attr []EntityAttrRow // entity attribute rows: entity_attr join to model_entity_dic table }
EntityMeta is entity metadata: entity name, digest, attributes
func (*EntityMeta) AttrByKey ¶ added in v1.13.0
func (entity *EntityMeta) AttrByKey(attrId int) (int, bool)
AttrByKey return index of entity attribute by key: attrId
func (*EntityMeta) AttrByName ¶ added in v1.13.0
func (entity *EntityMeta) AttrByName(name string) (int, bool)
AttrByName return index of entity attribute by name
type EntityRunPub ¶ added in v1.13.0
type EntityRunPub struct { Name string // entity name GenDigest string // digest of entity generation, not empty only as result of select from run_entity; input from "public" digest is ignored ValueDigest string // value digest, not empty only as result of select from run_entity; input from "public" value digest is ignored RowCount int // if not zero then entity microdata row count Attr []string // names of entity generation attributes }
EntityRunPub is "public" metadata of entity run generation and attributes for json import-export
type EntityTxtRow ¶ added in v1.13.0
type EntityTxtRow struct { ModelId int // model_id INT NOT NULL EntityId int // model_entity_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
EntityTxtRow is db row of entity_dic_txt join to model_entity_dic table
type Facet ¶
type Facet uint8
Facet is type to define database provider and driver facets, ie: name of bigint type
func Open ¶
Open database connection.
Default driver name: "SQLite" and connection string is compatible with model connection, ie:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
Otherwise it is expected to be driver-specific connection string, ie:
DSN=ms2014; UID=sa; PWD=secret; file:m1.sqlite?mode=rw&_busy_timeout=86400000
If isFacetRequired is true then database facet determined
type FilterColumn ¶
type FilterColumn struct { Name string // dimension or attribute name Op FilterOp // filter operator: equal, IN, BETWEEN Values []string // enum code(s): one, two or many values depending on filter condition }
FilterColumn define dimension or attribute column and condition to filter enum codes to build select where
type FilterIdColumn ¶
type FilterIdColumn struct { Name string // dimension or attribute name Op FilterOp // filter operator: equal, IN, BETWEEN EnumIds []int // enum id(s): one, two or many ids depending on filter condition }
FilterIdColumn define dimension or attribute column and condition to filter enum ids to build select where
type FilterOp ¶
type FilterOp string
FilterOp is enum type for filter operators in select where conditions
const ( InAutoOpFilter FilterOp = "IN_AUTO" // auto convert IN list filter into equal or BETWEEN if possible InOpFilter FilterOp = "IN" // dimension enum ids in: dim2 IN (11, 22, 33) EqOpFilter FilterOp = "=" // dimension equal: dim1 = 12 NeOpFilter FilterOp = "!=" // dimension equal: dim1 <> 12 GtOpFilter FilterOp = ">" // value greater than: attr1 > 12 GeOpFilter FilterOp = ">=" // value greater or equal: attr1 >= 12 LtOpFilter FilterOp = "<" // value less than: attr1 < 12 LeOpFilter FilterOp = "<=" // value less or equal: attr1 <= 12 BetweenOpFilter FilterOp = "BETWEEN" // dimension enum ids between: dim3 BETWEEN 44 AND 88 )
Select filter operators for dimension enum values or attribute values.
type GroupLstRow ¶
type GroupLstRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL IsParam bool // is_parameter SMALLINT NOT NULL, -- if <> 0 then parameter group else output table group Name string // group_name VARCHAR(255) NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL }
GroupLstRow is db row of group_lst table
type GroupMeta ¶
type GroupMeta struct { GroupLstRow // parameters or output tables group rows: group_lst GroupPc []GroupPcRow // group parent-child relationship rows: group_pc }
GroupMeta is db rows to describe parent-child group of parameters or output tables, it is join of group_lst to group_pc
type GroupPcRow ¶
type GroupPcRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL ChildPos int // child_pos INT NOT NULL ChildGroupId int // child_group_id INT NULL, -- if not NULL then id of child group ChildLeafId int // leaf_id INT NULL, -- if not NULL then id of parameter or output table }
GroupPcRow is db row of group_pc table
type GroupTxtRow ¶
type GroupTxtRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL DescrNote // language, description, notes }
GroupTxtRow is db row of group_txt table
type LangLstRow ¶
type LangLstRow struct { LangCode string // lang_code VARCHAR(32) NOT NULL Name string // lang_name VARCHAR(255) NOT NULL // contains filtered or unexported fields }
LangLstRow is db row of lang_lst table.
langId is db-unique id of the language. LangCode is unique language code: EN, FR.
type LangMeta ¶
type LangMeta struct { Lang []langWord // language lang_lst row and lang_word rows in that language // contains filtered or unexported fields }
LangMeta is languages and words for each language
func GetLanguages ¶
GetLanguages return language rows from lang_lst join to lang_word tables and map from lang_code to lang_id.
func (*LangMeta) CodeById ¶
CodeIdId return language code by language id or first language if id not found
type LangNote ¶
type LangNote struct { LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000) }
LangNote is a holder for language code and notes
type ModelDicDescrNote ¶ added in v1.17.6
type ModelDicDescrNote struct { Model ModelDicRow // model_dic db row DescrNote DescrNote // from model_dic_txt }
ModelDicDescrNote is join of model_dic db row and model_dic_txt row
type ModelDicRow ¶
type ModelDicRow struct { ModelId int // model_id INT NOT NULL Name string // model_name VARCHAR(255) NOT NULL Digest string // model_digest VARCHAR(32) NOT NULL Type int // model_type INT NOT NULL Version string // model_ver VARCHAR(32) NOT NULL CreateDateTime string // create_dt VARCHAR(32) NOT NULL DefaultLangCode string // model default language code }
ModelDicRow is db row of model_dic table.
ModelId (model_dic.model_id) is db-unique id of the model, use digest to find same model in other db.
func GetModelList ¶
func GetModelList(dbConn *sql.DB) ([]ModelDicRow, error)
GetModelList return list of the models: model_dic table rows.
func GetModelRow ¶ added in v1.6.3
func GetModelRow(dbConn *sql.DB, modelId int) (*ModelDicRow, error)
GetModelRow return model_dic table row by model id.
type ModelMeta ¶
type ModelMeta struct { Model ModelDicRow // model_dic table row Type []TypeMeta // types metadata: type name and enums Param []ParamMeta // parameters metadata: parameter name, type, dimensions Table []TableMeta // output tables metadata: table name, dimensions, accumulators, expressions Entity []EntityMeta // model entities and attributes Group []GroupMeta // groups of parameters or output tables EntityGroup []EntityGroupMeta // entity groups of attributes }
ModelMeta is model metadata db rows, language-neutral portion of it.
Types, parameters and output tables can be shared between different models and even between different databases. Use digest hash to find same type (parameter, table or model) in other database. As it is today language-specific part of model metadata (labels, description, notes, etc.) does not considered for "equality" comparison and not included in digest.
For example, logical type consists of 2 enum (code, value) pairs: [(0, "false") (1, "true")] and even it has different labels in different databases, i.e. (1, "Truth") vs (1, "OK") such type(s) considered the same and should have identical digest(s).
Inside of database *_hid (type_hid, parameter_hid, table_hid) is a unique id of corresponding object (primary key). Those _hid's are database-unique and should be used to find same type (parameter, output table) in other database. Also each type, parameter, output table have model-unique *_id (type_id, parameter_id, table_id) assigned by compiler and it is possible to find type, parameter or table by combination of (model_id, type_id).
Unless otherwise specified each array is ordered by model-specific id's and binary search can be used. For example type array is ordered by (model_id, type_id) and type enum array by (model_id, type_id, enum_id).
func GetModel ¶
GetModel return model metadata: parameters and output tables definition.
Model selected by name and/or digest, i.e.: ("modelOne", "abcd201208171604590148") if digest is empty then first model with min(model_id) is used
func GetModelById ¶
GetModelById return model metadata: parameters and output tables definition.
Model selected by model id, which expected to be positive.
func (*ModelMeta) EntityByKey ¶ added in v1.13.0
EntityByKey return index of entity by key: entityId
func (*ModelMeta) EntityByName ¶ added in v1.13.0
EntityByName return index of entity by name
func (*ModelMeta) EntityHidById ¶ added in v1.13.0
EntityHidById return entity Hid by id or -1 if not found
func (*ModelMeta) OutTableByHid ¶
OutTableByHid return index of output table by table Hid
func (*ModelMeta) OutTableByKey ¶
OutTableByKey return index of output table by key: tableId
func (*ModelMeta) OutTableByName ¶
OutTableByName return index of output table by name
func (*ModelMeta) OutTableHidById ¶
OutTableHidById return output table Hid by id or -1 if not found
func (*ModelMeta) ParamByHid ¶
ParamByHid return index of parameter by parameter Hid
func (*ModelMeta) ParamByKey ¶
ParamByKey return index of parameter by key: paramId
func (*ModelMeta) ParamByName ¶
ParamByName return index of parameter by name
func (*ModelMeta) ParamHidById ¶
ParamHidById return parameter Hid by id or -1 if not found
func (*ModelMeta) TypeOfDouble ¶ added in v1.17.3
return double type index, it sia type of output value table and calculated value
type ModelTxtMeta ¶
type ModelTxtMeta struct { ModelName string // model name for text metadata ModelDigest string // model digest for text metadata ModelTxt []ModelTxtRow // model text rows: model_dic_txt TypeTxt []TypeTxtRow // model type text rows: type_dic_txt join to model_type_dic TypeEnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic ParamTxt []ParamTxtRow // model parameter text rows: parameter_dic_txt join to model_parameter_dic ParamDimsTxt []ParamDimsTxtRow // parameter dimension text rows: parameter_dims_txt join to model_parameter_dic TableTxt []TableTxtRow // model output table text rows: table_dic_txt join to model_table_dic TableDimsTxt []TableDimsTxtRow // output table dimension text rows: table_dims_txt join to model_table_dic TableAccTxt []TableAccTxtRow // output table accumulator text rows: table_acc_txt join to model_table_dic TableExprTxt []TableExprTxtRow // output table expression text rows: table_expr_txt join to model_table_dic EntityTxt []EntityTxtRow // model entities text rows: entity_dic_txt join to model_entity_dic table EntityAttrTxt []EntityAttrTxtRow // entity attributes: entity_attr_txt join to model_entity_dic table GroupTxt []GroupTxtRow // group text rows: group_txt EntityGroupTxt []EntityGroupTxtRow // entity group text rows: entity_group_txt }
ModelTxtMeta is language-specific portion of model metadata db rows.
func GetModelText ¶
GetModelText return model text metadata: description and notes. If langCode not empty then only specified language selected else all languages. If isPack is true then return empty text metadata for range types
func (*ModelTxtMeta) Clone ¶ added in v1.15.3
func (src *ModelTxtMeta) Clone() (*ModelTxtMeta, error)
Clone return deep copy of source model text metadata
type ModelTxtRow ¶
type ModelTxtRow struct { ModelId int // model_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ModelTxtRow is db row of model_dic_txt join to model_dic
func GetModelTextRowById ¶ added in v1.13.0
GetModelTextById return model_dic_txt table rows by model id.
If langCode not empty then only specified language selected else all languages.
type ModelWordMeta ¶
type ModelWordMeta struct { ModelName string // model name for text metadata ModelDigest string // model digest for text metadata ModelWord []modelLangWord // language and db rows of model_word in that language }
ModelWordMeta is language-specific model_word db rows.
func GetModelWord ¶
GetModelWord return model "words": language-specific stirngs. If langCode not empty then only specified language selected else all languages.
func (*ModelWordMeta) Clone ¶ added in v1.15.3
func (src *ModelWordMeta) Clone() (*ModelWordMeta, error)
Clone return deep copy of source model words
type OrderByColumn ¶
type OrderByColumn struct { IndexOne int // one-based column index IsDesc bool // if true then descending order }
OrderByColumn define column to order by rows selected from parameter or output table.
type ParamDicRow ¶
type ParamDicRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL, -- unique parameter id Name string // parameter_name VARCHAR(255) NOT NULL Digest string // parameter_digest VARCHAR(32) NOT NULL Rank int // parameter_rank INT NOT NULL TypeId int // model_type_id INT NOT NULL IsExtendable bool // is_extendable SMALLINT NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL NumCumulated int // num_cumulated INT NOT NULL DbRunTable string // db_run_table VARCHAR(64) NOT NULL DbSetTable string // db_set_table VARCHAR(64) NOT NULL ImportDigest string // import_digest VARCHAR(32) NOT NULL }
ParamDicRow is db row of parameter_dic join to model_parameter_dic table
ParamHid (parameter_dic.parameter_hid) is db-unique id of the parameter, use digest to find same parameter in other db. ParamId (model_parameter_dic.model_parameter_id) is model-unique parameter id, assigned by model compiler.
type ParamDimsRow ¶
type ParamDimsRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL DimId int // dim_id INT NOT NULL Name string // dim_name VARCHAR(255) NOT NULL TypeId int // model_type_id INT NOT NULL // contains filtered or unexported fields }
ParamDimsRow is db row of parameter_dims join to model_parameter_dic table
type ParamDimsTxtRow ¶
type ParamDimsTxtRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL DimId int // dim_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ParamDimsTxtRow is db row of parameter_dims_txt join to model_parameter_dic table
type ParamImportRow ¶
type ParamImportRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL FromName string // from_name VARCHAR(255) NOT NULL FromModel string // from_model_name VARCHAR(255) NOT NULL IsSampleDim bool // is_sample_dim SMALLINT NOT NULL }
ParamImportRow is db row of model_parameter_import table
type ParamMeta ¶
type ParamMeta struct { ParamDicRow // model parameter row: parameter_dic join to model_parameter_dic table Dim []ParamDimsRow // parameter dimension rows: parameter_dims join to model_parameter_dic table Import []ParamImportRow // parameter import from upstream model // contains filtered or unexported fields }
ParamMeta is parameter metadata: parameter name, type, dimensions
type ParamRunSetPub ¶
type ParamRunSetPub struct { ParamRunSetTxtPub SubCount int // number of parameter sub-values DefaultSubId int // default sub-value id for that parameter workset ValueDigest string // value digest, not empty only as result of select from run_parameter; input from "public" value digest is ignored }
ParamRunSetPub is "public" run or workset parameter value metadata for json import-export
type ParamRunSetTxtPub ¶ added in v1.9.3
type ParamRunSetTxtPub struct { Name string // parameter name Txt []LangNote // parameter value notes by language }
ParamRunSetTxtPub is "public" run or workset parameter metadata for json import-export: name, description and notes
type ParamTxtRow ¶
type ParamTxtRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ParamTxtRow is db row of parameter_dic_txt join to model_parameter_dic table
type ParamValuePub ¶
type ParamValuePub struct { ParamRunSetPub // parameter metadata Kind string // where to get parameter from: "value", "run", "set" or empty "" which is "value" by default From string // run digest (or name or stamp) or workset name to copy parameter from Value []CellCodeParam // parameter value(s) }
ParamValuePub is "public" run or workset parameter metadata and values for json import-export.
type ProfileMeta ¶
type ProfileMeta struct { Name string // profile name Opts map[string]string // profile (key, value) options }
ProfileMeta is rows from profile_option table.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
func GetProfile ¶
func GetProfile(dbConn *sql.DB, name string) (*ProfileMeta, error)
GetProfile return profile_option table rows as (key, value) map.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
type ReadCalculteMicroLayout ¶ added in v1.16.0
type ReadCalculteMicroLayout struct { ReadLayout // entity name, run id, page size, where filters and order by CalculateMicroLayout // microdata aggregations }
ReadCalculteMicroLayout describe microdata generation read layout, aggregation measures and group by attributes.
type ReadCalculteTableLayout ¶ added in v1.15.4
type ReadCalculteTableLayout struct { ReadLayout // output table name, run id, page size, where filters and order by Calculation []CalculateTableLayout // additional measures to calculate }
ReadCalculteTableLayout describe table read layout and additional measures to calculte.
type ReadCompareMicroLayout ¶ added in v1.16.0
type ReadCompareMicroLayout struct { ReadCalculteMicroLayout // aggregation measures and group by attributes Runs []string // runs to compare: list of digest, stamp or name }
ReadCompareMicroLayout to compare microdata runs with base run using multiple comparison aggregations and/or calculation aggregations.
Comparison aggregation must contain [base] and [variant] attribute(s), ex.: OM_AVG(Income[base] - Income[variant]). Calculation aggregation is attribute(s) aggregation expression, ex.: OM_MAX(Income) / OM_MIN(Salary).
type ReadCompareTableLayout ¶ added in v1.15.5
type ReadCompareTableLayout struct { ReadCalculteTableLayout // output table, base run and comparison expressions or calculations Runs []string // runs to compare: list of digest, stamp or name }
ReadCompareTableLayout to compare output table runs with base run using multiple comparison expressions and/or calculation measures.
Comparison expression(s) must contain [base] and [variant] expression(s), ex.: Expr0[base] - Expr0[variant]. Calculation measure(s) can include table exprissions, ex.: Expr0 + Expr1 or aggregation of table accumulators, ex.: OM_SUM(acc0) / OM_COUNT(acc0)
type ReadLayout ¶
type ReadLayout struct { Name string // parameter name, output table name or entity microdata name FromId int // run id or set id to select input parameter, output table values or microdata from ReadPageLayout // read page first row offset, size and last page flag Filter []FilterColumn // dimension or attribute or value filters, final WHERE does join all filters by AND FilterById []FilterIdColumn // dimension or attribute filters by enum ids, final WHERE does join filters by AND OrderBy []OrderByColumn // order by columnns, if empty then dimension id ascending order is used }
ReadLayout describes source and size of data page to read input parameter, output table values or microdata.
Row filters combined by AND and allow to select dimension or attribute items, it can be enum codes or enum id's, ex.: dim0 = 'CA' AND dim1 IN (2010, 2011, 2012)
Order by applied to output columns. Because dimension or attribute columns always contain enum id's, therefore result ordered by id's and not by enum codes. Columns list depending on output table or parameter query:
parameter values:
SELECT sub_id, dim0, dim1, param_value FROM parameterTable ORDER BY...
output table expressions:
SELECT expr_id, dim0, dim1, expr_value FROM outputTable ORDER BY...
output table accumulators:
SELECT acc_id, sub_id, dim0, dim1, acc_value FROM outputTable ORDER BY...
all-accumulators view:
SELECT sub_id, dim0, dim1, acc0_value, acc1_value... FROM outputTable ORDER BY...
entity microdata table:
SELECT entity_key, attr0, attr1,... FROM microdataTable ORDER BY...
type ReadMicroLayout ¶ added in v1.13.0
type ReadMicroLayout struct { ReadLayout // entity name, run id, page size, where filters and order by GenDigest string // entity generation digest }
ReadMicroLayout describes source and size of data page to read entity microdata.
Only one entity generation digest expected for each run id + entity name, but there is no such constarint in db schema.
type ReadPageLayout ¶
type ReadPageLayout struct { Offset int64 // first row to return from select, zero-based ofsset Size int64 // max row count to select, if <= 0 then all rows IsLastPage bool // output last page flag: return true if it was a last page of rows IsFullPage bool // input last page flag: if true then adjust offset to return full last page }
ReadPageLayout describes first row offset and size of data page to read input parameter or output table values.
func CalculateMicrodata ¶ added in v1.16.0
func CalculateMicrodata(dbConn *sql.DB, modelDef *ModelMeta, microLt *ReadCalculteMicroLayout, runIds []int) (*list.List, *ReadPageLayout, error)
CalculateMicrodata aggregates microdata using group by attributes as dimensions and calculate aggregated measure(s).
func CalculateOutputTable ¶ added in v1.15.4
func CalculateOutputTable(dbConn *sql.DB, modelDef *ModelMeta, tableLt *ReadCalculteTableLayout, runIds []int) (*list.List, *ReadPageLayout, error)
CalculateOutputTable read output table page (dimensions and values) and calculate extra measure(s).
If calcLt.IsAggr true then do accumulator(s) aggregation else calculate expression value(s), ex: Expr1[variant] - Expr1[base].
func ReadMicrodataCalculateTo ¶ added in v1.16.0
func ReadMicrodataCalculateTo( dbConn *sql.DB, modelDef *ModelMeta, layout *ReadMicroLayout, calcLt *CalculateMicroLayout, runIds []int, cvtTo func(src interface{}) (bool, error), ) (*ReadPageLayout, error)
ReadMicrodataCalculateTo read aggregated microdata rows (run_id, calc_id, group by attributes, calc_value) and process each row by cvtTo().
It can calculate multiple measure values using simple aggregation of attributes, ex.: OM_AVG(Income) or on aggregate for run comparison, ex.: OM_AVG(Income[variant] - Income[base]). Optional list of run id's can be supplied to read more than one run from microdata table.
func ReadMicrodataTo ¶ added in v1.13.0
func ReadMicrodataTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadMicroLayout, cvtTo func(src interface{}) (bool, error)) (*ReadPageLayout, error)
ReadMicrodataTo read entity microdata rows (microdata key, attributes) from model run results and process each row by cvtTo().
func ReadOutputTableCalculteTo ¶ added in v1.15.4
func ReadOutputTableCalculteTo( dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, calcLt []CalculateTableLayout, runIds []int, cvtTo func(src interface{}) (bool, error), ) (*ReadPageLayout, error)
ReadOutputTableCalculteTo read calculated output table page (run id, expression(s) id, dimensions and values) and process each row by cvtTo().
It can calculate multiple values based on expressions and/or accumulators aggregation. Optional runIds list of run id's can be supplied to read more than one run from output table.
func ReadOutputTableTo ¶ added in v1.9.7
func ReadOutputTableTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, cvtTo func(src interface{}) (bool, error)) (*ReadPageLayout, error)
ReadOutputTableTo read output table page (dimensions and values) from model run results and process each row by cvtTo().
If layout.IsAccum true then select accumulator(s) else output expression value(s) If layout.ValueName not empty then select only that expression (accumulator) else all expressions (accumulators)
func ReadParameterTo ¶ added in v1.9.7
func ReadParameterTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadParamLayout, cvtTo func(src interface{}) (bool, error)) (*ReadPageLayout, error)
ReadParameterTo read input parameter rows (sub id, dimensions, value) from workset or model run results and process each row by cvtTo().
func SelectToList ¶
func SelectToList( dbConn *sql.DB, query string, layout ReadPageLayout, cvt func(rows *sql.Rows) (interface{}, error)) (*list.List, *ReadPageLayout, error)
SelectToList select db rows into list using cvt to convert (scan) each db row into struct.
It selects "page size" number of rows starting from row number == offset (zero based). If page size <= 0 then all rows returned. If IsFullPage is true then adjust offset to return full last page
type ReadParamLayout ¶
type ReadParamLayout struct { ReadLayout // parameter name, run id or set id page size, where filters and order by IsFromSet bool // if true then select from workset else from model run IsEditSet bool // if true then workset must be editable (readonly = false) ReadSubIdLayout // sub-value id filter: select rows with only one sub-value id }
ReadParamLayout describes source and size of data page to read input parameter values.
It can read parameter values from model run results or from input working set (workset). If this is read from workset then it can be read-only or read-write (editable) workset.
type ReadSubIdLayout ¶ added in v1.15.3
type ReadSubIdLayout struct { IsSubId bool // if true then select only single sub-value id SubId int // sub-value id to select rows from output table or parameter }
ReadSubIdLayout supply sub-value id filter to select rows with only single sub_id from output table or input parameter values.
type ReadTableLayout ¶
type ReadTableLayout struct { ReadLayout // output table name, run id, page size, where filters and order by ValueName string // if not empty then expression or accumulator name to select IsAccum bool // if true then select output table accumulator else expression IsAllAccum bool // if true then select from all accumulators view else from accumulators table ReadSubIdLayout // sub-value id filter: select rows with only one sub-value id }
ReadTableLayout describes source and size of data page to read output table values.
If ValueName is not empty then only accumulator or output expression with that name selected (i.e: "acc1" or "expr4") else all output table accumulators (expressions) selected.
type RunEntityRow ¶ added in v1.14.0
type RunEntityRow struct { RunId int // run_id INT NOT NULL GenHid int // entity_gen_hid INT NOT NULL RowCount int // row_count INT NOT NULL, -- if not zero then entity microdata row count ValueDigest string // value_digest VARCHAR(32), -- if not NULL then digest of table value for the run }
RunEntityRow is db row of run_entity join to entity_gen table
func GetRunEntityGenByModel ¶ added in v1.16.0
func GetRunEntityGenByModel(dbConn *sql.DB, modelId int) ([]RunEntityRow, error)
GetRunEntityGenList return run entity rows by model id: run_entity table rows.
type RunMeta ¶
type RunMeta struct { Run RunRow // model run master row: run_lst Txt []RunTxtRow // run text rows: run_txt Opts map[string]string // options used to run the model: run_option Param []runParam // run parameters: parameter_hid, sub-value count, run_parameter_txt table rows Table []runTable // run tables: table_hid fom run_table rows EntityGen []EntityGenMeta // run entity generation: entity_gen, entity_gen_attr table rows RunEntity []RunEntityRow // run microdata entities: run_entity table rows Progress []RunProgress // run progress by sub-values: run_progress table rows }
RunMeta is metadata of model run: name, status, run options, description, notes.
func GetRunFull ¶
GetRunFull return full metadata for model run: run_lst, run_option, run_parameter, run_table, run_progress, and entity generation rows.
func GetRunFullText ¶
func GetRunFullText(dbConn *sql.DB, runRow *RunRow, isSuccess bool, langCode string) (*RunMeta, error)
GetRunFullText return full metadata, including text, for completed model run: run_lst, run_txt, run_option, run_parameter, run_parameter_txt, run_table, run_progress, and entity generation rows.
If isSuccess true then return only successfully completed runs else return all runs: success, error, exit, progress. If langCode not empty then only specified language selected else all languages
func GetRunFullTextList ¶
func GetRunFullTextList(dbConn *sql.DB, modelId int, isSuccess bool, langCode string) ([]RunMeta, error)
GetRunFullTextList return list of full metadata, including text, for model runs: run_lst, run_txt, run_option, run_parameter, run_parameter_txt, run_table, run_progress and entity generation rows.
If isSuccess true then return only successfully completed runs else return all runs: success, error, exit, progress. If langCode not empty then only specified language selected else all languages
func (*RunMeta) EntityGenByDigest ¶ added in v1.13.0
EntityGenByDigest return index of entity generation by generation digest
func (*RunMeta) EntityGenByEntityId ¶ added in v1.13.0
EntityGenByEntityId return index of entity generation by model entity id. As it is today model do not insert more than one generation for each entity into model run, but there is no such costraint in db schema.
func (*RunMeta) ToPublic ¶
ToPublic convert model run db rows into "public" model run format for json import-export.
func (*RunMeta) UpdateRun ¶
func (meta *RunMeta) UpdateRun(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, doubleFmt string) (bool, error)
UpdateRun insert new or return existing model run metadata in database.
Run status must be completed (success, exit or error) otherwise error returned. If this run already exist then nothing is updated in database, only metadata updated with actual run id. Run digest is used to find existing model run, it cannot be empty "" string otherwise error returned.
Double format is used for progress value float conversion, if non-empty format supplied.
It return "is found" flag and update metadata with actual run id in database.
func (*RunMeta) UpdateRunText ¶
func (meta *RunMeta) UpdateRunText(dbConn *sql.DB, modelDef *ModelMeta, runId int, langDef *LangMeta) error
UpdateRunText merge run text (run description and notes) and run parameter notes into run_txt and run_parameter_txt tables.
New run text merged with existing db rows by update or insert if rows not exist db tables. If run not exist then function does nothing. Run status must be completed (success, exit or error) otherwise error returned. Run id of the input run metadata updated with runId value.
type RunParamTxtRow ¶
type RunParamTxtRow struct { RunId int // run_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000) }
RunParamTxtRow is db row of run_parameter_txt
func GetRunAllParamText ¶
GetRunAllParamText return all run parameters value notes: run_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetRunParamText ¶
func GetRunParamText(dbConn *sql.DB, runId int, paramHid int, langCode string) ([]RunParamTxtRow, error)
GetRunParamText return run parameter value notes: run_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
type RunProgress ¶
type RunProgress struct { SubId int // sub_id INT NOT NULL, -- sub-value id (zero based index) CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time Count int // progress_count INT NOT NULL, -- progress count: percent completed Value float64 // progress_value FLOAT NOT NULL, -- progress value: number of cases (case based) or time (time based) }
RunProgress is a "public" sub-value run_progress db row
func GetRunProgress ¶
func GetRunProgress(dbConn *sql.DB, runId int) ([]RunProgress, error)
GetRunProgress return sub-values run progress for specified run id: run_progress table rows.
type RunPub ¶
type RunPub struct { ModelName string // model name for that run ModelDigest string // model digest for that run ModelVersion string // model_ver VARCHAR(32) NOT NULL ModelCreateDateTime string // create_dt VARCHAR(32) NOT NULL Name string // run_name VARCHAR(255) NOT NULL SubCount int // sub_count INT NOT NULL, -- subvalue count SubStarted int // sub_started INT NOT NULL, -- number of subvalues started SubCompleted int // sub_completed INT NOT NULL, -- number of subvalues completed CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunId int // used only as output value, input value ignored RunDigest string // run_digest VARCHAR(32) NULL, -- digest of the run metadata: model digest, run name, sub count, created date-time, run stamp ValueDigest string // value_digest VARCHAR(32), -- if not NULL then digest of the run values: all parameters and output tables RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp Txt []DescrNote // run text: description and notes by language Opts map[string]string // options used to run the model: run_option Param []ParamRunSetPub // run parameters: name, sub-value count and value notes by language Table []TableRunPub // run tables: name for tables included in run_table Entity []EntityRunPub // run entities: entity generation and attributes Progress []RunProgress // run progress by sub-values: run_progress table rows }
RunPub is "public" model run metadata for json import-export
type RunRow ¶
type RunRow struct { RunId int // run_id INT NOT NULL, -- unique run id ModelId int // model_id INT NOT NULL Name string // run_name VARCHAR(255) NOT NULL, -- model run name SubCount int // sub_count INT NOT NULL, -- subvalue count SubStarted int // sub_started INT NOT NULL, -- number of subvalues started SubCompleted int // sub_completed INT NOT NULL, -- number of subvalues completed CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunDigest string // run_digest VARCHAR(32) NULL, -- digest of the run metadata: model digest, run name, sub count, created date-time, run stamp ValueDigest string // value_digest VARCHAR(32), -- if not NULL then digest of the run values: all parameters and output tables RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp }
RunRow is model run row: run_lst table row.
Run status: i=init p=progress s=success x=exit e=error(failed). Run id must be different from working set id (use id_lst to get it)
func GetFirstRun ¶
GetFirstRun return first run of the model: run_lst table row.
func GetLastCompletedRun ¶
GetLastCompletedRun return last completed run of the model: run_lst table row.
Run completed if run status one of: s=success, x=exit, e=error
func GetLastRun ¶
GetLastRun return last run of the model: run_lst table row.
func GetLastRunByName ¶ added in v1.6.3
GetLastRunByName return model run row by run name: run_lst table row.
If there is multiple runs with this name then run with max(run_id) returned
func GetRunByDigest ¶
GetRunByDigest return model run row by digest: run_lst table row.
func GetRunByDigestStampName ¶ added in v1.16.0
GetRunByDigestStampName return model run row by run digest or run stamp or run name: run_lst table row.
It does select run row by digest, if not found then by model id and stamp, if not found by model id and run name. If there is multiple runs with this stamp or name then run with min(run_id) returned
func GetRunByName ¶
GetRunByName return model run row by run name: run_lst table row.
If there is multiple runs with this name then run with min(run_id) returned
func GetRunByStamp ¶
GetRunByStamp return model run row by run stamp: run_lst table row.
If there is multiple runs with this stamp then run with min(run_id) returned
func GetRunList ¶
GetRunList return list of model runs by model_id: run_lst rows.
func GetRunListByDigestStampName ¶ added in v1.16.0
GetRunListByDigestStampName return list of model run rows by run digest or run stamp or run name: run_lst table rows.
It does select run row by digest, if not found then by model id and stamp, if not found by model id and run name. If there is multiple runs with this stamp or name then multiple rows returned
type RunTxtRow ¶
type RunTxtRow struct { RunId int // run_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
RunTxtRow is db row of run_txt
type TableAccRow ¶
type TableAccRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL AccId int // acc_id INT NOT NULL Name string // acc_name VARCHAR(255) NOT NULL IsDerived bool // is_derived SMALLINT NOT NULL SrcAcc string // acc_src VARCHAR(255) NOT NULL AccSql string // acc_sql VARCHAR(2048) NOT NULL // contains filtered or unexported fields }
TableAccRow is db row of table_acc join to model_table_dic table
type TableAccTxtRow ¶
type TableAccTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL AccId int // acc_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableAccTxtRow is db row of table_acc_txt join to model_table_dic table
type TableDicRow ¶
type TableDicRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL TableHid int // table_hid INT NOT NULL, -- unique table id Name string // table_name VARCHAR(255) NOT NULL Digest string // table_digest VARCHAR(32) NOT NULL IsUser bool // is_user SMALLINT NOT NULL Rank int // table_rank INT NOT NULL IsSparse bool // is_sparse SMALLINT NOT NULL DbExprTable string // db_expr_table VARCHAR(64) NOT NULL DbAccTable string // db_acc_table VARCHAR(64) NOT NULL DbAccAllView string // db_acc_all_view VARCHAR(64) NOT NULL ExprPos int // expr_dim_pos INT NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL ImportDigest string // import_digest VARCHAR(32) NOT NULL }
TableDicRow is db row of table_dic join to model_table_dic table.
TableHid (table_dic.table_hid) is db-unique id of the output table, use digest to find same table in other db. TableId (model_table_dic.model_table_id) is model-unique output table id, assigned by model compiler.
type TableDimsRow ¶
type TableDimsRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL DimId int // dim_id INT NOT NULL Name string // dim_name VARCHAR(255) NOT NULL TypeId int // model_type_id INT NOT NULL IsTotal bool // is_total SMALLINT NOT NULL DimSize int // dim_size INT NOT NULL // contains filtered or unexported fields }
TableDimsRow is db row of table_dims join to model_table_dic table
type TableDimsTxtRow ¶
type TableDimsTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL DimId int // dim_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableDimsTxtRow is db row of table_dims_txt join to model_table_dic table
type TableExprRow ¶
type TableExprRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL ExprId int // expr_id INT NOT NULL Name string // expr_name VARCHAR(255) NOT NULL Decimals int // expr_decimals INT NOT NULL SrcExpr string // expr_src VARCHAR(255) NOT NULL ExprSql string // expr_sql VARCHAR(2048) NOT NULL // contains filtered or unexported fields }
TableExprRow is db row of table_expr join to model_table_dic table
type TableExprTxtRow ¶
type TableExprTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL ExprId int // expr_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableExprTxtRow is db row of table_expr_txt join to model_table_dic table
type TableMeta ¶
type TableMeta struct { TableDicRow // model output table row: table_dic join to model_table_dic Dim []TableDimsRow // output table dimension rows: table_dims join to model_table_dic Acc []TableAccRow // output table accumulator rows: table_acc join to model_table_dic Expr []TableExprRow // output table expression rows: table_expr join to model_table_dic // contains filtered or unexported fields }
TableMeta is output table metadata: table name, dimensions, accumulators, expressions
type TableRunPub ¶ added in v1.8.4
type TableRunPub struct { Name string // parameter name ValueDigest string // value digest, not empty only as result of select from table_parameter; input from "public" value digest is ignored }
TableRunPub is "public" metadata for output tables included in model run results
type TableTxtRow ¶
type TableTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) ExprDescr string // expr_descr VARCHAR(255) NOT NULL ExprNote string // expr_note VARCHAR(32000) }
TableTxtRow is db row of table_dic_txt join to model_table_dic table
type TaskDef ¶
type TaskDef struct { Task TaskRow // modeling task row: task_lst Txt []TaskTxtRow // task text rows: task_txt Set []int // task body (current list of workset id's): task_set }
TaskDef is modeling task definition: metadata and input worksets
type TaskDefPub ¶
type TaskDefPub struct { ModelName string // model name for that task list ModelDigest string // model digest for that task list ModelVersion string // model_ver VARCHAR(32) NOT NULL ModelCreateDateTime string // create_dt VARCHAR(32) NOT NULL Name string // task_name VARCHAR(255) NOT NULL Txt []DescrNote // task text: description and notes by language Set []string // task body: list of workset names }
TaskDefPub is "public" modeling task metadata and task input worksets for json import-export
type TaskMeta ¶
type TaskMeta struct { TaskDef // task definition: metadata and input worksets TaskRun []taskRunItem // task run history: task_run_lst and task_run_set rows }
TaskMeta is metadata for modeling task: name, status, description, notes, task run history.
Modeling task is a named set of input model inputs (of workset ids) to run the model. Typical use case: create multiple input sets by varying some model parameters, combine it under named "task" and run the model with that task name. As result multiple model "runs" created ("run" is input and output data of model run). Such run of model called "task run" and allow to study dependencies between model input and output.
Task can be edited by user: new input workset ids added or some workset id(s) excluded. As result current task body (workset ids of the task) may be different from older version of it: task_set set_id's may not be same as task_run_set set_id's. TaskRun and TaskRunSet is a history and result of that task run, but there is no guarantee of any workset in task history still exist or contain same input parameter values as it was at the time of task run. To find actual input for any particular model run and/or task run we must use run_id.
func GetTaskFull ¶
func GetTaskFull(dbConn *sql.DB, taskRow *TaskRow, isSuccess bool, langCode string) (*TaskMeta, error)
GetTaskFull return modeling task metadata, description, notes and run history from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set.
If isSuccess true then return only successfully completed runs else return all runs: success, error, exit, progress. If langCode not empty then only specified language selected else all languages
func GetTaskFullList ¶
func GetTaskFullList(dbConn *sql.DB, modelId int, isSuccess bool, langCode string) ([]TaskMeta, error)
GetTaskFullList return list of modeling tasks metadata, description, notes and run history from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set.
If isSuccess true then return only successfully completed runs else return all runs: success, error, exit, progress. If langCode not empty then only specified language selected else all languages
func GetTaskRunList ¶
GetTaskRunList return model run history: master row from task_lst and all rows from task_run_lst, task_run_set.
func (*TaskMeta) MergeTaskDef ¶
MergeTaskDef update existing and insert new modeling task definition: task metadata and task input worksets.
It does replace: task_txt and task_set db rows. It does not change anything in task run history: task_run_lst and task_run_set tables. If task not exist then new task created. Task input worksets (new content of task_set table) must exist in workset_lst.set_id. Model id and task id updated with actual database id's.
func (*TaskMeta) ReplaceTaskDef ¶
ReplaceTaskDef delete existing and insert new modeling task definition: task metadata and task input worksets.
It does replace: task_txt and task_set db rows. It does not change anything in task run history: task_run_lst and task_run_set tables. If task not exist then new task created. Task input worksets (new content of task_set table) must exist in workset_lst.set_id. Model id and task id updated with actual database id's.
func (*TaskMeta) ToPublic ¶
ToPublic convert modeling task metadata db rows into "public" modeling task format for json import-export.
func (*TaskMeta) UpdateTaskFull ¶
UpdateTaskFull delete existing and insert new modeling task and task run history in database.
Model id, task id, run id, set id updated with actual database id's. Task input worksets (new content of task_set table) must exist in workset_lst table.
type TaskPub ¶
type TaskPub struct { TaskDefPub // task definition: metadata and input worksets TaskRun []taskRunPub // task run history: task_run_lst }
TaskPub is "public" modeling task metadata, task input worksets and task run history for json import-export
func (*TaskPub) FromPublic ¶
func (pub *TaskPub) FromPublic(dbConn *sql.DB, modelDef *ModelMeta, isCompleted bool) (*TaskMeta, bool, bool, error)
FromPublic convert modeling task metadata from "public" format (coming from json import-export) into db rows.
It return task metadata and two boolean flags: (1) isSetNotFound = true if some of task workset names not found in current database (2) isTaskRunNotFound = true if some of task run (pairs of set, model run) set or model run not found in current database.
Worksets are searched by set name, which is unique inside of the model. Model run searched by run digest. If isCompleted true then return only completed runs where status is success, error or exit else return all runs: success, error, exit, progress.
type TaskRow ¶
type TaskRow struct { TaskId int // task_id INT NOT NULL, -- unique task id ModelId int // model_id INT NOT NULL Name string // task_name VARCHAR(255) NOT NULL }
TaskRow is db row of task_lst.
func GetTask ¶
GetTask return modeling task rows by id: task_lst table row and set ids from task_set
func GetTaskByName ¶
GetTaskByName return modeling task rows by id: task_lst table row and set ids from task_set
type TaskRunRow ¶
type TaskRunRow struct { TaskRunId int // task_run_id INT NOT NULL, -- unique task run id TaskId int // task_id INT NOT NULL Name string // run_name VARCHAR(255) NOT NULL, -- task run name SubCount int // sub_count INT NOT NULL, -- subvalue count of task run CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- task status: i=init p=progress w=wait s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp }
TaskRunRow is db row of task_run_lst. This table contains task run history and status.
Task status: i=init p=progress w=wait s=success x=exit e=error(failed)
if task status = w (wait) then model wait and NOT completed until other process set status to one of finals: s,x,e model check if any new sets inserted into task_set and run it as they arrive
func GetTaskFirstRun ¶
func GetTaskFirstRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskFirstRun return first run of the modeling task: task_run_lst table row.
func GetTaskLastCompletedRun ¶
func GetTaskLastCompletedRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskLastCompletedRun return last completed run of the modeling task: task_run_lst table row.
Task run completed if run status one of: s=success, x=exit, e=error
func GetTaskLastRun ¶
func GetTaskLastRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskLastRun return last run of the modeling task: task_run_lst table row.
func GetTaskRun ¶
func GetTaskRun(dbConn *sql.DB, taskRunId int) (*TaskRunRow, error)
GetTaskRun return modeling task run status: task_run_lst table row.
func GetTaskRunByName ¶
GetTaskRunByName return modeling task run status by task id and task run name: task_run_lst table row. If there is multiple task runs with this name then run with min(task_run_id) returned
func GetTaskRunByStamp ¶
GetTaskRunByStamp return modeling task run status by task id and task run stamp: task_run_lst table row. If there is multiple task runs with this stamp then run with min(task_run_id) returned
func GetTaskRunByStampOrName ¶
GetTaskRunByStampOrName return modeling task run status by task id and task run stamp or task run name: task_run_lst table row.
It does select task run row by task id and stamp, if not found then by task id and run name. If there is multiple task runs with this stamp or name then run with min(task_run_id) returned.
func GetTaskRunListByStampOrName ¶
GetTaskRunListByStampOrName return modeling task run rows from task_run_lst table by task id and task run stamp or task run name.
It does select task run rows by task id and stamp, if not found then by task id and run name. If there is multiple task runs with this stamp or name then multiple rows returned.
type TaskRunSetRow ¶
type TaskRunSetRow struct { TaskRunId int // task_run_id INT NOT NULL RunId int // run_id INT NOT NULL, -- if > 0 then result run id SetId int // set_id INT NOT NULL, -- if > 0 then input working set id TaskId int // task_id INT NOT NULL }
TaskRunSetRow is db row of task_run_set. This table contains task run input (working set id) and output (model run id)
func GetTaskRunSetRows ¶ added in v1.8.4
func GetTaskRunSetRows(dbConn *sql.DB, taskRunId int) ([]TaskRunSetRow, error)
GetTaskRunSetRows return task run body (pairs of run id and set id) by task run id: task_run_set table rows.
type TaskRunSetTxt ¶
type TaskRunSetTxt struct { SetTxt map[string][]DescrNote // map workset name to description and notes by language RunTxt map[string][]DescrNote // map run digest-or-name to description and notes by language }
TaskRunSetTxt is additional task text: description and notes by language for all input worksets and model runs of the task. Run identified by run digest or, if digest is null then by run name
func GetTaskRunSetText ¶
func GetTaskRunSetText(dbConn *sql.DB, taskId int, isSuccess bool, langCode string) (*TaskRunSetTxt, error)
GetTaskRunSetText return additinal modeling task text description and notes for all task worksets and model runs: workset_txt, run_txt table rows.
It includes all input worksets text and model runs text. If isSuccess true then return only successfully completed runs else return all runs: success, error, exit, progress. If langCode not empty then only specified language selected else all languages.
type TaskTxtRow ¶
type TaskTxtRow struct { TaskId int // task_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TaskTxtRow is db row of task_txt
type TypeDicRow ¶
type TypeDicRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL TypeHid int // type_hid INT NOT NULL, -- unique type id Name string // type_name VARCHAR(255) NOT NULL, -- type name: int, double, etc. Digest string // type_digest VARCHAR(32) NOT NULL DicId int // dic_id INT NOT NULL, -- dictionary id: 0=simple 1=logical 2=classification 3=range 4=partition 5=link TotalEnumId int // total_enum_id INT NOT NULL, -- if total enabled this is enum_value of total item =max+1 IsRange bool // if true then it is range type and enums calculated MinEnumId int // min enum id MaxEnumId int // max enum id // contains filtered or unexported fields }
TypeDicRow is db row of type_dic join to model_type_dic table and min, max, count of enum id's.
TypeHid (type_dic.type_hid) is db-unique id of the type, use digest to find same type in other db. TypeId (model_type_dic.model_type_id) is model-unique type id, assigned by model compiler.
func (*TypeDicRow) IsBool ¶
func (typeRow *TypeDicRow) IsBool() bool
IsBool return true if model type is boolean.
func (*TypeDicRow) IsBuiltIn ¶
func (typeRow *TypeDicRow) IsBuiltIn() bool
IsBuiltIn return true if model type is built-in, ie: int, double, logical.
func (*TypeDicRow) IsFloat ¶
func (typeRow *TypeDicRow) IsFloat() bool
IsFloat return true if model type is any of float family.
func (*TypeDicRow) IsFloat32 ¶ added in v1.13.0
func (typeRow *TypeDicRow) IsFloat32() bool
IsFloat32 return true if model type is float 32 bit.
func (*TypeDicRow) IsInt ¶
func (typeRow *TypeDicRow) IsInt() bool
IsInt return true if model type is integer (not float, string or boolean). If type is not a built-in then it must be integer enums.
func (*TypeDicRow) IsString ¶
func (typeRow *TypeDicRow) IsString() bool
IsString return true if model type is string.
type TypeEnumRow ¶
type TypeEnumRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL EnumId int // enum_id INT NOT NULL Name string // enum_name VARCHAR(255) NOT NULL }
TypeEnumRow is db row of type_enum_lst join to model_type_dic table
type TypeEnumTxtRow ¶
type TypeEnumTxtRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL EnumId int // enum_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TypeEnumTxtRow is db row of type_enum_txt join to model_type_dic table
type TypeMeta ¶
type TypeMeta struct { TypeDicRow // model type rows: type_dic join to model_type_dic Enum []TypeEnumRow // type enum rows: type_enum_lst join to model_type_dic }
TypeMeta is type metadata: type name and enums
type TypeTxtRow ¶
type TypeTxtRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TypeTxtRow is db row of type_dic_txt join to model_type_dic table
type WorksetCreatePub ¶ added in v1.9.2
type WorksetCreatePub struct { WorksetHdrPub Param []ParamValuePub // workset parameters: name, text (value notes by language) and value }
WorksetCreatePub is "public" workset metadata and parameters list for json import-export. Each parameter must have metadata: name, subvalues count, optinal notes and value(s). Values can be either literal cell values or copy direction, for example run digest to copy from.
type WorksetHdrPub ¶
type WorksetHdrPub struct { ModelName string // model name for that workset ModelDigest string // model digest for that workset ModelVersion string // model_ver VARCHAR(32) NOT NULL ModelCreateDateTime string // create_dt VARCHAR(32) NOT NULL Name string // workset name: set_name VARCHAR(255) NOT NULL BaseRunDigest string // if not empty then digest of the base run IsReadonly bool // readonly flag UpdateDateTime string // last update date-time IsCleanBaseRun bool // if true then update set base run digest to NULL Txt []DescrNote // workset text: description and notes by language }
WorksetHdrPub is "public" workset metadata for json import-export
type WorksetMeta ¶
type WorksetMeta struct { Set WorksetRow // workset master row: workset_lst Txt []WorksetTxtRow // workset text rows: workset_txt Param []worksetParam // workset parameter: parameter_hid, sub-value count and workset_parameter_txt rows }
WorksetMeta is a model workset metadata: name, parameters, decription, notes.
Workset (working set of model input parameters): it can be a full set, which include all model parameters or subset and include only some parameters.
Each model must have "default" workset. Default workset must include ALL model parameters (it is a full set). Default workset is a first workset of the model: set_id = min(set_id). If workset is a subset (does not include all model parameters) then it can be based on model run results, specified by run_id (not NULL).
Workset can be editable or read-only. If workset is editable then you can modify input parameters or workset description, notes, etc. If workset is read-only then you can run the model using that workset as input.
Important: working set_id must be different from run_id (use id_lst to get it) Important: always update parameter values inside of transaction scope Important: before parameter update do is_readonly = is_readonly + 1 to "lock" workset
WorksetMeta is workset metadata db rows: workset_lst, workset_txt, workset_parameter, workset_parameter_txt
func GetWorksetFull ¶
func GetWorksetFull(dbConn *sql.DB, setRow *WorksetRow, langCode string) (*WorksetMeta, error)
GetWorksetFull return full workset metadata: workset_lst, workset_txt, workset_parameter, workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetFullList ¶
func GetWorksetFullList(dbConn *sql.DB, modelId int, isReadonly bool, langCode string) ([]WorksetMeta, error)
GetWorksetFullList return list of full workset metadata: workset_lst, workset_txt, workset_parameter, workset_parameter_txt table rows.
If isReadonly true then return only readonly worksets else all worksets. If langCode not empty then only specified language selected else all languages
func (*WorksetMeta) ToPublic ¶
func (meta *WorksetMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetPub, error)
ToPublic convert workset db rows into "public" workset format for json import-export
func (*WorksetMeta) UpdateWorkset ¶
func (meta *WorksetMeta) UpdateWorkset(dbConn *sql.DB, modelDef *ModelMeta, isReplace bool, langDef *LangMeta) error
UpdateWorkset create new workset metadata, replace or merge existing workset metadata in database.
Set name is used to find workset and set id updated with actual database value. Workset must be read-write for replace or merge.
Only metadata updated: list of workset parameters not changed. To add or remove parameters form workset use UpdateWorksetParameterFrom() method. It is an error if incoming list parameters include any parameter which are not already in workset_parameter table.
If workset does not exist then empty workset created, without parameters. Parameter list in workset metadata must be empty if workset does not exist.
Replace is replace of existing metadata or create empty new workset. If workset exist then workset metadata replaced and parameters text metadata replaced.
Merge does merge of text metadata with existing workset or create empty new workset. If workset exist then text is updated if such language already exist or inserted if no text in that language.
func (*WorksetMeta) UpdateWorksetParameterFrom ¶ added in v1.9.7
func (meta *WorksetMeta) UpdateWorksetParameterFrom( dbConn *sql.DB, modelDef *ModelMeta, isReplaceMeta bool, param *ParamRunSetPub, langDef *LangMeta, from func() (interface{}, error), ) (int, error)
UpdateWorksetParameterFrom add new or replace existing workset parameter.
If parameter already exist in workset then parameter metadata either merged or replaced. If parameter not exist in workset then parameter values must be supplied, it cannot be empty. If parameter not exist in workset then new parameter metadata and values inserted. If from() not nil then parameter values completely replaced, on each call from() must return CellParam for all parameter values.
Set name is used to find workset and set id updated with actual database value. Workset must be read-write for replace or merge.
type WorksetParamTxtRow ¶
type WorksetParamTxtRow struct { SetId int // set_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000), -- parameter value note }
WorksetParamTxtRow is workset_parameter_txt table row.
func GetWorksetAllParamText ¶
func GetWorksetAllParamText(dbConn *sql.DB, setId int, langCode string) ([]WorksetParamTxtRow, error)
GetWorksetAllParamText return all workset parameters value notes: workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetParamText ¶
func GetWorksetParamText(dbConn *sql.DB, setId int, paramHid int, langCode string) ([]WorksetParamTxtRow, error)
GetWorksetParamText return parameter value notes: workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
type WorksetPub ¶
type WorksetPub struct { WorksetHdrPub Param []ParamRunSetPub // workset parameters: name and text (value notes by language) }
WorksetPub is "public" workset metadata and parameter metadata for json import-export
func (*WorksetPub) FromPublic ¶
func (pub *WorksetPub) FromPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetMeta, error)
FromPublic convert workset metadata from "public" format (coming from json import-export) into db rows.
type WorksetRow ¶
type WorksetRow struct { SetId int // unique working set id BaseRunId int // if not NULL and positive then base run id (source run id) ModelId int // model_id INT NOT NULL Name string // set_name VARCHAR(255) NOT NULL IsReadonly bool // is_readonly SMALLINT NOT NULL UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time // contains filtered or unexported fields }
WorksetRow is workset_lst table row.
func GetDefaultWorkset ¶
func GetDefaultWorkset(dbConn *sql.DB, modelId int) (*WorksetRow, error)
GetDefaultWorkset return default working set for the model: workset_lst table row.
Default workset is a first workset for the model, each model must have default workset.
func GetWorkset ¶
func GetWorkset(dbConn *sql.DB, setId int) (*WorksetRow, error)
GetWorkset return working set by id: workset_lst table row.
func GetWorksetByName ¶
GetWorksetByName return working set by name.
If model has multiple worksets with that name then return first set.
func GetWorksetList ¶
func GetWorksetList(dbConn *sql.DB, modelId int) ([]WorksetRow, error)
GetWorksetList return list of model worksets: workset_lst rows.
type WorksetTxtRow ¶
type WorksetTxtRow struct { SetId int // set_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
WorksetTxtRow is db row of workset_txt
func GetWorksetText ¶
GetWorksetText return workset description and notes: workset_txt table rows.
If langCode not empty then only specified language selected else all languages
type WriteLayout ¶
type WriteLayout struct { Name string // parameter name or output table name ToId int // run id or set id to write parameter or output table values }
WriteLayout describes parameters or output tables values for insert or update.
Name is a parameter or output table name to read.
type WriteMicroLayout ¶ added in v1.13.0
type WriteMicroLayout struct { WriteLayout // common write layout: entity name and run id DoubleFmt string // used for float model types digest calculation }
WriteMicroLayout describes source and size of data page to read entity microdata.
Double format string is used for digest calculation if value type if float or double.
type WriteParamLayout ¶
type WriteParamLayout struct { WriteLayout // common write layout: parameter name, run or set id SubCount int // sub-values count IsToRun bool // if true then write into into model run else into workset IsPage bool // if true then write only page of data else all parameter values DoubleFmt string // used for float model types digest calculation }
WriteParamLayout describes parameter values for insert or update.
Double format string is used for digest calculation if value type if float or double.
type WriteTableLayout ¶
type WriteTableLayout struct { WriteLayout // common write layout: output table name and run id SubCount int // sub-values count DoubleFmt string // used for float model types digest calculation }
WriteTableLayout describes output table values for insert or update.
Double format string is used for digest calculation if value type if float or double.
Source Files ¶
- calculate.go
- cellAcc.go
- cellAllAcc.go
- cellExpr.go
- cellMicro.go
- cellMicroCalc.go
- cellParam.go
- cellTableCalc.go
- cellValue.go
- copyParameter.go
- db.go
- dbFacet.go
- dbModel.go
- dbModelCommon.go
- dbModelInternal.go
- dbModelRunSetTask.go
- db_no_odbc.go
- deleteModel.go
- deleteRun.go
- deleteTask.go
- deleteWorkset.go
- getCommon.go
- getLanguage.go
- getModel.go
- getModelText.go
- getRun.go
- getTask.go
- getWorkset.go
- publicRun.go
- publicTask.go
- publicWorkset.go
- readMicrodata.go
- readOutputTable.go
- readParameter.go
- readWriteLayout.go
- translateAggregation.go
- translateFnc.go
- translateHelper.go
- translateToAccSql.go
- translateToExprSql.go
- translateToMicroSql.go
- updateCommon.go
- updateLanguage.go
- updateModel.go
- updateModelText.go
- updateProfile.go
- updateRun.go
- updateTask.go
- updateWorkset.go
- updateWorksetParameter.go
- writeMicrodata.go
- writeOutputTable.go
- writeParameter.go