Interface ModelParallelCalculationFormulaItemContext

All Superinterfaces:
ModelFormulaContextReadOnly

public interface ModelParallelCalculationFormulaItemContext extends ModelFormulaContextReadOnly
The ModelParallelCalculationFormulaItemContext is exposed to model parallel calculation logics through the model binding.
  • Method Details

    • calculationItem

      Returns:
      the item currently calculated
      Since:
      9.0 - Hurricane
    • loadTable

      Sample code:
      
           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)
       
      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.
      Parameters:
      table - A table in this model
      query - An idempotent query to load into the table
      Returns:
      The number of row added
      Throws:
      InterruptedException
      Since:
      10.0 - Bee's Knees
      See Also:
    • loadTable

      Sample code:
      
           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)
       
      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.
      Parameters:
      table - A table in this model
      query - An idempotent query to load into the table
      Returns:
      The number of row added
      Throws:
      InterruptedException
      Since:
      10.0 - Bee's Knees
      See Also:
    • loadTable

      long loadTable(DatamartContext.Table table, PipelineStage query, boolean truncate) throws InterruptedException
      Sample code:
      
           def qapi = api.queryApi()
           def ds = qapi.tables().dataSource("txDS")
           def query = qapi
               .source(ds, [ds.sku, ds.amount])
               .aggregateBy({ t -> [t.sku] }, { t -> [t.sku.as("P"), qapi.exprs().sum(t.amount).as("R")] })
               .sortBy { t -> [qapi.orders().ascNullsLast(t.P)] }
           def table = model.getTable('MyTable')
           def nbRowAdded = model.loadTable(table, query, false)
       
      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.
      Parameters:
      table - A table in this model
      query - The query to load into the table
      truncate - If the table should be truncated before loading
      Returns:
      The number of row added
      Throws:
      InterruptedException
      Since:
      15.0 - Southside
      See Also: