ComplexTypeRunner.sbapp sample demonstrates how to use the StreamBase Client API to retrieve fields and values from complicated structures from a
tuple, such as a list of integers or a list of tuples that contain a double.
For details about how StreamBase used the API to extend com.streambase.sb.operator.*, see Using the Java Operator API in the API Guide. For information about importing a JAR that contains a Java Operator in StreamBase Studio, and then selecting an Operator class from that JAR, see Using the Java Operator to Perform Custom Functionality in the Authoring Guide.
For details about using custom icons with your Java operators, see the Java Client library documentation for
The Java code in this sample is delivered only in source code form. To build the code, you must load the sample into StreamBase Studio, which automatically builds the Java code.
In StreamBase Studio, import this sample with the following steps:
From the top-level menu, select→ .
javato narrow the list of options.
Select custom-java-aggregate from the Extending StreamBase category.
StreamBase Studio creates a project for the sample.
In the Project Explorer, open the sample you just loaded.
Open the package folder (most samples contain a single package folder. Open the top-level package folder if your sample contains more than one folder).
Open the named application file and click the Run button. This opens the SB Test/Debug perspective and starts the application.
If you see red marks, wait a moment for the project in Studio to load its features.
If red marks do not resolve themselves in a moment, select the project and right-click→ from the context menu.
In the Manual Input tab, add two intList elements and enter the values:
intList = 1 intList = 2Also add two tupleList elements and enter the values:
tupleList > innerDouble = 1.0 tupleList > innerDouble = 2.0Once all values are entered, click .
In the Application Output view, note the summed values:
intListSum = 3 tupleListSum = 3.0
When done, press F9 or click the Stop Running Application button.
The Java Operator Complex Types sample includes the following files:
The source code for a Customer Java Operator which takes in two complex fields,
intList(a list of integers) and
tupleList(a list of tuples, each of which has a double field,
innerDouble). The operator emits two additional fields,
intListSum(a sum of all integer values in the
tupleListSum(a sum of all
innerDoublevalues from all tuples contained in the
A simple EventFlow application which uses the
ComplexTypeAccessorCustom Java Operator to emit the summed integer and double values as described above.
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.