Example: Working with dynamic interface schemas

The example operator specifies a schema variable for both the input and the output interface schema. In addition, when you instantiate the operator, you must specify two fields of its input interface schema.

The following figure shows an example of an operator with a dynamic interface schema:

Figure 1. Operator with a dynamic interface schemaOperator with a dynamic interface schema

To create an operator with such a dynamic interface schema, you typically provide a constructor that takes an argument defining the schema. This constructor can take a single argument defining a single interface field, an array of arguments defining multiple interface fields, or any combination of arguments specific to your derived operator.

The constructor for the operator shown in the previous figure has the following form:
ADynamicOperator (char * inputSchema);
The constructor for an operator that supports a dynamic interface must make the interface schema definition available to the APT_Operator::describeOperator() function, which contains calls to: For example:
setInputInterfaceSchema("record(a:string; b:int64; inRec:*;)", 0);
setOutputInterfaceSchema("record (outRec:*;)", 0);
These functions must include any schema components specified in the constructor or by member functions of the operator.

APT_Operator::runLocally() defines the cursors and field accessors used by the operator to access the records and record fields of the data sets processed by an operator. Because users of the operator can define field names and data types for the interface schema of an operator, APT_Operator::runLocally() must be able to create the corresponding accessors for those fields.