Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi team,
I want to distribute the attribute "number" by 1 on the attributes "Supp" which have the biggest "rest" and which are grouped by code,
I use:
tOracleInput-> tSortRow-> Tjavaflex-> tLogRow
I use tSortRow to sort the "rest" attributes,
tJavaFlex:
for (int i = 0; i <= row7.code; i ++)
{for (j = 0; j <= row7.number; j--)
{row10.Supp = row7.Supp + 1;}
input
code|number|rest|supp
1 |2 |150 |4
1 |2 |125 |1
1 |2 |110 |1
2 |3 |145 |0
2 |3 |130 |3
2 |3 |50 |1
2 |3 |10 |4
Iwant an output like this:
code|number|rest|supp
1 |2 |150 |5
1 |2 |125 |2
1 |2 |110 |1
2 |3 |145 |1
2 |3 |130 |4
2 |3 |50 |2
2 |3 |10 |4
Could anyone please give me a hint of how to do this?
Your help is very much appreciated.
thanks,
nadakh
Find attached the job
Here is the tJavaRow
String code = input_row.code; int num = input_row.number; output_row.code = input_row.code; output_row.number = input_row.number; output_row.rest = input_row.rest; output_row.supp = input_row.supp; if( code.contains(context.current_code) ){ context.to_distribute -= 1 ; output_row.supp += ( 0 > context.to_distribute ? 0 : 1 ); } else { context.current_code = input_row.code; context.to_distribute = input_row.number - 1; output_row.supp += ( 0 > context.to_distribute ? 0 : 1 ); }
hope this will help
Your example does not make this very clear. Why does .....
1 |2 |150 |4
1 |2 |125 |1
1 |2 |110 |1
2 |3 |145 |0
2 |3 |130 |3
2 |3 |50 |1
2 |3 |10 |4
......turn into this....
1 |2 |150 |5
1 |2 |125 |2
1 |2 |110 |1
2 |3 |145 |1
2 |3 |130 |4
2 |3 |50 |2
2 |3 |10 |4
The first 3 columns are exactly the same, but there doesn't appear to be a a reason for the column 4 change??
Hi rhall_2_0,
then, I will explain this example, for the code "1": I have 3 lists, each list gets a "rest" and a "Supp" and I have a "Number" to distribute on the lists that have the most highest "rest" (for code "1": I have "number" = 2).
for "rest" = 150 we assign a "Number"=1 -> Supp = Supp + 1
for "rest" = 125 we assign a "Number"=1 -> Supp = Supp + 1
for "rest" = 110 there is no "number" to assign it -> Supp = Supp + 0
and I repeat the same procedure for each code. (for code "2" I have "number" = 3 to distribute it)
I hope that I explain my problem well, I do not find how to make this loop with talend
I'm still not sure about the logic, but what you describe should be possible using a tJavaFlex (as you've suggested). What is the issue you are getting?
Hi dgm01,
Yes it works like that.