Blogs

Streams Application Development: A Graph is Worth a 1000 Lines of Code

Can you tell that this:

 

Is the same as this:

This is a very simple application, and I still had to shrink the source code down to fit on the page.

What do you think is easier: typing in a few hundred characters or dragging a box onto a graph and dragging lines to connect it up? Do you know all the syntax and semantic rules for IBM InfoSphere Streams? The graphical editor does and can generate code for you.

For application development, InfoSphere Streams 3.0, provides a graphical editor that makes programming Streams applications simpler. You no longer have to mentally map your application code into a directed flow graph. The Streams graphical editor does it for you. You can then work directly with this graph to create and modify your application.

Using the graphical editor to create an application is as simple as:

  1. Add your operators to the graph
  2. Connect your operators
  3. Define the connection schemas
  4. Fill in the operator parameter

The graphical editor will generate the SPL code for you.

To add operators to your application, you simply select them from the palette of available operators, drag the operator to the position you want in the graph and drop it. To connect the operator to other operators, you select the output port of an operator and drag a connection to the input port of an operator. That is all you need to do to connect your operators into a Streams application.

Now that you have the operators and connections created in the graph, you need to: define the connection (stream) schemas, provide any operator parameters and fill in any logic needed.

To define the schemas you can either: drag an existing type from the palette and drop it on a connection, copy an existing connection’s schema and paste it or select a connection and bring up a simple wizard to define the stream’s schema. The graphical editor will generate all the required code for you.

To provide operator details (parameters, logic, etc…) select the operator and bring up a properties dialog that provides simple, specialized wizards to fill in the operator’s details.

The parameters wizard allows you to select the parameters from a list of the operator’s parameters, and then provide a value. Any logic required can be provided in the logic clause wizard, which is a fully functional SPL text editor.

The graphical editor will generate SPL code, and the resultant file is saved as an SPL file. This provides round-trip support, and you can use both the graphical editor and the SPL text editor together from a single source file.

Watch the short video below, which shows how simple it is to modify an existing Streams application using the graphical editor. You can try this using the Vwap sample application and adding in a Filter and FileSink operator.