Build Custom Flex Operators to Analyze Event Streams
2020-02-12
Intermediate
20 min.
See how flex operators can be used to apply custom operations to event streams. Use CCL Script to correlate and match events to produce higher-level events. Also implement a flex operator to update a table showing the current status of a set of devices.
You will learn
- How to use the Flex Operator and incoming events to update status information
- How to match and correlate multiple events to produce a single output event
- How to use CCL Script to write an event handler
- How to use a DECLARE block to define data structures
Prerequisites
In this tutorial you will add two Flex operators to your streaming project. Flex operators are custom operators written in CCL Script that give you the ability to do things that you couldn’t do using standard relational SQL operators.
- The first flex operator will be used to record power outages in the SAP HANA database, but the trick is that we don’t want to record individual “power on” and “power off” events in the database. Instead, we prefer to have a single database record for each power outage, with the power-off time, the power-on time, and the duration. So you will use the flex operator to match “power on” events with the earlier “power off” event for the same machine, and then create a single output event with all the information about the power outage.
- The second flex operator will update a window that shows the current status of every machine.
Step 1: Add a flex operator to your project
Step 2: Connect the Flex operator to the event stream
Step 3: Rename it
Step 4: Add columns to define the schema
Step 5: Add a local declaration block
Step 6: Add the event handler script
Step 7: Change the Flex operator to produce an output stream instead of a window
Step 8: Add another Flex operator - this one to track the status of all machines
Step 9: View the complete project in CCL Script
Navigate tutorial steps
-
Step 1: Add a flex operator to your project
-
Step 2: Connect the Flex operator to the event stream
-
Step 3: Rename it
-
Step 4: Add columns to define the schema
-
Step 5: Add a local declaration block
-
Step 6: Add the event handler script
-
Step 7: Change the Flex operator to produce an output stream instead of a window
-
Step 8: Add another Flex operator - this one to track the status of all machines
-
Step 9: View the complete project in CCL Script
- Back to Top