After you have dragged and dropped more than one component from the Palette View to the EventFlow Editor, you will want to connect them, indicating that the output tuples of one component are the input tuples to another component, or in the case of data constructs, indicating the operators that use them. These connections are called arcs in StreamBase Studio.
To make an arc between two operators or an operator and a stream, click the black square on the right (output) port of one component, and drag the mouse pointer to an input port on the left square port of another component. When you have successfully created the arc, a solid black line is shown between the components, and components "downstream" are likely to change color to indicate their new typecheck status. The figure below shows six connected components - an input stream, two Map operators, a Filter operator, a Union operator, and an output stream.
|
Note
To display the components' type labels above the icons, we enabled the Show Component Types preference.
To create an arc between a data construct and an operator that uses it, click the gray
square on the bottom port of the operator, and drag the mouse pointer to the gray
square at the top of its associated data construct. (You can also create arcs starting
with the data construct and connecting it to the operator.) When you have successfully
created the arc, a dotted gray line is shown between the components. Note that multiple
operators may be connected to a single data construct. For example, the following
figure is from the sample application at :
streambase-directory/sample/operator/query/Query.sbapp
After you have created arcs, you can click on them to display their properties in the Properties view. Clicking an arc between two operators or an operator and a stream normally causes StreamBase Studio to display a read-only table in the Schema tab (shown below). The fields shown in the table represent the schema output from the previous operator or stream and input to the next operator or stream. Under certain conditions (see Arcs in Loops), StreamBase Studio cannot determine which schema to use, and you may need resolve the ambiguity.
Clicking an arc between an operator and a data construct causes StreamBase Studio to display a read-only Association tab (shown below), that tells you about the association.
If your EventFlow contains an arc that creates a loop between two or more components, StreamBase Studio will display a typecheck error in the Typecheck Errors View and mark the "downstream" components gray, as shown in the figure below.
When components are in a loop, it is unclear to StreamBase Studio which schema should be used to typecheck them, because some schemas depend on other components that have not yet processed data. When this typecheck error occurs, select one of the arcs and open its Properties view. Then resolve the typecheck error in one of the following ways:
-
Define the schema by editing its fields in the table.
-
If the loop involves a Union operator (which by definition requires the schemas on all input ports to be the same), StreamBase Studio assists you with editing the schema. This is shown in the preceding figure. If you click the Use the schema link, StreamBase Studio will fill the table with the first valid schema it detects (the schema associated with the first port, if all schemas are valid).
-
Click the button and insert an existing schema. You can choose a schema from any application within any project in your Package Explorer, or one previously saved in the Saved Schemas view.
When you click off the Properties view (or click the
Apply
and Typecheck button near the top-right area of the Properties view), the typecheck
error associated with the loop should go away. Then the arc with the schema you
specified will turn blue. (See figure below.) If you later update a schema that
participates in the loop, the typecheck error will reappear, and StreamBase
Studio will provide an Update Using This Schema link in the Properties view
when you click the arc.
A more subtle example of a loop occurs in the following EventFlow fragment:
|
When the loop condition is not obvious, use the clues that StreamBase provides. Typecheck error messages are often the best place to start. In this example, the Typecheck Errors view contains this message:
You have a loop involving update_tuple_count,tuple_count,grab_tuple_count.... Click on any arc within the loop to explicitly edit the schema.
A closer investigation of the application used in this example would reveal that the loop condition is set up by the Lock and Unlock operators and their associated Lock Set data construct. The grab_tuple_count operator is attempting to process data within that flow, passing a result to the BSort operator. However, before the expected data can arrive, it is delayed at the Lock1 operator, awaiting some condition farther downstream to unlock the data.
As the error message suggests, the solution is to click the grab_tuple_count operator'a output arc, and after determining what fields should be passed through, explicitly adding the fields to its schema.
