Page 1 of 1
Random number generation in buildop
Posted: Tue Jan 10, 2006 12:08 pm
by Rajesh_kr82
I have to assign unique numbers to records in a buildop stage. How can i ensure that the numbers generated in all tha partitions are unique? Is there any way to get the partition number in C++ code i have written.
Rajesh
Posted: Tue Jan 10, 2006 1:37 pm
by bcarlson
Why do you need to assign it within the buildop? You could use a Surrogate Key Generator (or more generically, a Column Generator) to add a unique sequence number to the row.
There are quite a few posting out there for "Surrogate Key Generator" and "Column Generator" if that would suit your needs.
Brad.
Posted: Tue Jan 10, 2006 3:44 pm
by Rajesh_kr82
Well here is the problem? lets say my data set is as below::
Key columns
1 ab
1 cb
1 cd
2 df
3 fd
4 fd
4 re
here i want to assign same number to all the 1's and 4's. The stages which you have mentioned will generate seperate number for all the different rows.
Posted: Tue Jan 10, 2006 4:12 pm
by ray.wurlod
System variable @PARTITION may do what you need. To be honest I'm not 100% clear on your requirement.
Posted: Tue Jan 10, 2006 4:43 pm
by bcarlson
Both the Surrogate Key Generator and the Column Generator stages can add the partition number to your schema, which you could then use in your buildop.
Posted: Tue Jan 10, 2006 6:05 pm
by vmcburney
You can assign numbers in the transformer stage using the FAQ on
How do I set up a counter in a parallel transformer? You just need to sort and partition on that number field and only increment the parallel counter when the key number field changes. You can do this with a lastkey stage variable for comparison.
Posted: Fri Jan 13, 2006 12:44 pm
by Rajesh_kr82
I got it done after setting the counter.
Thanks for help guys.
Rajesh