Help with the code
Moderators: chulett, rschirm, roy
Help with the code
There are like 1000 rows and I need a new column with simultaneous 100 and 200 and each row...
like the new column should be
100
200
100
200
How to get to this...
like the new column should be
100
200
100
200
How to get to this...
-
- Participant
- Posts: 43
- Joined: Thu May 29, 2008 8:41 pm
Completely random 100 and 200 values? Or duplicating a source row so that you have one with 100 and the other with 200? Other?
For former, a round robin partitioner and then base the new column on @PARTITIONNUM or stage variables (if 100 then 200 else 100 although that won't necessarily be balanced unless using single partition). For duplicating source rows, send through a copy stage with two outputs and then through a column generator on each link, one setting to 100, the other to 200. For other...
For former, a round robin partitioner and then base the new column on @PARTITIONNUM or stage variables (if 100 then 200 else 100 although that won't necessarily be balanced unless using single partition). For duplicating source rows, send through a copy stage with two outputs and then through a column generator on each link, one setting to 100, the other to 200. For other...
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I think you mean "alternating" rather than "simultaneous".
If the Transformer stage is operating in Sequential mode, then all you need are two stage variables, one to remember the previous row and the other to toggle the value.
Once you get to parallel operation you have to answer more questions, such as does it matter whether the partitions are processed independently (which might mean that you end up with slightly more 100 values than 200 values particularly if each partition processes an odd number of rows).
If the Transformer stage is operating in Sequential mode, then all you need are two stage variables, one to remember the previous row and the other to toggle the value.
Once you get to parallel operation you have to answer more questions, such as does it matter whether the partitions are processed independently (which might mean that you end up with slightly more 100 values than 200 values particularly if each partition processes an odd number of rows).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Actually you could do it with one uint8 stage variable whose initial value is not 100.
Code: Select all
svValue <-- If svValue <> 100 Then 100 Else 200
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
What will happen in the following case ?wittyme wrote:Not really... I am getting duplicate 100 and 200 values from my source. So, I want to add it in the job.
No criteria specifically.
You will getKey
Tom
Jerry
Jerry
Jerry
Tom
Is that what you want ?GenValue Key
100 Tom
200 Jerry
100 Jerry
200 Jerry
100 Tom