on 10-01-2007 10:24 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.