Map
Short Description
Map manipulates record’s structure or content. This component was formerly called Reformat.
Map
-
x
1
1-N
✓
✓
✓
Ports
Input
0
✓
For input data records
Any(In0)
Output
0
✓
For transformed data records
Any(Out0)
1-n
x
For transformed data records
Any(OutPortNo)
This component has one input port and at least one output port.
The component can send different records to different output ports or even send the same data record to more output ports.
Metadata
Map propagates metadata from the input port to the output port (from left to right), but it does not propagate metadata from the output port to the input port (from right to left). Metadata propagation through Map has low priority.
Map Attributes
BASIC
Transform
[1]
The definition of how records should be mapped. Written in the graph source either in CTL or in Java.
Transform URL
[1]
The name of the external file, including the path, containing the definition of the way how records should be mapped; written in CTL or Java.
Transform class
[1]
The name of an external class defining the way how records should be mapped.
Transform source charset
Encoding of external file defining the transformation. The default encoding depends on DEFAULT_SOURCE_CODE_CHARSET in defaultProperties.
E.g. UTF-8
DEPRECATED
Error actions
The definition of an action that should be performed when the specified transformation returns an Error code. See Return Values of Transformations.
Error log
The URL of the file to which error messages for specified Error actions should be written. If not set, they are written to Console.
[1] One of these must be specified. Any of these transformation attributes uses a CTL template for Map or implements a RecordTransform
interface.
For more information, see CTL Scripting Specifics or Java Interfaces for Map below.
Details
Map receives potentially unsorted data through the single input port, transforms each of them in a user-specified way and sends the resulting record to the port(s) specified by the user. Return values of the transformation are numbers of output port(s) to which data record will be sent.
A transformation must be defined. The transformation uses a CTL template for Map, implements a RecordTransform
interface or inherits from a DataRecordTransform
superclass. The interface methods are listed below.
CTL Scripting Specifics
When you define any of the three transformation attributes, specify a transformation that assigns a number of output port to each input record.
CTL scripting allows you to specify a custom transformation using the simple CTL scripting language.
CTL Templates for Map
Java Interfaces for Map
Examples
Using Map to drop field(s)
This example shows a way to use Map to drop unnecessary metadata fields.
Input metadata contains the firstname, surname and address fields. Output metadata contains the firstname and surname fields. Drop the address field.
Solution In Map, specify the Transform attribute:
You can use $out.0.* = $in.0.*;
instead of specifying the mapping of particular fields.
Splitting the records
This example shows a way to use Map to split one record to multiple parts and send each part to a different output port.
Input metadata contains the ID, firstname, surname and address fields. Send ID, firstname and surname to the first output port and ID and address to the second output port.
Solution In Map, set the Transform attribute.
Filtering records
Map can be used as a filter.
Input metadata contains the ID and color fields. Valid colors are red, green, or blue. Send red items to the first output port; green items to the second output port; and blue items to the third output port. Items without correct color should be send to the fourth output port.
Solution
Best Practices
Use Map To
Drop unwanted fields
Calculate new or modify existing fields
Convert data types
If the transformation is specified in an external file (with Transform URL), we recommend users to explicitly specify Transform source charset.