I have a log file composed of "Events", "Time", "UserId".
+------------+----------------+---------+
| Events | Time | UserId |
+------------+----------------+---------+
| ClickA | 7/6/16 10:00am | userA |
+------------+----------------+---------+
| ClickB | 7/6/16 12:00am | userA |
+------------+----------------+---------+
I would like, for each users, to compute the average time between events. How do you guys solve this problem? In a traditional programming environment I would go through each events for an user and calculate the time delta between events n and n-1, adding this value to an array A. I would then compute the average for each value in A. How can I do this with Spark?