Loop (Concurrency)
Synopsis
This operator loops over the subprocess as often as it is specified in the parameter number of iterations. The iteration macro returns the value of the current number of iteration.Description
The operators in the subprocess are executed as many times as defined in the parameter number of iterations. By default, the input of each iteration will always be the original input data. This can be changed with the reuse results parameter, which changes the output of each iteration to be the input of the next iteration. For obvious reasons, this will limit the loop to run in a single thread and not make use of more CPU cores.
Input
- input (IOObject)
This port receives an IOObject which is passed on to the inner process for each iteration. If the reuse results parameter is selected, all subsequent iterations after the first one will use the results of the output ports of the previous iteration.
Output
- output (IOObject)
This port collects every result that is provided by the inner process. If reuse results is selected, only the result of the last iteration will be returned. Otherwise, a collection of all results of each iteration will be returned. The order of the ports is the same inside and outside the operator.
Parameters
- number_of_iterations The number of iterations specifies how often the subprocess will be executed. Range: integer
- iteration_macro The name of the iteration macro which can be accessed in the subprocess. Range: string
- reuse_results Set whether to reuse the results of each iteration as the input of the next iteration. If set to true, the output of each iteration is used as input for the next iteration. For obvious reasons, this will limit the loop to run in a single thread and not make use of more CPU cores. If set to false, the input of each iteration will be the original input of the loop. Range: boolean
- enable_parallel_execution This parameter enables the parallel execution of the subprocess. Please disable the parallel execution if you run into memory problems. Range: boolean
Tutorial Processes
Using a basic loop
The 'Deals' data set is loaded using the Retrieve operator and supplied to the Loop operator.
Inside the Loop operator, nothing else is done than returning the input as result after waiting for 1 second and adding an attribute based on the current iteration of the loop.
The result of the process is a collection of the results of each iteration.
Reusing results in a loop
The 'Deals' data set is loaded using the Retrieve operator and supplied to the Loop operator.
Inside the Loop operator, nothing else is done than returning the input as result after waiting for 1 second and adding an attribute based on the current iteration of the loop.
The results of each iteration are reused as the input of the next iteration, so the final result of the Loop operator is not a collection of each iteration result, but rather the result of the final iteration.