Filtering
Operations that output a subset of their input items.
Drop
Drop<type>(n)
Drop(n)
Output all input items except the first n
Take
Take<type>(n)
Take(n)
Output only the first n
input items.
Dedup
Dedup<type>()
Dedup()
Output every input item that is not equal to the previous input item.
Dedup (expiring)
Dedup<type>()
Dedup()
Output the input item if it is not equal to the previous input or it has been more than milli
milliseconds since the last output.
Debounce
Debounce<type>(millis)
Debounce(millis)
Outputs each input after millis
milliseconds if no other input has been received.
Throttle
Throttle<type>(millis)
Throttle(millis)
Rate limits the input stream to average at most one value per millis
milliseconds. It functions by outputing the first input received (if any) in successive windows of millis
milliseconds.
Sample
Sample<type>(millis)
Sample(millis)
Generates a stream of values with the latest value from its input stream every millis
milliseconds.
Over
Over<type>(threshold)
Over(threshold)
Output only input items greater than threshold
.
Under
Under<type>(threshold)
Under(threshold)
Output only input items less than threshold
.
AtLeast
AtLeast<type>(threshold)
AtLeast(threshold)
Output only input items greater than or equal to threshold
.
AtMost
AtMost<type>(threshold)
AtMost(threshold)
Output only input items less than or equal to threshold
.
Positive
Positive<type>()
Positive()
Output only input items that are greater than 0.
Negative
Negative<type>()
Negative()
Output only input items that are less than 0.
Zero
Zero<type>()
Zero()
Output only input items that are less than 0.
True
True<type>()
True()
Output only input items equal to true.
False
False<type>()
False()
Output only input items equal to false.
Filter
Filter<type>(function)
Filter(function)
For each input item, apply the given function and output the input if the function returns true.
Transformation
Operations that transforms each input item to produce an output item.
Const
Const<in-type,out-type>(value)
Const(value)
For each input item, output value
.
Abs
Abs<type>()
Abs()
For each input item, output it's absolute value.
Scale
Scale<type>(k)
Scale(k)
For each input item, output k
× input value.
Add
Add<type>(b)
Add(b)
For each input item, output b
+ input value.
Clamp
Clamp<type>(lo, hi)
Clamp(lo, hi)
For each input item, output lo
if the input is less than lo
, hi
if the input more than hi
, or the input value if it is between lo
and hi
.
ClampLow
ClampLow<type>(lo)
ClampLow(lo)
For each input item, output the maximum of the input value or lo
.
ClampHigh
ClampHigh<type>(hi)
ClampHigh(hi)
For each input item, output the minimum of the input value or hi
.
IsOver
IsOver<type>(threshold)
IsOver(threshold)
Output true for each input item greater than threshold
otherwise false.
IsUnder
IsUnder<type>(threshold)
IsUnder(threshold)
Output true for each input item less than threshold
otherwise false.
IsAtLeast
IsAtLeast<type>(threshold)
IsAtLeast(threshold)
Output true for each input item greater than or equal to threshold
otherwise false.
IsAtMost
IsAtMost<type>(threshold)
IsAtMost(threshold)
Output true for each input item less than or equal to threshold
otherwise false.
IsPositive
IsPositive<type>()
IsPositive()
Output true for each input item that is greater than 0 otherwise false.
IsNegative
IsNegative<type>()
IsNegative()
Output true for each input item that is less than 0 otherwise false.
IsZero
IsZero<type>()
IsZero()
Output true for each input item that is less than 0 otherwise false.
Toggle
Toggle<in-type,out-type>(initial)
Toggle(initial)
On the first input, output ! initial
and thereafter output ! previous output.
Project1
Project1<type>()
Project1()
For each tuple input item, output the 1st element of the tuple
Project2
Project2<type>()
Project2()
For each tuple input item, output the 2nd element of the tuple
Project3
Project3<type>()
Project3()
For each tuple input item, output the 3rd element of the tuple
Counted
Counted<in-type,counter-type>()
Counted()
For each tuple input item, output a tuple with the input item and total number of inputs seen.
Map
Map<in-type,out-type>(function)
Map(function)
For each tuple input item, apply the given function
to the input and output the returned value.
The signature of function is
out-type function(const in-type&)
Map (no copy)
Map<in-type,out-type>(function)
N/A
For each tuple input item, call the given function
with the input and result and output the result.
The signature of function is
void function(const in-type&, out-type&)
Scan
Scan<in-type,state-type>(function, init)
Scan(function, init)
The scan operator keeps a state of state-type
which is initially init
. For each input item, the given function
is called with the input item and the current state as arguments. The returned value is output and becomes the new state.
The function signature of the update function is
state-type update(const in-type&, const state-type&)
Scan (no copy)
Scan<in-type,state-type>(update, init)
N/A
The scan operator keeps a state of state-type
which is initialized by init
function (optional). For each input item, the given update
function is called with the input item and the current state as arguments. The update can modify the state argument and the new state is the output of the operator.
The function signature of the update function is
void update(const in-type&, state-type&)
and the function signature of the init funciton is
void init(state-type&)
Aggregation
Operators that aggregate or summarize information from multiple items in output items.
Count
Count<type>()
Count()
For each item received, output the total number of items received since the start.
WinSum
WinSum<type,width>()
WinSum(width)
Outputs the sum of a width
size sliding window over the input stream.
SumOf
SumOf<type,count>()
SumOf(count)
Outputs the sum of each batch of count
input items.
SumOver
SumOver<type>(millis)
SumOver(millis)
Outputs the sum of each batch of input items received over millis
milliseconds.
WinAverage
WinAverage<type,width>()
WinAverage(width)
Outputs the average of a width
size sliding window over the input stream.
AverageOf
AverageOf<type,count>()
AverageOf(count)
Outputs the average of each batch of count
input items.
AverageOver
AverageOver<type>(millis)
AverageOver(millis)
Outputs the average of each batch of input items received over millis
milliseconds.
WinMin
WinMin<type,width>()
WinMin(width)
Outputs the minimum of a width
size sliding window over the input stream.
MinOf
MinOf<type,count>()
MinOf(count)
Outputs the minimum of each batch of count
input items.
MinOver
MinOver<type>(millis)
MinOver(millis)
Outputs the minimum of each batch of input items received over millis
milliseconds.
WinMax
WinMax<type,width>()
WinMax(width)
Outputs the maximum of a width
size sliding window over the input stream.
MaxOf
MaxOf<type,count>()
MaxOf(count)
Outputs the maximum of each batch of count
input items.
MaxOver
MaxOver<type>(millis)
MaxOver(millis)
Outputs the maximum of each batch of input items received over millis
milliseconds.
String operators
Lines
Lines()
N/A
Output a stream of lines (strbuf class) from an input stream of characters (char).
Format
Format<type>(format)
N/A
Build a formatted string from input items using the format
template. Any occurrence of $1
in the template is replaced by the input value. Occurrences of $t
are replaced by the current time as a Unix timestamp (number of seconds since Jan. 1, 1970).
Split
Split<max-fields>(delimiter)
Split()
Splits each input string at the given delimiter
and outputs the resulting strings in a vector. The C++ types are strbuf
input and Vec<strbuf,max-fields>
output.
ToString
ToString<input-type>()
ToString()
Converts the input values to a string and outputs it as a strbuf
ToJson
ToJson<input-type>()
ToJson()
Converts the input values to a JSON string and outputs it as a jsons
Miscellaneous
Iterate
Iterate<type>(millis, repeat)
Iterate(millis, repeat)
Generates a stream of values from a generator (e.g. Range
). The values are generated one every millis
milliseconds. If repeat
is true then the iterater will start over with the 1st value after it reaches the last. The millis and repeat parameters are optional with defaults 0 and false respectively.
Poll
Poll<type>(millis)
Poll(millis)
Generates a stream of values from an input by polling the current value every millis
milliseconds.
Build
Build<in-type,state-type,result-type>(function, init)
N/A
This operator replaces the scan -> filter -> map pattern with a single operator and also only allocates one result object at creation time. The operator keeps a state of state-type
which is initially init
. For each input item, the given function
is called with the input item and the current state and result as reference arguments. If the function returns true, the current value of result is output otherwise nothing is output.