Denormalizer

We suppose that you have already learned what is described in:

If you want to find the right Transformer for your purposes, see Transformers Comparison.

Short Summary

Denormalizer creates single output record from one or more input records.

Component Same input metadata Sorted inputs Inputs Outputs Java CTL
Denormalizer-
no
11
yes
yes

Abstract

Denormalizer receives sorted data through single input port, checks Key values, creates one output record from one or more adjacent input records with the same Key value.

A transformation must be defined. The transformation uses a CTL template for Denormalizer, implements a RecordDenormalize interface or inherits from a DataRecordDenormalize superclass. The interface methods are listed below.

Icon

Ports

Port typeNumberRequiredDescriptionMetadata
Input0
yes
for input data recordsany
Output0
yes
for denormalized data recordsany

Denormalizer Attributes

AttributeReqDescriptionPossible values
Basic
Key[ 1) ] Key that creates groups of input data records according to its value. Adjacent input records with the same value of Key are considered to be members of one group. One output record is composed from members of such group. See Key for more information. 
Group size[ 1) ]Group may be defined by exact number of its memebers. E.g. each five records form a single group. The input record count MUST me a multiple of group size. This is mutually exclusive with key atribute.a number
Denormalize[ 2) ] Definition of how to denormalize records, written in the graph in CTL. 
Denormalize URL[ 2) ] Name of external file, including path, containing the definition of how to denormalize records, written in CTL or Java. 
Denormalize class[ 2) ] Definition of how to denormalize records, written in the graph in Java. 
Sort order Order in which groups of input records are expected to be sorted. See Sort order Auto (default) | Ascending | Descending | Ignore
Equal NULL By default, records with null values of key fields are considered to be equal. If false, they are considered to be different.true (default) | false
Denormalize source charset Encoding of external file defining the transformation.ISO-8859-1 (default)
Deprecated
Error actions Definition of the action that should be performed when the specified transformation returns some Error code. See Return Values of Transformations. 
Error log URL of the file to which error messages for specified Error actions should be written. If not set, they are written to Console. 

[ 1) ] Either key or group size must be specified, group size having higher priority

[ 2) ] One of them must specified. Any of these transformation attributes uses the CTL template for Denormalizer or implements a RecordDenormalize interface.

See CTL Scripting Specifics or Java Interfaces for Denormalizer for more information.

See also Defining Transformations for detailed information about transformations.

Advanced Description

CTL Scripting Specifics

When you define any of the three transformation attributes, you must specify the way how input should be transformed into output.

For detailed information about CloudConnect Transformation Language see Part XI, CTL - CloudConnect Transformation Language. (CTL is a full-fledged, yet simple language that allows you to perform almost any imaginable transformation.)

CTL scripting allows you to specify custom transformation using the simple CTL scripting language.

Once you have written your transformation, you can also convert it to Java language code by clicking corresponding button at the upper right corner of the tab.

You can open the transformation definition as another tab of the graph (in addition to the Graph and Source tabs of Graph Editor) by clicking corresponding button at the upper right corner of the tab.

CTL Templates for Denormalizer

Here is an example of how the Source tab for defining the transformation looks.

Source Tab of the Transform Editor in the Denormalizer Component

Figure 55.1. Source Tab of the Transform Editor in the Denormalizer Component


Table 55.1. Functions in Denormalizer

CTL Template Functions
boolean init()
RequiredNo
DescriptionInitialize the component, setup the environment, global variables
InvocationCalled before processing the first record
Returnstrue | false (in case of false graph fails)
integer append()
Requiredyes
Input Parametersnone
ReturnsInteger numbers. See Return Values of Transformations for detailed information.
InvocationCalled repeatedly, once for each input record
DescriptionFor the group of adjacent input records with the same Key values it appends the information from which composes the resulting output record. If any of the input records causes fail of the append() function, and if user has defined another function (appendOnError()), processing continues in this appendOnError() at the place where append() failed. If append() fails and user has not defined any appendOnError(), the whole graph will fail. The append() passes to appendOnError() error message and stack trace as arguments.
Example
function integer append() {
	CustomersInGroup++;
        myLength = length(errorCustomers);	
	if(!isInteger($OneCustomer)) {
		errorCustomers = errorCustomers + iif(myLength > 0 ," - ","") + $OneCustomer;
	}
	customers = customers + iif(length(customers) > 0 ," - ","") + $OneCustomer;
	groupNo = $GroupNo;
	return CustomersInGroup;
}
integer transform()
Requiredyes
Input Parametersnone
ReturnsInteger numbers. See Return Values of Transformations for detailed information.
InvocationCalled repeatedly, once for each output record.
DescriptionIt creates output records. If any part of the transform() function for some output record causes fail of the transform() function, and if user has defined another function (transformOnError()), processing continues in this transformOnError() at the place where transform() failed. If transform() fails and user has not defined any transformOnError(), the whole graph will fail. The transformOnError() function gets the information gathered by transform() that was get from previously successfully processed code. Also error message and stack trace are passed to transformOnError().
Example
function integer transform() {
   $0.CustomersInGroup = CustomersInGroup;
   $0.CustomersOnError = errorCustomers;	
   $0.Customers = customers;
   $0.GroupNo = groupNo;
   return OK;
} 
void clean()
Requiredno
Input Parametersnone
Returnsvoid
InvocationCalled repeatedly, once for each output record (after this has been created by the transform() function).
DescriptionReturns the component to the initial settings
Example
function void clean(){
   customers = "";
   errorCustomers = "";
   groupNo = 0;
   CustomersInGroup = 0;
}
integer appendOnError(string errorMessage, string stackTrace)
Requiredno
Input Parametersstring errorMessage
string stackTrace
ReturnsInteger numbers. Positive integer numers are ignored, meaning of 0 and negative values is described in Return Values of Transformations
InvocationCalled if append() throws an exception. Called repeatedly for the whole group of records with the same Key value.
DescriptionFor the group of adjacent input records with the same Key values it appends the information from which it composes the resulting output record. If any of the input records causes fail of the append() function, and if user has defined another function (appendOnError()), processing continues in this appendOnError() at the place where append() failed. If append() fails and user has not defined any appendOnError(), the whole graph will fail. The appendOnError() function gets the information gathered by append() that was get from previously successfully processed input records. Also error message and stack trace are passed to appendOnError().
Example
function integer appendOnError(string errorMessage, string stackTrace) {
   printErr(errorMessage);
   return CustomersInGroup;
}
integer transformOnError(Exception exception, stackTrace)
Requiredno
Input Parametersstring errorMessage
string stackTrace
ReturnsInteger numbers. See Return Values of Transformations for detailed information.
InvocationCalled if transform() throws an exception.
DescriptionIt creates output records. If any part of the transform() function for some output record causes fail of the transform() function, and if user has defined another function (transformOnError()), processing continues in this transformOnError() at the place where transform() failed. If transform() fails and user has not defined any transformOnError(), the whole graph will fail. The transformOnError() function gets the information gathered by transform() that was get from previously successfully processed code. Also error message and stack trace are passed to transformOnError().
Example
function integer transformOnError(
                  string errorMessage, 
                  string stackTrace) {
   $0.CustomersInGroup = CustomersInGroup;
   $0.ErrorFieldForTransform = errorCustomers;	
   $0.CustomersOnError = errorCustomers;
   $0.Customers = customers;
   $0.GroupNo = groupNo;
   return OK;
}
string getMessage()
RequiredNo
DescriptionPrints error message specified and invocated by user
InvocationCalled in any time specified by user (called only when either append(), transform(), appendOnError(), or transformOnError() returns value less than or equal to -2).
Returnsstring
void preExecute()
RequiredNo
Input parametersNone
Returnsvoid
DescriptionMay be used to allocate and initialize resources required by the transform. All resources allocated within this function should be released by the postExecute() function.
InvocationCalled during each graph run before the transform is executed.
void postExecute()
RequiredNo
Input parametersNone
Returnsvoid
DescriptionShould be used to free any resources allocated within the preExecute() function.
InvocationCalled during each graph run after the entire transform was executed.

[Important]Important
  • Input records or fields

    Input records or fields are accessible within the append() and appendOnError() functions only.

  • Output records or fields

    Output records or fields are accessible within the transform() and transformOnError() functions only.

  • All of the other CTL template functions allow to access neither inputs nor outputs.

[Warning]Warning

Remember that if you do not hold these rules, NPE will be thrown!

Java Interfaces for Denormalizer

The transformation implements methods of the RecordDenormalize interface and inherits other common methods from the Transform interface. See Common Java Interfaces.

Following are the methods of the RecordDenormalize interface: