From the course: Apache Flink: Real-Time Data Engineering
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Computing activity durations - Flink Tutorial
From the course: Apache Flink: Real-Time Data Engineering
Computing activity durations
- In this video, I will show you how to compute durations, based on an event stream. Events happen at various points in time. To compute durations, we need to track the previous events timestamp, and use it to compute the duration, when the next event arrives. We also need to track the previous events name, since the duration would correspond to that event. This requires the use of state variables. In this case, we want to track activity durations by each user. So, we first do a key by of the user to create state by user. Next, we use a Rich Map Function. In the function, we create two state variables, last event name and last event start timestamp. These will then be used to track the action and timestamp that comes for the specific user. In the open method, we set up the value descriptors, for both the state variables and initialize those values. In the Map Function, we will always ignore the log and event, since…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.