on 07-26-2007 8:41 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
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.