Associating an IMDC with an Input Iterator with the API - Aster Execution Engine

Teradata Aster® Developer Guide

Product
Aster Execution Engine
Release Number
7.00.02
Published
July 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
xnl1494366523182.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
ffu1489104705746
lifecycle
previous
Product Category
Software
During contract negotiation, you can associate an IMDC with an input iterator. Then, when an input source is associated with the IMDC, the input iterator is provided to data-consuming methods, which iterate over the data in the IMDC. Associating an IMDC with an input iterator is an easy way to integrate the use of the IMDC with a SQL-MapReduce function.
The IMDC must exist before the data-consuming methods are invoked. You can create the IMDC with the API or a utility function, or the IMDC can be created by a SQL-MapReduce function that was called by an earlier query in the session.
  • Associate an IMDC with an input iterator during contract negotiation:
    public function_name (RuntimeContract contract)
    {
      ...
      InputInfo inputInfo = contract.getInputInfo();
      contract.useInMemoryDataCollectionForInput(inputInfo, "IMDC_name");
      ...
    }
    
An input iterator is now associated with the IMDC. When the IMDC exists and an input source is associated with it, the input iterator is provided to the data-consuming method, which iterates over the data in the IMDC.

For example, the function my_sqlmr associates an input iterator with the IMDC myIMDC, and the input iterator iterates over the myIMDC:

public my_sqlmr (RuntimeContract contract)
{
  ...
  InputInfo inputInfo = contract.getInputInfo();
  contract.useInMemoryDataCollectionForInput(inputInfo, "myIMDC");
  ...
}

public void operateOnSomeRows(
              RowIterator inputIterator,
              RowEmitter outputEmitter
            )
{           
       
  //inputIterator iterates over data in IMDC "myIMDC"
  while ( inputIterator.advanceToNextRow() )
    {
      outputEmitter.addFromRow(inputIterator);
      outputEmitter.emitRow();
    }     
}