Using the Iterate Operator

Introduction

  Use the Iterate operator to emit one tuple for each element in a list. You specify a field of type list in an incoming stream, and the operator emits one tuple for each element in that field's list. Since list fields can contain a varying number of elements for each tuple, this operator resolves each incoming tuple into multiple outgoing tuples, each of which has the same schema as the incoming tuple, but with one new field prepended by the Iterate operator. The prepended field has the same data type as the element type of the specified list field in the incoming tuple. The added field is populated with each element of the specified incoming list, in list order, one per emitted tuple.

For example, in incoming tuple 1, a list(double) field named Bids might have six elements. The Iterate operator receives one tuple and outputs six tuples, with all fields the same as the incoming fields, except that one new field, eachbid, is prepended to the schema. The eachbid field has type double and is populated by the elements of the Bids list, one at a time in list order, for each outgoing tuple.

Then, in incoming tuple 2, list Bids might have three elements. The Iterate operator receives incoming tuple 2 and outputs three tuples, and so on.

The StreamSQL equivalent of the Iterate operator is the FOREACH clause of the SELECT statement. See SELECT Statement in the StreamSQL Guide.

Properties: General Tab

Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.

Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.

Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.

Properties: Operation Settings Tab

In the Properties view for an Iterate operator, the Settings tab requires the following parameters:

Property Description
Iterate Over Specify a field of data type list in the incoming stream, or specify an expression that resolves to a field of type list.
Output Element Field Name Specify the name of the outgoing field that is prepended to the schema of the incoming tuple to form the schema of outgoing tuples.

Properties: Concurrency Tab

Use the Concurrency tab to specify separate threading for this instance of this component. The own thread check box is a candidate for selection if this component instance is long-running or compute-intensive, can run without data dependencies on other StreamBase components, and would not cause the containing module to block while waiting for a thread to return. In this case, you may be able to improve performance by selecting this option. This option causes StreamBase Server to process this component concurrently with other processing in the application. The operating systems supported by StreamBase automatically distribute the processing of threads across multiple processors.

Caution

The separate thread setting is not suitable for every application, and using this setting requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.