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(); }