Contents
This sample consists of a simple EventFlow application, QueryIndexByExpression.sbapp
, that illustrates the Query Table's
index by expression feature. This feature allows you to use an expression as part of
specifying the field or fields that comprise a secondary index for a Query Table. The
expression must be statically resolvable, and must contain the name of at least one
field in the Query Table's schema.
This sample's Query Table has the schema {string symbol, double lastPriceChange} and is automatically populated with the following values by means of the Initial Contents tab of the table's Properties view:
IBM, -4.3 |
MSFT, 6.7 |
GOOG, -2.3 |
APPL, 9.3 |
The field name portion of the Query Table's secondary index is specified with the
expression abs(lastPriceChange)
. This
simple expression allows you to enter either a query value either as a positive or
negative number and obtain the same result. For example, if a Query operator
specifies a Read operation based on this secondary index, you could enter either 4.3
or –4.3 to obtain the result IBM.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, click
> . -
Enter
sample group
to narrow the list of options. -
Select Operator sample group from the Data Constructs and Operators category.
-
Click
.
StreamBase Studio creates a single project for the operator sample group.
-
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. -
Open the
src/main/eventflow/com.tibco.sb.sample.operator
folder. -
Open the
QueryIndexByExpression.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
In the Manual Input view, the QueryByPriceDelta input stream is preselected. Enter one of the values from the initially loaded contents shown above, as either a positive or negative number. For example, enter –4.3, then enter 4.3.
-
Click Send Data, and a tuple arrives in the Output Streams view. In both cases, the Output Streams view shows the IBM row of the Query Table returned on the QueryResults stream.
-
Continue experimenting with values from the list above, or values not in the list.
-
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.
Important
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:
studio-workspace
/sample_operator
See Default Installation
Directories for the default location of studio-workspace
on your system.