Operator Filter

Primitive operator image not displayed. Problem loading file: ../../image/tk$spl/op$spl.relational$Filter.svg

The Filter operator removes tuples from a stream by passing along only those tuples that satisfy a user-specified condition. Non-matching tuples can be sent to a second optional output.

Checkpointed data

When the Filter operator is checkpointed, logic state variables (if present) are saved in checkpoint.

Behavior in a consistent region

The Filter 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 Filter 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 Filter 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 Filter 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 Filter operator does not accept any window configurations.

Assignments

The Filter operator does not allow assignments to output attributes. The output tuple attributes are automatically forwarded from the input ones.

Examples

This example uses the Filter operator.


composite Main {                                                      
   graph                                                               
    stream<rstring name, uint32 age> Beat = Beacon() {}               
    stream<rstring name, uint32 age> Youngs = Filter(Beat)            
    {                                                                 
      param filter : age < 30u;                                       
    }                                                                 
    (stream<Beat> Younger; stream<Beat> Older) = Filter(Beat)         
    {                                                                 
      param filter : age < 30u;                                       
    }                                                                 
}

Summary

Ports
This operator has 1 input port and 2 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.

Input Ports

Ports (0)

The Filter operator is configurable with a single inport port that ingests tuples to be filtered.

Properties

Output Ports

Assignments
This operator does not allow assignments to output attributes.
Ports (0)

The Filter operator is configurable with one or two output ports. This first output port is mandatory.

The Filter operator requires that the stream type of the output port matches the stream type of the input port. This output port receives the tuples that match the filter expression.

Properties

Ports (1)

The Filter operator is configurable with one or two output ports. This second output port is optional.

The Filter operator requires that the stream type of the output port matches the stream type of the input port. This output port, if present, receives the tuples that fail to match the filter expression.

Properties

Parameters

This operator supports 1 parameter.

Optional: filter

filter

Specifies that the condition that determines the tuples to be passed along by the Filter operator. It takes a single expression of type boolean as its value. When not specified, it is assumed to be true.

Properties

Code Templates

Filter

stream<${inputStream}> ${streamName} = Filter(${inputStream}){
            param 
                filter: ${filterExpression};
        }
      

Filter with Two Output Streams

(stream<${inputStream}> ${matchedStream}; stream<${inputStream}> ${unmatchedStream}) = Filter(${inputStream}) {
            param filter: ${filterExpression};
        }