Operator Gate
The Gate operator is used to control the rate at which tuples are passed through. Each tuple that passes through Gate must be acknowledged by a downstream operator to allow more tuples through.
Checkpointed data
The Gate operator does not support checkpointing.
Behavior in a consistent region
The Gate operator is not supported in a consistent region.
Checkpointing in an autonomous region
When the Gate operator is in an autonomous region and configured with config checkpoint : periodic(T) clause, no checkpoint is taken at runtime. Upon restart, the operator restores to its initial state.
When the Gate 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.
Examples
This example uses the Gate operator.
composite Main {
graph
stream<rstring name, uint32 age> Data = Beacon() {}
stream<Data> Gated = Gate(Data; Control)
{
param maxUnackedTupleCount : 1u; // allow only 1 tuple to go through at a time
numTuplesToAck : Control.count; // acknowledge given number of tuples
}
(stream<Data> Output; stream<uint32 count> Control) = Custom(Gated)
{
logic onTuple Gated:
{
println (Gated); // do some processing
submit(Gated, Output); // pass it on to the output
submit({count = 1u}, Control); // tell gate to allow another tuple
}
// no more than 1 tuple will be queued up at any time
config threadedPort : queue(Gated, Sys.Wait);
}
}
Summary
- Ports
- This operator has 2 input ports and 1 output port.
- Windowing
- This operator does not accept any windowing configurations.
- Parameters
- This operator supports 2 parameters.
Required: maxUnackedTupleCount
Optional: numTuplesToAck
- Metrics
- This operator does not report any metrics.
Properties
- Implementation
- C++
- Threading
- Always - Operator always provides a single threaded execution context.
- Ports (0)
-
The Gate operator has two input ports. The first port is the data port and holds the tuples to be gated.
- Properties
-
- Optional: false
- ControlPort: false
- TupleMutationAllowed: false
- WindowingMode: NonWindowed
- WindowPunctuationInputMode: Oblivious
- Ports (1)
-
The second input port is the control port and is used to acknowledge data tuples.
- Properties
-
- Optional: false
- ControlPort: true
- TupleMutationAllowed: false
- WindowingMode: NonWindowed
- WindowPunctuationInputMode: Oblivious
- Assignments
- This operator does not allow assignments to output attributes.
- Ports (0)
-
The Gate operator is configurable with a single output port, which produces the gated tuples. The schema of the output port must match that of the first input port.
- Properties
-
- Optional: false
- TupleMutationAllowed: false
- WindowPunctuationOutputMode: Preserving
Required: maxUnackedTupleCount
Optional: numTuplesToAck
- maxUnackedTupleCount
-
Specifies the maximum number of tuples that are allowed through the Gate operator before they are acknowledged.
- Properties
-
- Cardinality: 1
- Optional: false
- ExpressionMode: AttributeFree
- numTuplesToAck
-
Specifies the number of tuples to acknowledge for each control stream tuple that is received. If this parameter is not specified, the default value is 1u.
- Properties
-
- Cardinality: 1
- Optional: true
- ExpressionMode: Expression
- PortScope: 1
- Gate
-
stream<${schema}> ${outputStream} = Gate(${dataStream};${controlStream}) { param maxUnackedTupleCount: ${numAllowedThru}; }