The task of the “Hourly Tips” exercise is to identify, for each hour, the driver earning the most tips. It’s easiest to approach this in two steps: first use hour-long windows that compute the total tips for each driver during the hour, and then from that stream of window results, find the driver with the maximum tip total for each hour.
Please note that the program should operate in event time.
The input data of this exercise is a stream of
TaxiFare events generated by the Taxi Fare Stream Source.
TaxiFareSource annotates the generated
DataStream<TaxiFare> with timestamps and watermarks. Hence, there is no need to provide a custom timestamp and watermark assigner in order to correctly use event time.
The result of this exercise is a data stream of
Tuple3<Long, Long, Float> records, one for each hour. Each hourly record should contain the timestamp at the end of the hour, the driverId of the driver earning the most in tips during that hour, and the actual total of their tips.
The resulting stream should be printed to standard out.
- Java: com.dataartisans.flinktraining.exercises.datastream_java.windows.HourlyTipsExercise
- Scala: com.dataartisans.flinktraining.exercises.datastream_scala.windows.HourlyTipsExercise
Reference solutions are available at GitHub: