Create an application graph

You are now ready to construct the application graph and will need the following data for this section:

Parameter Value
Input file /home/streamsadmin/data/all.cars
Output file filtered.cars
File format CSV (both input and output)
Do not use quotation marks around strings on output
Filter condition vehicle ID is “C101” or “C133”
Stream names Observations (before filter)
Filtered (after filter)

 

With this information, you can create the entire application. You will use the graphical editor. There will be no SPL coding in this lab.

Tip for seeing the code: If you want to see SPL code for what you are creating, right-click anywhere in the graphical editor and select Open with SPL Editor.

To drop the operators that you want into the graph, you need to find them in the palette, which is the panel to the left of the canvas.

Operator templates

Some operators appear once in the palette. Others (the ones you will use) have twisties and expand into one or more subentries. These are templates: invocations of the operator with specific settings, for example, a Filter operator with a second output port for rejected tuples. In this lab, the generic version (with the twisty) is always the correct one. Don’t use the templates.

Operator names

The editor generates placeholder names for the operators that you drag onto the canvas. These placeholders include the operator type (“FileSink”) and a sequence number (“1”). The sequence number depends on the order in which the operators are added to the graph, and yours might not match this document. You can safely ignore that. It does not affect anything in the application, and in any case, you will change the generated names later to match the role each operator plays.

Organize layout and maximize in view

To organize the layout, click the Layout button in the editor’s toolbar. To zoom in and use all of the space in the graphical editor canvas, click the Fit to Content button. You can also use the slider in the toolbar to control the zoom level.

Before you add to the graph, reduce some clutter in the palette.

Initially, the list of toolkits is long because it shows all toolkits that Streams Studio knows about. The preconfigured lab workspace includes all toolkits installed with Streams. For now, you will not use any of those toolkits (and you have not declared any dependencies), so it is not helpful to have them in the palette.

  1. In the graphical editor, right-click Toolkits in the palette.
  2. In the context menu, clear Show All Toolkits.
  3. Find the following three operators:
    • FileSource
    • FileSink
    • Filter

    You can filter the palette contents and quickly get the ones you want.

Add operators to the application graph:

  1. In the graphical editor, go to the palette filter field, which shows the word Find, and enter fil. This narrows the palette down to a list that includes the three operators that you need.
    Before you drop an operator: Make sure that the main composite MyMainComposite (and not one of the previously added operators) is highlighted when you drop the next operator. If a Confirm Overwrite dialog appears, click No and try again.
    If you drop the operator on the canvas outside the main composite, the editor creates a new composite (called Comp_1) and places the operator inside. If that happens, undo the change (Ctrl+Z or click Edit > Undo Add Composite with Operator) and try again.
  2. Select each operator with a twisty (one at a time) and drag it into the MyMainComposite main composite. Ensure that the green handles appear before you let go. The editor names the operators FileSink_1, FileSource_2, and Filter_3.