Constructor for a SQL-MapReduce Function in Java - 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

Each function must implement a constructor which takes only a RuntimeContract. The function class is instantiated during planning of the query, and it informs the system about its properties via the RuntimeContract. The system fills in various fields in the contract (such as the input schema and the argument clauses) and passes this incomplete contract to the constructor. The constructor must fill in the function's output schema and then complete the contract. Below is an example of a constructor for a simple SQL-MapReduce function that always returns (word varchar, count int).

public tokenize(RuntimeContract contract)
{
ArrayList<ColumnDefinition> outputColumns = new ArrayList<ColumnDefinition>();
outputColumns.add( new ColumnDefinition( "word", SqlType.varchar() ) );
outputColumns.add( new ColumnDefinition( "count", SqlType.int() ) );
contract.setOutputInfo( new OutputInfo(outputColumns) );
contract.complete();
}