Skip to main content

kslack (Stream Processor)

Stream processor performs reordering of out-of-order events using K-Slack algorithm.


reorder:kslack(<LONG> timestamp)
reorder:kslack(<LONG> timestamp, <LONG> timeout)
reorder:kslack(<LONG> timestamp, <BOOL> discard.late.arrival)
reorder:kslack(<LONG> timestamp, <LONG> timeout, <LONG> max.k)
reorder:kslack(<LONG> timestamp, <LONG> timeout, <BOOL> discard.late.arrival)
reorder:kslack(<LONG> timestamp, <LONG> timeout, <LONG> max.k, <BOOL> discard.late.arrival)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
timestampThe event timestamp on which the events should be ordered.LONGNoYes
timeoutA timeout value in milliseconds, where the buffered events who are older than the given timeout period get flushed every second.-1 (timeout is infinite)LONGYesNo
max.kThe maximum K-Slack window threshold (K parameter).9,223,372,036,854,775,807 (The maximum Long value)LONGYesNo
discard.late.arrivalIf set to true the processor would discarded the out-of-order events arriving later than the K-Slack window, and in otherwise it allows the late arrivals to proceed.falseBOOLYesNo

Example 1

CREATE STREAM StockStream (eventTime long, symbol string, volume long);

@info(name = 'kslackReorderingQuery')
INSERT INTO OutputStream
SELECT eventTime, symbol, volume
FROM StockStream#reorder:kslack(eventTime, 5000);

The kslackReorderingQuery processes stock events from the StockStream and outputs the reordered events to the OutputStream.

The #reorder:kslack(eventTime, 5000) part of the query is an event reordering extension. It reorders events based on the eventTime attribute value and forcefully flushes all events that have arrived older than the given timeout value (in this case, 5000 milliseconds or 5 seconds) every second.

The query's output includes the eventTime, symbol, and volume of the reordered events. The result is then directed to the OutputStream.