on 08-05-2010 9:36 PM
Hi
I need a UDF to generate the Sequence Number. Counter and Index won't work in my example. I need to generate sequence number incrementing only when there is a Context Change. I cannot use collapse context as I need to keep all the values.
It is like Index function. If INDEX works like this -
when ever there is a context change, we can reset the counter.
In my scenario, UDF should work as
when ever there is a context change, Increment the counter, other wise keep the same.
eg. input to INDEX/UDF
A
context change
B
B
context change
C
context change
D
D
context change
INDEX Function Output is
1
context change
2
3
context change
4
context change
5
6
context change
Desired UDF output should be
Index Output is
1
context change
2
2
context change
3
context change
4
4
context change
Edited by: bprashanth19 on Aug 5, 2010 10:50 PM
Edited by: bprashanth19 on Aug 5, 2010 10:50 PM
Hi Prasanth,
Map Like This..
Input ---> collapseContext ----> index(1,1) ----> splitByValue(Each Value) ---\
input ----->useOneAsMany ---->output
input /
I have tested this mapping passing the same input which you have mentioned.
got the output like
1
context change
2
2
context change
3
context change
4
4
context change
Regards
Jyothi A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Jyothi.That was eaxctly the solution I was looking for.
Thanks Das for the UDF, I had some challenges implementing the UDF. Though I created the variable count in target node, UDF was still given error as count not defined.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
u can obtain this using a simple UDF
decalre a global variable.
int count = 1;
keep execution type = context
copy paste the below code
for(int i= 0;i<var1.length;i++)
{
result.addValue(count+"");
}
count = count+ 1;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please use index function with property entire document inplace of context.
See if it works.
Thanks,
Hetal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Index function can be used.
Check the index property, it can reset after context change.
Regards
Liang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.