Getting Started with Streaming Analytics
Also available as:
PDF
loading table of contents...

Transforming Data using a Projection Processor

It is common to do transformations on the events in the stream. In our case, before we alert on the speeding driver, we want to convert the average speed we calculated in the aggregate processor into a integer from a double so it is easier to display in the alert. The projection processor allows you to do these transformations.

  1. Drag the Projection processor onto the canvas and connect to it to the IsDriverSpeeding Rule processor:

  2. When you double-click on the projection processor, you see a number of out-of-the-box functions, however a Round function does not exist.

  3. Adding UDFs (User Defined Functions) is easy to do within SAM. Follow the below steps to add Round UDF function to SAM.
    1. From the left-hand menu, click Configuration, then Application Resources.
    2. Select the UDF tab and click the + sign to create the ROUND UDF. The jar for this UDF can be downloaded from here, located in the custom-udf folder. The simple java class used to implement this Round function using the SAM SDK can be found here. Unzip the downloaded artifact and use the jar called sam-custom-udf-0.0.5.jar. Configure the UDF with the following values:

    3. After uploading the UDF, you should see the new Round UDF created.

  4. After creating the UDF, go back to your Application and double-click Projection Processor you added to the canvas. You will see ROUND_AUTOCREATE in the FUNCTION drop down list.
  5. Configure the ROUND_AUTOCREATE function as the following: