Transformations
Transformations are pre-defined generalized workers applicable for various purposes. They function as compact helper functions embedded within a component, facilitating data transformations and performing other useful tasks. The existing list of transformations includes:
-
UnpackNamed: Unwraps an encapsulated object; for instance, if we have
Just a
, then the transformation will yielda
.Example:
BoundingBox
->{class:DetectedClass,rectangle:Rectangle<Double>}
-
PackNamed: Takes
a
and encapsulates it into a named type, for example froma
toJust a
.Example:
{class:DetectedClass,rectangle:Rectangle<Double>}
->BoundingBox
-
UnpackTuple: Unwraps a stream of tuples, returning all its elements into separate streams
($ts...) -> $ts...
.Example:
(Segmentation, BoundingBox)
->Segmentation
andBoundingBox
-
PackTuple: Encapsulates a stream of tuple elements into a stream of tuples
$ts... -> ($ts...)
.Example:
Segmentation
andBoundingBox
->(Segmentation, BoundingBox)
-
UnpackRecord: Unpacks a record type into separate stream outputs. Behaves just like tuple except has field names instead of indexed types.
Example 1:
{class:DetectedClass,rectangle:Rectangle<Double>}
->DetectedClass
andRectangle<Double>
Example 2:
{class:DetectedClass, rectangle:Rectangle<Double>, counter:UInt64}
->DetectedClass
,Rectangle<Double>
andUInt64
-
PackRecord: Packs streams inputs into a single stream of records.
Example:
DetectedClass
,Rectangle<Double>
andUInt64
->{class:DetectedClass, rectangle:Rectangle<Double>, counter:UInt64}
-
UnpackUnion: Splits stream of unions into separate streams for every union option.
Example:
Image.BGR | Image.GRAY | Image.RGB
->Image.BGR
,Image.GRAY
,Image.RGB
-
PackUnion: Packs input streams into a stream of unions
Example:
Image.BGR
,Image.GRAY
,Image.RGB
->Image.BGR | Image.GRAY | Image.RGB
-
Constant: Streams exactly one pre-defined value given as a parameter.
-
DelayByOne: Delays the stream by one message, initially streaming a pre-defined value provided as a parameter.
Example: If the streamed message is
1
and predefined value is0
; then DelayByOne outputs0
as the first message and1
as second. -
ConvertValue: Takes an atomic type and converts another atomic type. Convertion is done according to C++ rules for corresponding fundamental types. (
a -> b
)Example:
Int32 -> Double
Input:
1
Output:
1.0
-
Flatten: Takes a list and streams the elements within that list
[a] -> a
.Example:
[Int32]
->Int32
Input:
[0, 1, 2, 3, 4]
Output:
0, 1, 2, 3, 4
-
Filter: Takes two values, a boolean and another value, and returns nothing if the boolean is false; otherwise, it returns that value (
Bool, t -> t
)Example: If inputs are
true
and1
returns1
. If inputs arefalse
and1
then no messages will be sent. -
Repeat: Takes two inputs, first input is of type
UInt64
and has valuex
and the second input is a steam of any type. The transformation streams message of second inputx
many times.Example: If
x
is set to 5, the value1
will be streamed 5 times.Input 1:
5
Input 2:
["this is a message"]
Output:
["this is a message"], ["this is a message"], ["this is a message"], ["this is a message"], ["this is a message"]
-
Length: Takes a list and returns its size (
[t] -> UInt64
).Example:
Input:
[0, 1, 2, 3, 4]
Output:
5
-
UniteStreams: Takes a number of streams and combines them into a single stream (
t... -> t
). -
SelectStreams: Takes a number of streams and an index and streams a value from the stream selected by the index (
UInt64, t... -> t
). -
Shuffle: Takes a list of pairs and combines the pairs with the same key (
[(K, V)] -> [(K, [V])]
). -
Join: Functions as the SQL join operation (
[(K, V1)], [(K, V2)] -> [(K, V1, V2)]
). -
LiftUnroll: Takes a list and outputs its size and streams its each elements as a separate Message.
Example:
Input:
[0, 1, 2, 3, 4]
Output 1:
5
Output 2:
0, 1, 2, 3, 4
-
LiftReroll: Takes the streamed elements and puts them into a list, first input is the size of the list.
Example:
Input 1:
2, 3, 5
Input 2:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Output:
[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]