Interface ModelParallelCalculationFormulaItemContext
- All Superinterfaces:
ModelFormulaContextReadOnly
The
ModelParallelCalculationFormulaItemContext
is exposed to model parallel calculation logics through the model
binding.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
-
Method Summary
Modifier and TypeMethodDescriptionlong
loadTable
(DatamartContext.Table table, DatamartContext.Query query) Sample code:long
loadTable
(DatamartContext.Table table, DatamartContext.SqlQuery query) Sample code:Methods inherited from interface ModelFormulaContextReadOnly
attachmentDownloadURL, currentStep, filterTreesContext, inputs, label, lookupTablesContext, outputs, pmmlContext, rContext, schedulesContext, table, typedId, uniqueName
-
Method Details
-
calculationItem
ModelParallelCalculationFormulaItemContext.CalculationItem calculationItem()- Returns:
- the item currently calculated
- Since:
- 9.0 Hurricane
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.Query query) throws InterruptedException Sample code:
WARNING: the given query must be idempotent (e.g., using key columns on the table) as each item calculation may be run several times (by several nodes) and the ordering of their execution is also nondeterministic.def ctx = api.getDatamartContext() def query = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") .where(Filter.equal("sku", model.calculationItem().inputs()['sku'])) def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query)
- Parameters:
table
- A table in this modelquery
- An idempotent query to load into the table- Returns:
- The number of row added
- Throws:
InterruptedException
- Since:
- 10.0 Bee's Knees
-
loadTable
long loadTable(DatamartContext.Table table, DatamartContext.SqlQuery query) throws InterruptedException Sample code:
WARNING: the given query must be idempotent (e.g., using key columns on the table) as each item calculation may be run several times (by several nodes) and the ordering of their execution is also nondeterministic.def ctx = api.getDatamartContext() def t1 = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") .where(Filter.equal("sku", model.calculationItem().inputs()['sku'])) def query = ctx.newSqlQuery() query.addSource(t1) query.setQuery('SELECT P, R::numeric as R FROM T1 ORDER BY P') def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query)
- Parameters:
table
- A table in this modelquery
- An idempotent query to load into the table- Returns:
- The number of row added
- Throws:
InterruptedException
- Since:
- 10.0 Bee's Knees
-