I’m fairly new to Aerospike, UDFs, and LUA. However, I can’t get my head around how to solve such an issue where I need to have a context-aware aggregation. Any directions would be amazingly helpful.
Use Case: A click-stream tracking system that allows for the calculation of the minimum, maximum and average visit duration.
Simplified Data Structure:
- session (String): a unique ID
- createdAt (Integer): the timestamp when the tracking happened
How I normally would solve this is by the following steps.
- Group by the session
- Sort the grouped session’s data by createdAt
- Calculate the session’s data by comparing the createdAt of the first and the last session.
- Merge the results from the grouped by session blocks into one global result.
- Calculate the minimum, maximum and average duration
The issue I have right now that I can’t really bring my head around how to implement such a context-aware (session 1 createdAt needs comparison with session 2 createdAt) functionality in a UDF with LUA. Additionally, the grouping of the raw data into session-scopes is giving me a bit of a hard time.
How would you solve such an issue?