diff options
author | Arun Ramakrishnan <smartnut007@gmail.com> | 2014-04-24 17:27:16 -0700 |
---|---|---|
committer | Matei Zaharia <matei@databricks.com> | 2014-04-24 17:27:16 -0700 |
commit | 35e3d199f04fba3230625002a458d43b9578b2e8 (patch) | |
tree | 7e301a1585e3dc45cd1a42b8ce567b0aada57b4f /streaming | |
parent | f99af8529b6969986f0c3e03f6ff9b7bb9d53ece (diff) | |
download | spark-35e3d199f04fba3230625002a458d43b9578b2e8.tar.gz spark-35e3d199f04fba3230625002a458d43b9578b2e8.tar.bz2 spark-35e3d199f04fba3230625002a458d43b9578b2e8.zip |
SPARK-1438 RDD.sample() make seed param optional
copying form previous pull request https://github.com/apache/spark/pull/462
Its probably better to let the underlying language implementation take care of the default . This was easier to do with python as the default value for seed in random and numpy random is None.
In Scala/Java side it might mean propagating an Option or null(oh no!) down the chain until where the Random is constructed. But, looks like the convention in some other methods was to use System.nanoTime. So, followed that convention.
Conflict with overloaded method in sql.SchemaRDD.sample which also defines default params.
sample(fraction, withReplacement=false, seed=math.random)
Scala does not allow more than one overloaded to have default params. I believe the author intended to override the RDD.sample method and not overload it. So, changed it.
If backward compatible is important, 3 new method can be introduced (without default params) like this
sample(fraction)
sample(fraction, withReplacement)
sample(fraction, withReplacement, seed)
Added some tests for the scala RDD takeSample method.
Author: Arun Ramakrishnan <smartnut007@gmail.com>
This patch had conflicts when merged, resolved by
Committer: Matei Zaharia <matei@databricks.com>
Closes #477 from smartnut007/master and squashes the following commits:
07bb06e [Arun Ramakrishnan] SPARK-1438 fixing more space formatting issues
b9ebfe2 [Arun Ramakrishnan] SPARK-1438 removing redundant import of random in python rddsampler
8d05b1a [Arun Ramakrishnan] SPARK-1438 RDD . Replace System.nanoTime with a Random generated number. python: use a separate instance of Random instead of seeding language api global Random instance.
69619c6 [Arun Ramakrishnan] SPARK-1438 fix spacing issue
0c247db [Arun Ramakrishnan] SPARK-1438 RDD language apis to support optional seed in RDD methods sample/takeSample
Diffstat (limited to 'streaming')
0 files changed, 0 insertions, 0 deletions