This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, go to https://wso2.com/documentation/.

Extrema Extension

bottomKLengthBatch

Syntaxextrema:bottomKLengthBatch(Attribute, windowLength, Kvalue)
Extension TypeStreamProcessor
DescriptionbottomKLengthBatch counts the frequency of different values of a specified attribute inside a batch window, and emits the lowest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • windowLength: The length of the window. This should be specified as an integer value.
  • Kvalue: The number of bottom frequencies required. This should be specified as an integer value.
ReturnThe bottom K frequency values are emitted per batch.
Example

define stream inputStream (item string, price long);


info(name = 'query1')

from inputStream#extrema:bottomKLengthBatch(item, 6, 3)

insert all events into outputStream;)

topKLength Batch

Syntaxextrema:topKLengthBatch(Attribute, windowLength, Kvalue)
Extension TypeStreamProcessor
DescriptiontopKLengthBatch counts the frequency of different values of a specified attribute inside a batch window, and emits the highest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • windowLength: The length of the window. This should be specified as an integer value.
  • Kvalue: The number of top frequencies required. This should be specified as an integer value.
ReturnThe top K frequency values are emitted per batch.
Example

define stream inputStream (item string, price long);


info(name = 'query1')

from inputStream#extrema:topKLengthBatch(item, 6, 3)

insert all events into outputStream;)

bottomK

Syntaxextrema:bottomK(Attribute,Kvalue)
Extension TypeStreamProcessor
 bottomK counts the frequency of different values of a specified attribute, and emits the lowest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • Kvalue: The number of bottom frequencies required. This should be specified as an integer value.
ReturnThe bottom K frequency values are emitted. Events are emitted only if there is a change in the bottomK results for each received chunk of events.
Example

define stream inputStream (item string, price long);


info(name = 'query1')

from inputStream#extrema:bottomK(item, 3)

insert all events into outputStream;)

topK

Syntaxextrema:topK(Attribute,Kvalue)
Extension TypeStreamProcessor
DescriptiontopK counts the frequency of different values of a specified attribute, and emits the highest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • Kvalue: The number of top frequencies required. This should be specified as an integer value.
ReturnThe top K frequency values are emitted. Events are emitted only if there is a change in the topK results for each received chunk of events.
Example

define stream inputStream (item string, price long);


info(name = 'query1')

from inputStream#extrema:topK(item, 3)

insert all events into outputStream;)

bottomKTimeBatch

Syntaxextrema:bottomKTimeBatch(Attribute,timeWindow,Kvalue)
Extension TypeStreamProcessor
DescriptionbottomKTimeBatch counts the frequency of different values of a specified attribute inside a time window, and emits the lowest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • timeWindow: The time window during which the frequency should be calculated.
  • Kvalue: The number of bottom frequencies required. This should be specified as an integer value.
ReturnThe bottom K frequency values are emitted. Events are emitted only if there is a change in the bottomK results for each received chunk of events.
Example

define stream inputStream (item string, price long);

from inputStream#extrema:bottomKTimeBatch(item, 1 sec,  3)

insert all events into outputStream;)

topKTimeBatch

Syntaxextrema:topKTimeBatch(Attribute,timeWindow,Kvalue)
Extension TypeStreamProcessor
DescriptiontopKTimeBatch counts the frequency of different values of a specified attribute inside a time window, and emits the highest (k) number of frequency values.
Parameters
  • Attribute: The attribute of which the frequency is counted. The attribute type can be int, long, float, double, string, bool or object.
  • timeWindow: The time window during which the frequency should be calculated.
  • Kvalue: The number of top frequencies required. This should be specified as an integer value.
ReturnThe top K frequency values are emitted. Events are not emitted if there are no changes in the topK results after the last chunk of events received.
Example

define stream inputStream (item string, price long);

from inputStream#extrema:topKTimeBatch(item, 1 sec,  3)

insert all events into outputStream;

maxByLengthBatch

Syntaxwindow.extrema:maxByLengthBatch(Attribute, BatchLength)
Extension TypeStreamProcessor
DescriptionmaxByLengthBatch calculates the maximum value of a specified attribute inside a batch window and emits it.
Parameters
  • Attribute: The attribute of which the maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • BatchLength: The length of the batch involved. This should be specified as an INT value.
ReturnThe event with the maximum value for the given attribute in the specified batch window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:maxByLengthBatch(price, 4) select symbol,price,volume

insert into outputStream ;

minByLengthBatch

Syntaxwindow.extrema:minByLengthBatch(Attribute, BatchLength)
Extension TypeStreamProcessor
DescriptionminByLengthBatch calculates the minimum value of a specified attribute within a batch window and emits it.
Parameters
  • Attribute: The attribute of which the minimum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • BatchLength: The length of the batch involved. This should be specified as an INT value.
ReturnThe event with the minimum value for the given attribute in the specified batch window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:minByLengthBatch(price, 4) select symbol,price,volume

insert into outputStream ;

maxByLength

Syntaxwindow.extrema:minByLength(Attribute, SlidingWindowLength)
Extension TypeStreamProcessor
DescriptionminByLength calculates the maximum value of a specified attribute, and emits it.
Parameters
  • Attribute: The attribute of which the maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • SlidingWindowLength: The length of the sliding window observed. This should be specified as an INT value.
ReturnThe event with the maximum value for the given attribute in the specified sliding window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:maxByLength(price, 4) select symbol,price,volume

insert into outputStream ;

minByLength

Syntaxwindow.extrema:minByLength(Attribute, SlidingWindowLength)
Extension TypeStreamProcessor
DescriptionminByLength calculates the minimum value of a specified attribute and emits it.
Parameters
  • Attribute: The attribute of which the minimum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • SlidingWindowLength: The length of the sliding window observed. This should be specified as an INT value.
ReturnThe event with the minimum value for the given attribute in the specified sliding window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:minByLength(price, 4) select symbol,price,volume

insert into outputStream ;

 

maxByTimeBatch

Syntaxwindow.extrema:maxByTimeBatch(Attribute, TimeBatchLength)
Extension TypeStreamProcessor
DescriptionmaxByTimeBatch calculates the maximum value of a specified attribute within a time window, and emits it.
Parameters
  • Attribute: The attribute of which the maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • TimeBatchLength: The length of the time window observed.
ReturnThe event with the maximum value for the given attribute within the specified time window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:maxByTimeBatch(price, 1 sec) select symbol,price,volume

insert into outputStream ;

 

minByTimeBatch

Syntaxwindow.extrema:minByTimeBatch(Attribute, TimeBatchLength)
Extension TypeStreamProcessor
DescriptionminByTimeBatch calculates the minimum value of a specified attribute within a time window and emits it.
Parameters
  • Attribute: The attribute of which the maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • TimeBatchLength: The length of the time window observed.
ReturnThe event with the minimum value for the given attribute within the specified time window is returned.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:minByTimeBatch(price, 1 sec) select symbol,price,volume

insert into outputStream ;

 

maxByTime

Syntaxwindow.extrema:maxByTime(Attribute, TimeWindowLength)
Extension TypeStreamProcessor
DescriptionmaxByTime calculates the maximum value of a specified attribute within a sliding time window and emits it.
Parameters
  • Attribute: The attribute of which the maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • TimeWindowLength: The length of the sliding time window observed.
ReturnThe event with the maximum value for the given Attribute is returned. This output is updated for every event arrival and expiry during the TimeWindowLength specified.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:maxByTime(price, 1 sec) select symbol,price,volume

insert into outputStream ;

minByTime

Syntaxwindow.extrema:minByTime(Attribute, TimeWindowLength)
Extension TypeStreamProcessor
DescriptionminByTime calculates the minimum value of a specified attribute within a sliding time window and emits it.
Parameters
  • Attribute: The attribute of which the minimum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, LONG or STRING.
  • TimeWindowLength: The length of the sliding time window observed.
ReturnThe event with the minimum value for the given Attribute is returned. This output is updated for every event arrival and expiry during the TimeWindowLength specified.
Example

define stream cseEventStream (symbol string, price float, volume int);

from cseEventStream#window.extrema:maxByTime(price, 1 sec) select symbol,price,volume

insert into outputStream ;

kalmanMinMax

Syntax

extrema:kalmanMinMax(Attribute, Q, R, WindowSize, ExtremaType)

Extension TypeStreamProcessor
DescriptionkalmanMinMax uses the kalman filter to smooth the time series values in the given window size, and then determine the maxima and/or minima of that set of values.
Parameters
  • Attribute: The attribute of which the minimum and/or maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, or LONG.
  • Q: The standard deviation of the process noise.
  • R: The standard deviation of the measurement noise.
  • WindowSize: The length of the window within which the minimum and/or the maximum value for the given window should be identified.
  • ExtremaType: This can be minmax or minmax.
    • min: If this is specified, minimum values are identified within the given window length, and they are returned with min as their extrema type.
    • max: If this is specified, maximum values are identified within the given window length, and they are returned with max as their extrema type.
    • minmax: If this is specified, both minimum and maximum values are identified within the given window length and returned. The extrema type is specified as min for the minimum events, and as max for the maximum events.

ReturnReturns the events with the minimum and/or maximum for the specified attribute within the given window length, with the extrema type as min or max as relevant.
ExampleinputStream#:kalmanMinMax(price, 0.000001,0.0001, 25, 'min') returns the minimum values for a set of price values.

kernalMinMax

Syntax

extrema:kernelMinMax(Attribute, Bandwidth, WindowSize, ExtremaType)

Extension TypeStreamProcessor
DescriptionkernalMinMax uses Gaussian Kernel to smooth the time series values in the given window size, and then determine the maxima and minima of that set of values.
Parameters
  • Attribute: The attribute of which the minimum and/or maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, or LONG.
  • Bandwidth: The bandwidth of the Gaussian Kernel calculation.
  • Window size: The length of the window within which the minimum and/or the maximum value for the given window should be identified.
  • Extrema type: This can be minmax or minmax.
    • min: If this is specified, minimum values are identified within the given window length, and they are returned with min as their extrema type.
    • max: If this is specified, maximum values are identified within the given window length, and they are returned with max as their extrema type.
    • minmax: If this is specified, both minimum and maximum values are identified within the given window length and returned. The extrema type is specified as min for the minimum events, and as max for the maximum events.

ReturnReturns the events with the minimum and/or maximum for the specified attribute within the given window length, with the extrema type as min or max as relevant.
Example

The following returns the maximum values for a set of price values.

from inputStream#timeseries:kernelMinMax(price, 3, 7, ‘max’)

select *
insert into outputStream;

minMax

Syntaxextrema:minMax(Attribute, MaxPreBound, MaxPostBound, PreBoundChange, PostBoundChange, ExtremaType)
Extension Type StreamProcessor
Description

minMax finds the minimum and/or the maximum value within a given length window (maxPreBound+maxPostBound), where following conditions are met.

For minimum:

  • An event where the value for the specified attribute is greater by the percentage specified as the preBoundChange should have arrived prior to the event with the minimum value, within the maxPreBound length window.
  • An event where the value for the specified attribute is greater by the percentage specified as the postBoundChange should have arrived after the event with the minimum value, within the maxPostBound length window.

 

For maximum:

  • An event where the value for the specified attribute is less by the percentage specified as the preBoundChange should have arrived prior to the event with the maximum value, within the maxPreBound length window.
  • An event where the value for the specified attribute is less by the percentage specified as the postBoundChange should have arrived after the event with the maximum value, within the maxPostBound length window.

 

Parameters
  • Attribute: The attribute of which the minimum and/or maximum value is required. The data type of the value for this parameter can be INT, FLOAT, DOUBLE, or LONG.
  • MaxPreBound: The maximum pre window length to be considered (before the min/max event).
  • MaxPostBound: The maximum post window length to be considered (after the min/max event).
  • PreBoundChange: The threshold, pre-bound change percentage.
  • PostBoundChange: The threshold, post-bound change percentage.
  • ExtremaType: This can be min, max or minmax.
    • min: If this is specified, minimum values are identified within the given window length, and they are returned with min as their extrema type.
    • max: If this is specified, maximum values are identified within the given window length, and they are returned with max as their extrema type.
    • minmax: If this is specified, both minimum and maximum values are identified within the given window length and returned. The extrema type is specified as min for the minimum events, and as max for the maximum events.
Return

Returns the events with the minimum and/or maximum for the specified attribute within the given window length, with the extrema type as min or max as relevant. These events are returned with the following additional parameters.

  • preBound: The actual distance between the minimum/maximum value and the threshold value. This value should be within the MaxPreBound window.
  • postBound: The actual distance between the minimum/maximum value and the threshold value. This value should be within the MaxPostBound window.
Example
  • The following returns the maximum values found within a set of price values.

    from inputStream#timeseries:minMax(price, 4, 4, 1, 2, 'max')

    select *

    insert into outputStream; 
     
  • The following returns the minimum values found within a set of price values.

    from inputStream#timeseries:minMax(price, 4, 4, 1, 2, 'min')

    select *

    insert into outputStream; 
     
  • The following returns both the minimum values and the maximum values found within a set of price values.

    from inputStream#timeseries:minMax(price, 4, 4, 1, 2, 'min')

    select *

    insert into outputStream;