This sample illustrates how certain numeric data types can coerce; that is, how same-named field values with certain compatible types can all appear to be carried by a new field with a type compatible with all original values. It consists of a Studio project containing a single EventFlow module file.
The module illustrates some of the basic types that are coercible:
int and double coerce to double
int and long coerce to long
Coercion also takes place when the fields are lists-of each type, or are individual fields within a field of type tuple.
Rearrange the arcs and try connecting the unconnected input streams to explore which types do not coerce: double will not coerce to long (loss of data from long type) no types coerce to string, timestamp or blobs
For details on type coercion, see Data Type Coercion and Conversion in the StreamBase Reference documentation.
In StreamBase Studio, import this sample with the following steps:
From the top-level menu, click> .
coeto narrow the list of options.
Select Examples of Data Type Coercion from the Applications category.
StreamBase Studio creates a project for each sample.
In the EventFlow Editor, you can explore which data types can be coerced together and which may not. Follow these steps to explore this sample in the EventFlow editor:
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select> from the context menu.
Coercions.sbappfile in the
Notice that there are two groups of input streams, union operators, and output streams, called Lists and Tuples . The only difference between them is their schemas.
In the Lists group, hover the mouse pointer over the arc exiting the intmeetslong Union operator (bottom right).
Notice that its schema is list(long). This is because it is coercing its inputs, one of which is list(int) and the other of which is list(long), to data type long.
Click on the arc exiting the input stream ListOfDouble near its arrowhead.
Notice that its schema is list(double).
Drag the arc away from the intmeetsdouble Union operator and instead connect it to the intmeetslong Union operator.
A new input port on the intmeetslong Union operator appears to receive the arc.
Again, hover the mouse pointer over the arc exiting the intmeetslong Union operator.
Notice that the schema of that arc has changed from list(long) to list(double) as the result of type coercion.
Try connecting the input streams ListOfTimestamp and ListOfString to either Union operator in its group. What happens? Hover over the Union operator to see.
If you want to undo any change you have made to the diagram, click Ctrl+Z (Windows) or command+Z (Mac).> or type
Repeat any of the above steps on the components in the Tuples group. Observe how it behave similarly to the Lists group.
If the application has no typecheck errors, click the Run button to send lists and tuples to it. (You may be asked to save the application first). The SB Test/Debug perspective opens and the module starts.
In the Manual Input view, select.
Click the green mylist to add a list element.button to the right of
Enter an integer in the mylist(0) field
Optionally repeat steps 9 and 10 to add more list elements and enter their values.
In the Output Streams view, observe the values in the OutListOfLong and OutListOfDouble streams and notice where type coercion has occurred.
Select a different input stream and repeat steps 10–13 to observe when coercion takes place.
When done, press F9 or click the Terminate EventFlow Fragment button.
The Type Coercion sample consists of the files shown in the following table.
||An EventFlow module illustrates which data types are compatible and in what ways.|
||The file describing how the application is laid out in StreamBase Studio.|
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
See Default Installation Directories for the default location of
studio-workspace on your system.