This unit is a Processor unit type.
A unit that transforms an event containing a list into a sequence of events containing successive list items. This can be done simultaneously over several lists (producing a zip, not a cartesian product).
You specify fields in the input event containing lists to be detached and transformed into individual values in the output events.
An event comes in through the in port. The init port emits a signal stream to indicate the start of a list.
The unit processes and transforms the lists into individual values. The end port emits a signal stream to indicate the end of a list.
If some of the specified fields are not present or don't have the correct type, the event is sent to the malformed output port.
Successful N output events are sent to the out port, N being the max length of lists. Each of these events will contain "a slice" of original lists at a growing index. For lists shorter than the longest one, corresponding values will be null.
After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:
|General||Name||Enter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.|
|Fields||Click the plus icon to add fields containing lists.|
|Name||Enter the name of the field in the input event containing a list.|
|Array||Whether collection type is Array (true) or Collection (false).|
|Component type||Class of collection/array items. Enter a java class qualified name.|
|in||All events enter through this port. They must contain fields specified in settings, and comply with the specified type.|
|init||Signal stream that indicates the start of a list.|
|out||Outputs the events containing the same fields as input events, but with single values instead of lists.|
|end||Signal stream that indicates the end of a list.|
|malformed||Outputs input events that don't have the specified fields or type.|
Imagine you wish to view a list as a sequence of events.
You can use the Detacher unit to transform events containing a list into a sequence of events containing successive list items. To do it, we add a Tick unit to fire the request every time we need it. Then, connect it to the Detacher unit through its in input port. Finally, we can send the events to Devo by connecting the Detacher out output port to a Devo Sink unit.
In the Tick unit properties, set the fields to transform in the Fields tab.
In the Detacher unit properties, you must specify whether to detach lists, arrays, or sets. Here we will choose Array.
In the Devo Sink unit properties, send the events to a my.app table and choose the Array field.
You can try this flow by downloading this JSON file and uploading it to your domain using the Import option.