When the originating Actor's output is a complex object, the iteration's complexity increases due to the object's internal hierarchy of fields and nested arrays. Thus the iteration logic over an object with multiple links is impacted by the answers to the following questions:
This article describes how Broadway performs complex iteration use cases, such as:
If the connected elements of the object are on the same level of hierarchy such as two fields of the same array, the iteration's behavior is the same as an iteration over two or more elements in a result array.
The originating Actor's output can have more than one collection. A common use case is a JSON data structure that contains more than one array. Occasionally there may be a requirement to manage several loops over the same data structure, for example to combine the data from two arrays or to perform other types of data manipulation. In this case, both arrays (or elements in the arrays) must be connected using an Iterate link type to one or more Actors.
The iteration logic is impacted by the answers to the question - do these arrays have the same or a different size? When the arrays have a different size, at some point one array ends and returns a null while another array still has values. To prevent the redundant loops over the empty array, split the flow and create a Stage Condition to check if the array returns a value or a null.
Another recommended way to handle two collections of different sizes is to use Inner Flows. You can pass each array by a value into its respective inner flow and then iterate within each inner flow on the array's values.
When a flow is split into branches and includes an additional split inside the iteration, the split inside the loop is only applicable for the duration of the loop.
The following flow displays an example of a flow that has a split inside the iteration. If Stage 2 is true, its branch will start and execute Stage 5. Then, either Stage 8 or 11 will be executed starting an additional split.
Note that after the loop is completed, both Stage 17 and 18 will run since they depend on Stage 2 and not on the conditions inside the loop.
When the originating Actor's output is a complex object, the iteration's complexity increases due to the object's internal hierarchy of fields and nested arrays. Thus the iteration logic over an object with multiple links is impacted by the answers to the following questions:
This article describes how Broadway performs complex iteration use cases, such as:
If the connected elements of the object are on the same level of hierarchy such as two fields of the same array, the iteration's behavior is the same as an iteration over two or more elements in a result array.
The originating Actor's output can have more than one collection. A common use case is a JSON data structure that contains more than one array. Occasionally there may be a requirement to manage several loops over the same data structure, for example to combine the data from two arrays or to perform other types of data manipulation. In this case, both arrays (or elements in the arrays) must be connected using an Iterate link type to one or more Actors.
The iteration logic is impacted by the answers to the question - do these arrays have the same or a different size? When the arrays have a different size, at some point one array ends and returns a null while another array still has values. To prevent the redundant loops over the empty array, split the flow and create a Stage Condition to check if the array returns a value or a null.
Another recommended way to handle two collections of different sizes is to use Inner Flows. You can pass each array by a value into its respective inner flow and then iterate within each inner flow on the array's values.
When a flow is split into branches and includes an additional split inside the iteration, the split inside the loop is only applicable for the duration of the loop.
The following flow displays an example of a flow that has a split inside the iteration. If Stage 2 is true, its branch will start and execute Stage 5. Then, either Stage 8 or 11 will be executed starting an additional split.
Note that after the loop is completed, both Stage 17 and 18 will run since they depend on Stage 2 and not on the conditions inside the loop.