Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 5. Streams Processing Language > Example Streams program - Pg. 259

5.5 Example Streams program In this section, we describe a Streams Processing Language example that you could compile and run. The infamous Hello World example program is widely accepted as originating from the book The C Programming Language by Kernighan and Ritchie, first published in 1978. The scenario given is that your first program in a new programming language should do something simple, such as output a message that says "Hello World". The benefit is that to achieve this, the developer must: Have gained access to a development environment Have accessed the compiler and a properly installed development and runtime environment for the programming language concerned Know how to use a compatible language editor Be able to compile and run the software If the program successfully runs the simple Hello World code, the developer then knows the steps taken, as well as the environment, are, at a basic level, good to use going forward to use to build more and more complex programs. In Example 5-37, the program uses the SPL Beacon operator to generate five tuples filled with its single rstring-typed attribute, set to the string value of "Hello World". If the program runs correctly, these Beacon-generated tuples will be received by a custom operator and displayed on the console along with the "Hello World" message(s). Example 5-37 Hello World example /* This example is the simplest possible SPL application. It uses a Beacon operator to generate tuples that carry "Hello World" messages. A custom sink operator receives the tuples from Beacon and displays it on the console. */ composite HelloWorld { graph stream <rstring message> Hi = Beacon() { param iterations: 5u; output Hi: message = "Hello World!"; Chapter 5. Streams Processing Language 259