How do you partition a request by timestamp?
The first minute goes to the first stream and then the rest goes to a second stream for three hours. Then after The three hours, the first minute goes the first stream and the rest go the second stream.
Thanks
On a high level we can do something like this:
We would need a Siddhi table, where we store a pivot timestamp. We can route events to streams based on this pivot timestamp. Let's call this table:
TimeStampTable(pivotTimestamp long).At each event of
IncomingStream(eventTimestamp long, ..otherAttributes..), we do a join withTimeStampTable, and check if an entry exists atTimeStampTable.eventTimestamptoTimeStampTable. This is going to function as the pivot timestamp. Get0astimeDiff.eventTimestamp - pivotTimestampastimeDiff.Based on
timeDiff, put a label to each event (basically add a string attribute and pass it to the next stream). I.e,WITHIN_FIRST_MINUTE, andWITHIN_THREE_HOURS.Route events to appropriate streams based on the above label.
At step (2.B), if
timeDiff >= 3 hours, replacepivotTimestampwith the current timestamp.