Runtime Schema Cast Operator Sample

About This Sample

The Runtime Schema Cast operator casts its input schema to its configured target output schema at run time. This operator is used in nested modules to expand the subfields within a capture field, either by flattening or nesting the captured subfields. Flattened subfields appear as top-level fields of the target schema, while nested fields appear as subfields of a top-level tuple field whose name matches that of the captured field.

See Using the Runtime Schema Cast Operator for more on possible uses for this operator.

Running This Sample in StreamBase Studio

  1. In the Package Explorer, double-click to open the runtime-cast-example-outer.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 application.

  3. In the Manual Input view, click Send Data to send the default null tuple.

  4. In the Console view, observe the tuples before and after being flattened by the FlattenCaptureFields operator and again after being un-flattened by the UnflattenCaptureFields operator.

    • In the tuple logged by the LogBeforeFlatten operator, the captured fields are displayed as subfields of the InstrumentFields top-level field.

    • In the tuple logged by the LogAfterFlatten operator, the captured fields are displayed as top-level fields.

    • Finally, in the tuple logged by the LogAfterUnflatten operator, the captured fields are displayed once again as subfields of the InstrumentFields top-level field.

  5. Press F9 or click the Stop Running Application button.

Running This Sample in Terminal Windows

This section describes how to run this sample in UNIX terminal windows or Windows command prompt windows.

On Windows, be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not the default command prompt.

  1. Open two terminal windows on UNIX, or two StreamBase Command Prompts on Windows. In each window, navigate to your workspace copy of the sample, as described below.

  2. In window 1, type:

    sbd runtime-cast-example-outer.sbapp
    
  3. In window 2, type:

    echo null | sbc enqueue InputStream
    
  4. Observe in window 1 three log tuples as described in the section on running this sample in StreamBase Studio above.

  5. In window 2, type the following command to terminate the server and dequeuer:

    sbadmin shutdown
    

Importing This Sample into StreamBase Studio

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

  • From the top menu, select FileLoad StreamBase Sample.

  • Type runtime in the search field to narrow the list.

  • From the Data Constructs and Operators category, select Runtime Schema Cast Operator.

  • Click OK.

StreamBase Studio creates a single project containing the sample files.

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.

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 the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:

studio-workspace/sample_runtime-cast-operator

See Default Installation Directories for the location of studio-workspace on your system.

In the default TIBCO StreamBase installation, this sample's files are initially installed in:

streambase-install-dir/sample/sample_runtime-cast-operator

See Default Installation Directories for the location of streambase-install-dir on your system. This location may require administrator privileges for write access, depending on your platform.