on 01-15-2015 11:25 AM
Hi All,
I have a requirment like
my source have 2 fields
field1 having data 1cc2cc3cc4cc5cc
feild2 having data accbccdddcceccfffffcc
in need output like 1cc2cc333cc4cc55555cc please help me to get this type of output.
Note cc means context change, we need to reah values of contexts with source and generate like that.
Thanks,
Venu.
Hello,
Why do u need a UDF? Simply use "UseOneAsMany" function to generate ur output.
Filed1----
Filed2---- UseOneAsMany - Output
Field2----
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I think you mentioned this statement once i posted my reply so that's the reason i overlooked it.
one thing i forgot to mention, values in both queues are not same, i gave same vaules in example but in my case first queue having less values than second queue.
Anyway, u can write a UDF but since the number of context are not same so u have to identify a logic where u can determine for which context (field2) which field1 value needs to be replicated. BTW, <null> can come in between ur actual values as well? If not then i think ur logic can be build around that, where for all "true" values u can read field 1 values one by one.
Thanks
Amit Srivastava
Hi Azhar,
Its very complext and huge XMLs, now i need the UDF logic for two fields mapping given below.
my source have 2 fields
field1 having data 1cc2cc3cc4cc5cc
feild2 having data accbccdddcceccfffffcc
in need output like 1cc2cc333cc4cc55555cc please help me to get this type of output.
Note cc means context change, we need to reah values of contexts with source and generate like that.
values in both queues are not same, i gave same vaules in example but in my case first queue having less values than second queue.
Hope this is can help you.
thanks,
Venu.
Hi Venu,
For the Input given in your previous post, the output can be achieved using the UDF as follows:
public String calculate1(String var1, String var2, Container container) throws StreamTransformationException{
String temp = "";
if(var2.length() > 0)
for(int i=0; i<var2.length();i++)
temp = temp+var1;
var1 = temp;
return var1;
}
Check if it helps. We can build on this UDF as per your requirement.
Regards,
Azhar
Message was edited by: Azhar Shaikh
So in your first queue there is always a context change after each value?
If so why doesn't useoneasmany work?
However below UDF shoudl return the output that you requested for above sample content.
Execution type : All values of context
for( int i=0;i<var2.length;i++)
{
result.addValue(var1[0]);
}
var1 -> your first queue
var2 -> second queue
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.