Janghwan
02/02/2023, 2:06 AMclass GameEvent {
string userID
int eventType // started, lost, won etc.
string gameID
string eventID
long timestamp
}
More generally, We want to maintain each user’s win count of the last 100 games they played. So for the last 100 “started” games, we need to keep “won” event for the matching gameID.
It is clear to me that the userID will be the key, and timestamp will be the event time field.
But I’m not sure how to model this type of window, and aggregation functions to keep last 100 games and matching “won” events.
Also there can be duplicated events so it should be deduplicated by eventID or a combination of gameID, eventType .
It seems I need to use some sort of custom window functions, but i’m not sure what’s provided out of the box, and what i need to implement by myself.
I appreciate any help.