Simple Remapper
Overview
Simple Remapper is a remapper that, unlike Foreach and similarly to a splitter, generates items on which the blocks of its context then iterates. Each item created by a Simple Remapper block represents a group of consecutive items produced by a previous context, which can be that of a splitter or of another remapper.
Input
The input variables are completely custom and defined as block properties.
When the workflow is executed, the workflow's orchestator prepares an input JSON for the Simple Remapper block that is a JSON object containing an array. The array contains an item for each iteration of the reference context and each item has keys named after the input variables. The values of the keys are the values of the output keys of blocks in the reference context, as established by setting the input properties (see below).
Block properties
The properties of a Simple Remapper block are accessed by editing the block and are divided into these groups:
-
Basic properties:
- Block name
- Component version (read only)
- Block ID (read only)
-
Functional:
- Context to reduce: the reference context producing the data to divide in groups. It is chosen with a drop-down. To remove the choice, select Clear .
- Keep same context: read-only, always off. It's a reminder that Simple Remapper, unlike Foreach, creates it's own, new, context.
-
Remapping strategy: the technique Simple Remapper uses to create groups out of input JSON. It's based on the value of the input variable acting as the input item's category, indicated by the value of the Field name for item category functional property (see below). The strategy can be:
- Begin Marker: a group begins with an item with the category set to literal value Begin.
- Same Category: a group begins with the first item and every time the category changes value, so a group contains all the consecutive items with the same category.
-
Field name for item category: the name of input variable to consider as the category of input items. The category is used to create the groups according to the value of the Remapping strategy property (see above).
- Report items on output: whether or not to include in each output item an
items
array containing the zero-based indexes of all the consecutive input items of the group. - Field name for the output array: name of the array inside each output item containing the data of the grouped input items.
-
Deployment:
- Timeout: execution timeout expressed in minutes (m) or seconds (s).
- Replicas: number of required instances.
- Consumer Number: number of threads of the consumer, the software module of the block that provides input to process by taking it from the block's work queue.
- Memory: required memory.
- CPU: thousandths of a CPU required (for example: 1000 = 1 CPU).
-
Input: these properties determine the input JSON to the block when the workflow is executed. These are the input variables, to be defined, that the block expects to find as keys for each item in the array contained in the input JSON object. Input properties are set by mapping them to the output keys of blocks in the reference context.
It is mandatory to define an input variable that serves as the category of input items. Its value is evaluated by the remapping strategy (see above) to determine when the data to produce one output item ends and the data to produce another begins.
The value of the functional property Field name for item category must therefore be set to the name of this fundamental input variable.-
To define a new input variable:
- Click the plus button: a new row is added below the list of variables.
- In the left field enter the name of the variable.
-
Using the drop-down list, map the variable to the output key of one of the block in the reference context.
First of all select the type choosing between number, string, boolean, object and array. After that, the list below will only show output keys of the same type.
The list is divided in groups, one group for each suitable upstream block. Select the name of the block multiple times or the expand and collapse icons to the right of the block name to show or hide the sub-list of output keys for that block.
If the type of the property is object, the first entry in the sub-list is the block name.This represents the entire JSON object produced by the block, its full output, so it can be mapped only to input variables of type object.
Note
The drop-down list shows all the first-level keys that can, potentially, be available, but the keys that are actually there when executing the workflow may be less. If you map a key that is missing at execution time, the corresponding output key of the Simple Remapper block will be set to
null
.You can filter the list by typing at the top of it: the list will show only keys with matching names.
To cancel the mapping process, select No mapping from the list or, if you already chose a key, select Clear .
-
To modify an existing mapping:
- Edit the left field to change the name of the input variable.
- Use the drop-down as described above to map a different output key.
-
To remove an existing mapping, select Remove to the right of it.
When done, select Confirm.
-
-
Output: read-only, a reminder of the structure of the output objects that are produced.
Output
A Simple Remapper block produces as many output items as the groups determined by the remapping strategy. The block's context then will cycle over these items.
Each output item is a JSON object with the structure displayed in the Output tab of the properties pop-up.
The individual item always contains an array named after the value of the Field name for the output array functional property.
The purpose of this array is to contain the data of all input items that have been recognized as a group. Considering the input JSON passed to the Simple Remapper block, each item in the array corresponds to an item in the input array that is part of a group and has the same keys except for the key that acts as a category, that is as a group discriminant. However, if the remapping strategy is Same Category, then the output object will also contain a top-level key that is the echo of the category input variable.
Finally, if the Report items on output property is on, the output object will contain an items
array with the numeric, zero based, indexes of the items of the array contained in the input JSON that have been grouped in the output object.
So for example, if the input is an object containing an array with 10 items and the remapping strategy determines that the first three are one group, the second two are another group and the last five are another group, the Simple Remapper block will output three objects, one for each group.
Each object will have an array containing the data (except for the category) of all the input items of the group, so three in the first output object. two in the second and five in the third. Optionally, each output object will contain an items
array containing numbers, the indexes of the group item in the input array, so:
"items": [0, 1, 2]
in the first object,
"items": [3, 4]
in the second, and:
"items": [5, 6, 7, 8, 9]
in the third.