cancel
Showing results for 
Search instead for 
Did you mean: 

Another mapping question

Former Member
0 Kudos

All,

We have a input file of the following format.

<source>

<record><recordtype>H</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d2</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d2</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>H</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recorddata>Test</recorddata></record>

<record><recordtype>d3</recordtype><recorddata>Test</recorddata></record>

</source>

We need to add another node to the this structure, called recordnumber. The occurence of recordtype=H, signifies a new record and all the records following that till the next occurence of H, should have the same recordnumber. Like as below,

<target>

<record><recordtype>H</recordtype><recordnumber>1</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recordnumber>1</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d2</recordtype><recordnumber>1</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recordnumber>1</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d2</recordtype><recordnumber>1</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>H</recordtype><recordnumber>2</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d1</recordtype><recordnumber>2</recordnumber><recorddata>Test</recorddata></record>

<record><recordtype>d3</recordtype><recordnumber>2</recordnumber><recorddata>Test</recorddata></record>

</target>

How can we do this?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

This can be done using advanced UDF (user defined function). The entire payload has to be sent as argument in to the container. Because here we need to have the history of occurance of H record.

rgds

Ramesh P

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi thezone !

To complete the recordnumber node, use an advanced udf that receives the entire queue. Then inside the UDF, you can read each element of the queue, use a counter to create the recordnumber and on each appearance of the "H" value, you increase the counter...the output of this UDF should be something like this: 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3, etc.

Regards,

Matias.

Former Member
0 Kudos

If you are using A-UDF (as adviced in your other thread) then you can use a counter which you increment everytime you encounter recordtype with value 'H'.

sincerely,

--NM