cancel
Showing results for 
Search instead for 
Did you mean: 

What does G_BATCH_SIZE stand for

Former Member
0 Kudos

Hi All,

Could you telll hwat does this UDF do:

for(int i=0;i<(a.length/G_BATCH_SIZE);i++) {

result.addValue("true");

result.addContextChange();

}

if((a.length % G_BATCH_SIZE) != 0) {

result.addValue("true");

result.addContextChange();

}

Regards,

Xier

Accepted Solutions (1)

Accepted Solutions (1)

henrique_pinto
Active Contributor
0 Kudos

It will aggregate the items of the a[] array into groups of G_BATCH_SIZE items each.

If some items from a[] array are left (if the division a.length / G_BATCH_SIZE has a rest different of zero), it will create a last group with these items.

So, the udf will create a new array with the value "true" for each of these new groups.

Also, each of the items of this output array will be in a different context.

It may be useful if you have the following mapping case:

Input message:

Input_MT (1)

--Item (0...unbounded)

-


ItemId (1)

Output message:

Output_MT (1)

--Box (0...unbounded)

-


BoxId (1)

-


BoxItems (1)

-


Item (1...4)

-


ItemId (1)

You want to create boxes for the items, but you can only put up to 4 items in each box.

In this case, that UDF would be useful to populate the BoxItems target field, using the Item source field as input. In case you haven't noticed, for this example, G_BATCH_SIZE = 4.

The same logic would be useful to create the Box target field, only that you didn't have to create different contexts (remove the result.addContextChanges() lines from the UDF).

Regards,

Henrique.

Answers (0)