Skip to main content

kslack (Stream Processor)

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

Syntax

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 = 'query1')
insert into OutputStream
select eventTime, symbol, volume
from StockStream#reorder:kslack(eventTime, 5000);

The query reorders events based on the eventTime attribute value, and it forcefully flushes all the events who have arrived older than the given timeout value (5000 milliseconds) every second.