TableOperator Java Client API Sample


This sample illustrates the use of the TableAccessor class in the Java Client API. This class lets Java code (such as custom Java operators) interact with data sources in various ways. In particular, this class lets you insert rows, replace rows, read a single row based on the primary index, perform more complex multi-row queries, delete rows, get table size, and truncate entire tables.

This sample includes seven custom Java operators, each of which illustrates a single aspect of the TableAccessor class:

  • InsertJavaOperator

  • ReplaceJavaOperator

  • ReadPrimaryJavaOperator

  • QueryJavaOperator

  • DeleteJavaOperator

  • TruncateJavaOperator

  • SizeJavaOperator

Code shared by these operators exists in a common abstract superclass, AbstractTableOperator. So, for example, the InsertJavaOperator.processTuple method illustrates the use of the corresponding TableAccessor.insert method.

The StreamBase application TableOperator.sbapp includes an instance of each of those seven Java operators, along with related input, output, and error streams, as appropriate.

To demonstrate Java operator input and output, this sample also includes a StreamBase unit test suite, Thus, instead of running the TableOperator.sbapp EventFlow application and enqueuing tuples, you just run the unit test. This starts the TableOperator.sbapp application, populates its Query Table, then runs each of the application's seven Java operators, and reports the results. A solid green bar in the JUnit view indicates a successful run.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter tableacc to narrow the list of options.

  • Select Illustrates methods of the TableAcessor class from the Client Libraries category.

  • Click Import Now.

StreamBase Studio creates a single project containing the sample files.

Running This Sample in StreamBase Studio

Follow these steps:

  1. In the Project Explorer view, open the src/test/java/packageName folder tree to expose the file.

  2. Select, right-click, and from its context menu, select Run As>EventFlow Fragment Unit Test.

    The JUnit view appears and displays the successful execution of the six tests specified in the file.

You can then explore the sample in other ways. For example:

  • Read the source of to see samples of Java operator input and expected output.

  • In the src/main/java/packageName folder, read the sources of the Java operators:*JavaOperator.

  • Run TableOperator.sbapp and interact manually with the operators. Follow these steps:

    1. In the Project Explorer view, double-click to open the TableOperator.sbapp application. Make sure the application is the currently active tab in the EventFlow Editor.

    2. Click the Run button. This opens the SB Test/Debug perspective and starts the module.

    3. In the Manual Input view, select the Insert stream, and send tuples that populate the application's Query Table with values.

    4. Once you have a small set of data in the Query Table, select the other input streams one at a time to manage and manipulate the data in the Query Table.

    5. When done, press F9 or click the Terminate EventFlow Fragment button.

Sample Location

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.