Prateek Kulkarni Prateek Kulkarni - 1 year ago 239
Scala Question

takeSample() function in Spark

I'm trying to use the

function in Spark and the parameters are - data, number of samples to be taken and the seed. But I don't want to use the seed. I want to have a different answer everytime. I'm not able to figure out how I can do that. I tried using
as the seed value but it gave an error since I think the data type didn't match. Is there any other function similar to
that can be used without the seed? Or is there any other implementation I can use with
so that I get a different output every time.

Answer Source

System.nanoTime is of type long, the seed expected by takeSample is of type Int. Hence, takeSample(..., System.nanoTime.toInt) should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download