Operator Functor
The Functor operator is used to transform input tuples into output ones, and optionally filter them as in a Filter operator. If you do not filter an input tuple, any incoming tuple results in a tuple on each output port.
Checkpointed data
When the Functor operator is checkpointed, logic state variables (if present) are saved in checkpoint.
Behavior in a consistent region
The Functor operator can be an operator within the reachability graph of a consistent region. It cannot be the start of a consistent region. In a consistent region, a Functor operator stores its state when a checkpoint is taken. When the region is reset, the operator restores the state from the checkpoint.
Checkpointing behavior in an autonomous region
When the Functor operator is in an autonomous region and configured with config checkpoint : periodic(T) clause, a background thread in SPL Runtime checkpoints the operator every T seconds, and such periodic checkpointing activity is asynchronous to tuple processing. Upon restart, the operator restores its state from the last checkpoint.
When the Functor operator is in an autonomous region and configured with config checkpoint : operatorDriven clause, no checkpoint is taken at runtime. Upon restart, the operator restores to its initial state.
Such checkpointing behavior is subject to change in the future.
Windowing
The Functor operator does not accept any window configurations.
Assignments
The Functor operator allows assignments to output attributes. The output tuple attributes whose assignments are not specified are automatically forwarded from the input ones. After the automatic forwarding, the Functor operator expects all output tuple attributes to be completely assigned.
Examples
This example uses the Functor operator.
composite Main {
graph
stream<rstring name, uint32 age, uint64 salary> Beat = Beacon() {}
stream<rstring name, uint32 age, rstring login,
tuple<boolean young, boolean rich> info> Annotated = Functor(Beat)
{
param filter : age >= 18u;
output Annotated : login = lower(name),
info = { young = (age<=30u), rich = (salary>1000000ul) };
}
(stream<rstring name, uint32 age> Age;
stream<rstring name, uint64 salary> Salary) = Functor(Beat)
{
param filter : age >= 18u;
}
}
Summary
- Ports
- This operator has 1 input port and 1 or more output ports.
- Windowing
- This operator does not accept any windowing configurations.
- Parameters
- This operator supports 1 parameter.
Optional: filter
- Metrics
- This operator does not report any metrics.
Properties
- Implementation
- C++
- Threading
- Always - Operator always provides a single threaded execution context.
- Ports (0)
-
The Functor operator is configurable with a single input port, which ingests tuples to be manipulated.
- Properties
-
- Optional: false
- ControlPort: false
- TupleMutationAllowed: false
- WindowingMode: NonWindowed
- WindowPunctuationInputMode: Oblivious
- Assignments
- This operator allows any SPL expression of the correct type to be assigned to output attributes. Attributes not assigned in the output clause will be automatically assigned from the attributes of the input ports that have the same name and type. If there is no such input attribute, an error is reported at compile-time.
- Ports (0)
-
The Functor operator is configurable with one or more output ports. This port produces generated tuples.
- Properties
-
- Optional: false
- TupleMutationAllowed: true
- WindowPunctuationOutputMode: Preserving
- Ports (1...)
-
Additional ports produce generated tuples.
- Properties
-
- TupleMutationAllowed: true
- WindowPunctuationOutputMode: Preserving
Optional: filter
- filter
-
Specifies the condition that determines which input tuples are to be operated on by the Functor operator. It takes a single expression of type boolean as its value. When not specified, it is assumed to be true, that is, tuples are transformed, but no filtering is performed.
- Properties
-
- Type: boolean
- Cardinality: 1
- Optional: true
- ExpressionMode: Expression
- Functor
-
stream<${schema}> ${outputStream} = Functor(${inputStream}) { param filter : ${filterExpression}; output ${outputStream} : ${outputAttribute} = ${value}; }