This topic describes
Iterate.sbapp, the Iterate
operator's sample application.
This sample uses an Aggregate operator and the
aggregatelist() expression language function to aggregate incoming
tuples and collect them by their Symbol field into three-element lists of tuples, so
that every list output contains three input tuples of the same stock. An Iterate operator then takes these
lists and extracts their component tuples to reorder and supplement the output fields.
The incoming tuple contains fields named Symbol, Name, Volume, and Price.
In StreamBase Studio, import this sample with the following steps:
From the top-level menu, click> .
sample groupto narrow the list of options.
Select Operator Sample Group from the Data Constructs and Operators category.
StreamBase Studio creates a single project for all the operator samples.
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.
Iterate.sbappfile and click the Run button. This opens the SB Test/Debug perspective and starts the module.
In the Manual Input view, select the
Enter a dozen or so tuples, alternating the Symbol field, but re-using the same Symbol several times, clicking Send Data after each entry. For example, enter:
IBM, IBM Corporation, 4000, 127.81 AAPL, Apple Inc, 2500, 133.62 IBM, IBM Corporation, 1000, 128.00 AAPL, Apple Inc, 500, 133.64 MSFT, Microsoft Corporation, 6000, 28.70 AAPL, Apple Inc, 2000, 133.75 MSFT, Microsoft Corporation, 400, 27.75 IBM, IBM Corporation, 2500, 129.62
Instead of typing in the Manual Input view, while
Iterate.sbappis still running in Studio, open a StreamBase Command Prompt. Start an enqueue session for the sample's input stream by typing
sbc enqueue StockIn. Then copy the contents of the gray box above and paste them into the command prompt window.
Inspect the Output Streams view. Notice that there are three entries for Dell and three for IBM. There is no output for Microsoft yet because we have only entered two tuples. Enter one more Microsoft tuple to trigger its entries in the Output Streams view:
MSFT, Microsoft Corporation, 1400, 29.45
Enter more tuples and watch them accumulate in groups of three.
When done, press F9 or click the Terminate EventFlow Fragment button.
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.