on 10-16-2014 1:21 AM
Hi,
I need to check whether the value in first argument is same as in 2nd Argument, if so then pass that value else add context change.
I am using below UDF for the same
int i=0,j=0;
for(i=0;i<a.length;i++){
for(j=0;j<b.length;j++)
if(a[i].equals(b[j]))
result.addValue("He");
else
result.addContextChange();
}
A B
123 234
456 456
789
234
678
Output should be
[]
456
[]
234
[]
Appreciate your help.
Thanks,
CH..
Hi CH
Try out the logic below. Your UDF should be of type "Queue".
for (int i = 0; i < a.length; i++) {
boolean found = false;
for (int j = 0; j < b.length; j++) {
if (a[i].equals(b[j])) {
result.addValue(a[i]);
found = true;
break;
}
}
if(!found) {
result.addContextChange();
}
}
Rgds
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi CH
Good to know it worked for your first scenario.
For your second scenario, can you clarify what is the relationship to match 123 with ABC, and 456 with DEF? Also, what are the values of X from input A?
It would be much easier if you provide values from an actual payload instead of hypothetical values.
Rgds
Eng Swee
Hi Swee,
Basically in my First queue i am having 5 entries with key123 as one of the field and in second queue i might have 5 entries with Key123 or some times it might not be 5 it might be existing or not also.
I need to pass 2nd queue entry to only for the first queue entry where this key matches if not i need to pass Empty context.
Remember second queue might exist or not also and both queue 1, queue2 are in same level.
Hope this clarifies.
i was thinking based on my example provide if Queue1 has value X then pass [] else pass the first value of Queue 2 to the first non exisiting value X.
Correspondingly 2nd non X value should be replaced with 2nd value of QUEQE2.
Thanks,
Ch
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
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.