The latest version for DAS is WSO2 Data Analytics Server 3.1.0. View documentation for the latest release.
WSO2 Data Analytics Server is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

Reorder extension is implemented using the K-Slack algorithm. The K-Slack Siddhi extension is used for reordering events from an unordered event stream. The following is an example of a query with the reorder extension.


@info(name = 'query1') 
from inputStream#reorder:kslack(eventTimestamp) 
select eventTimestamp, price, volume 
insert into outputStream;

There are several important variations of the K-slack API of which the details are described below

K-Slack function


<bool> reorder:kslack(<long> timestamp)

Extension TypeStreamProcessor
DescriptionThis is the most basic version. The events are sorted by the  timestamp  parameter.

<bool> reorder:kslack(<long> timestamp, <long> timeOut )

Extension TypeStreamProcessor
DescriptionThe second argument shown in the above syntax corresponds to a fixed time-out value set at the beginning of the process. Once the time-out value expires, the extension drains all the events that are buffered within the reorder extension to outside. The time out has been implemented internally using a timer. The events buffered within the extension are released each time the timer ticks.
<bool> reorder:kslack(<long> timestamp, <long> timeOut, <long> maxValue )
Extension TypeStreamProcessor
DescriptionThe third argument in the above syntax is the maximum value for K. This is the amount to which the K value of the K-Slack algorithm will be increased.
  • kslack(timestamp, -1l, 1000000)
    In the above example, the algorithm execution starts when K=0 and it gets increased up to 1000000. The value of the K-slack does not increase from that point onwards. Hence, this leads to lower latency compared to the version shown in the first (i.e., single parameter) example of this list. Note that the second argument is set to -1l which effectively disables the timer based draining of the internal buffer.
  • kslack(timestamp, 1000l, 1000000)
    The above is another variation of the third category. Here, a time-out value is specified for the second argument (i.e. 1000 ms). In this case, the K-slack algorithm buffers events until the 1000ms time period expires. The maximum K value is 1000000. The K-value cannot exceed the specified amount.


<bool>  reorder:kslack (<long> timestamp, <long> timeOut, <bool> expireFlag )

Extension TypeStreamProcessor
DescriptionThe fourth argument in the above syntax is a flag that indicates whether the out-of order events that appear after the expiration of the K-slack window should be discarded or not.
Examplekslack(timestamp, -1l, true)
  • No labels