Using field lists with operators
You can use field lists when you specify the interface schema to an operator with a dynamic interface.
The following example defines one such operator, called DynamicOperator:
Figure 1. DynamicOperator

The operator has the following characteristics:
- Takes a single data set as input.
- Writes its results to a single output data set.
- Has an input interface schema consisting of a single schema variable inRec and an output interface schema consisting of a single schema variable outRec.
static char schema[] = "record" // Schema of input data set
"( a:int32; "
" b:int32; "
" c:int16; "
" d:sfloat; "
" e:string; )";
DynamicOperator aDynamicOp("a - c"); // Specify the input schema
The following table shows the definition of DynamicOperator. Comments follow the code in the table.
| Comment | Code |
|---|---|
|
|
- 8
- Define a constructor that takes a field list as an argument.
- 16
- Define storage for the complete input interface schema to the operator.
- 17
- Define storage for the input field list specifying the input schema.
- 23
- Use APT_Operator::viewAdaptedSchema() to obtain the complete record schema of the input data set. You will expand the input field list in the context of the input data set record schema.
- 24
- Define err, an instance of APT_FieldList::Error, to hold any errors generated when expanding the field list.
- 25
- Use APT_FieldList::expand() to expand the field list relative to the record schema of the input data set. If the field list does not contain a wildcard or field range, the expand function does nothing.
- 26
- If any errors occurred during the expansion, print the description of the error and return APT_StatusFailed from describeOperator().
- 31
- Use APT_FieldList::numFields() to determine the number of fields in the field list.
- 32
- Create a for loop to iterate through the field lists. For each element in the field list, add a schema field to inSchema, the input interface schema of the operator.
- 34
- Use APT_FieldList::field() to get a field selector from the expanded field list.
- 35
- Use APT_Schema::field() to return an APT_SchemaField object corresponding to a record schema field of the input data set.
- 36
- Use APT_Schema::addField() to add the APT_SchemaField object to inSchema.
- 38 - 41
- After adding all the fields of the field list to the input interface schema, you must create a schema field component for the schema variable "inRec:*;" and add that component to the input interface schema. Use APT_Schema::addField() to add the schema variable to allow transfers from the input data set to the output data set.
- 42
- Use APT_Operator::setInputInterfaceSchema() to set the input interface schema of the operator to the schema contained in inSchema.