map
Syntax
- map:
- sub-op 1...
- sub-op 2...
- ...
Description
The map operation works on arrays, applying a separate chain of operations to every element in the array. THe chain of sub-operations does not need to begin with a starting operation like source, and any number of operations can be chained together.
Map can be useful when dealing with some data sources that can provide arrays of data on a single identifier. One example would be for syntheiszing alarm codes when a data source only provides a list of alarm messages.
Examples
- AdapterScript
alarm-codes:
- source: alarm-messages
- map:
- hash: md5
- max-length: 8
In the above example, alarm-messages
is an identifier from another part of the adapter script.
The above example creates a synthesized list of alarm codes that correspond to a list of alarm messages. The map operation is used to apply a chain of two operations to each message. Within that chain, the hash operation creates a reasonably unique string from the message by calculating its MD5 hash. The max-length operation limits the value to 8 characters instead of the full 32 returned by the hash.