@spl.for_each

Toolkits > com.ibm.streamsx.topology 2.1.0 > com.ibm.streamsx.topology.python > Creating SPL Operators from Python code > @spl.for_each

Decorator to create a stateful or stateless SPL sink operator from a Python callable class or function. A sink operator has a single input port and no output ports.

Callable class

When a Python callable class is decorated with @spl.for_each a stateful SPL operator is created with a single input port and no output ports. For each input tuple the __call__ function is called passing the tuple.

If the Python class has instance fields then they are the state of the operator and are private to each invocation of the operator and maintained across calls to its __call__ function.

A for_each operator is oblivious to punctuation.

Function

When a Python function is decorated with @spl.for_each a stateless SPL operator is created with a single input port and no output ports. For each input tuple the function is called passing the tuple.