...
Remark the difference: This operator blocks only until the end predicate is reached. This works only, if samestarttime is set to true, else e.g. A|4|true|false | META | 1|4 would be A|4|true|false | META | 4|4, this has no validitiy and will not be produced.
Using predicate window to simulate standard windows
The predicate window can be used to simulate other windows. Remark: This is only for demonstration purposes as the element and time window are much faster!
All the following examples use this source:
Code Block |
---|
#PARSER PQL
#RUNQUERY
timer = TIMER({
period = 1000,
source = 'timer'
}
)
ticker := MAP({
expressions = [['counter()','tick'],['TimeInterval.START','TS']]
},
timer
) |
Element Window
Code Block |
---|
#PARSER PQL
#IFSRCNDEF ticker
#INCLUDE ${PROJECTPATH}/TickerSource.qry
#ENDIF
#ADDQUERY
/// Tumbling element window
out = PREDICATEWINDOW({
/// Start window with any element
start = "true",
/// close window, when size of buffer is 5
end = "size(__all)==5",
/// output as list
nesting = true
},
ticker
) |
Code Block |
---|
#PARSER PQL
#IFSRCNDEF ticker
#INCLUDE ${PROJECTPATH}/TickerSource.qry
#ENDIF
#ADDQUERY
/// Sliding element window
out = PREDICATEWINDOW({
/// start window with any element
start = "true",
/// If set to false, end element is not part of result
KEEPENDINGELEMENT = true,
/// end predicate is tested before element is added to window
/// thats why size(__all) must be one below window size!
end = "size(__all)=2",
/// Move window when size of window is 3
ADVANCEWHEN = 'size(__all)=3',
/// move by one position
ADVANCESIZE = 1,
/// output as list
nesting = true
},
ticker
) |
Time Window
Code Block |
---|
#PARSER PQL
#IFSRCNDEF ticker
#INCLUDE ${PROJECTPATH}/TickerSource.qry
#ENDIF
#ADDQUERY
/// Tumbling time window
out = PREDICATEWINDOW({
start = "true",
end = "!isNull(__first.TS) && __first.TS + 10 < TS",
nesting = true
},
ticker
) |