diff options
author | Matei Zaharia <matei@eecs.berkeley.edu> | 2012-04-05 14:53:22 -0700 |
---|---|---|
committer | Matei Zaharia <matei@eecs.berkeley.edu> | 2012-04-05 14:53:22 -0700 |
commit | a8bb324ed9d4c6fa1dd73687f471373dde49378f (patch) | |
tree | a93f694cc860dd11bb808fa499732a13cd506d12 /core | |
parent | acaf99cb3aa6710de7af9da2c73d797fa2d1351b (diff) | |
parent | 816d4e58402c4242ff046a8678c94b72a7993e2d (diff) | |
download | spark-a8bb324ed9d4c6fa1dd73687f471373dde49378f.tar.gz spark-a8bb324ed9d4c6fa1dd73687f471373dde49378f.tar.bz2 spark-a8bb324ed9d4c6fa1dd73687f471373dde49378f.zip |
Merge branch 'master' into mesos-0.9
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/spark/RDD.scala | 60 | ||||
-rw-r--r-- | core/src/main/scala/spark/SparkContext.scala | 2 |
2 files changed, 31 insertions, 31 deletions
diff --git a/core/src/main/scala/spark/RDD.scala b/core/src/main/scala/spark/RDD.scala index c85973fc0c..1160de5fd1 100644 --- a/core/src/main/scala/spark/RDD.scala +++ b/core/src/main/scala/spark/RDD.scala @@ -94,37 +94,37 @@ abstract class RDD[T: ClassManifest](@transient sc: SparkContext) extends Serial new SampledRDD(this, withReplacement, fraction, seed) def takeSample(withReplacement: Boolean, num: Int, seed: Int): Array[T] = { - var fraction = 0.0 - var total = 0 - var multiplier = 3.0 - var initialCount = count() - var maxSelected = 0 - - if (initialCount > Integer.MAX_VALUE) { - maxSelected = Integer.MAX_VALUE - } else { - maxSelected = initialCount.toInt - } - - if (num > initialCount) { - total = maxSelected - fraction = Math.min(multiplier * (maxSelected + 1) / initialCount, 1.0) - } else if (num < 0) { - throw(new IllegalArgumentException("Negative number of elements requested")) - } else { - fraction = Math.min(multiplier * (num + 1) / initialCount, 1.0) - total = num.toInt - } - + var fraction = 0.0 + var total = 0 + var multiplier = 3.0 + var initialCount = count() + var maxSelected = 0 + + if (initialCount > Integer.MAX_VALUE) { + maxSelected = Integer.MAX_VALUE + } else { + maxSelected = initialCount.toInt + } + + if (num > initialCount) { + total = maxSelected + fraction = Math.min(multiplier * (maxSelected + 1) / initialCount, 1.0) + } else if (num < 0) { + throw(new IllegalArgumentException("Negative number of elements requested")) + } else { + fraction = Math.min(multiplier * (num + 1) / initialCount, 1.0) + total = num.toInt + } + var samples = this.sample(withReplacement, fraction, seed).collect() - - while (samples.length < total) { - samples = this.sample(withReplacement, fraction, seed).collect() - } - - val arr = samples.take(total) - - return arr + + while (samples.length < total) { + samples = this.sample(withReplacement, fraction, seed).collect() + } + + val arr = samples.take(total) + + return arr } def union(other: RDD[T]): RDD[T] = new UnionRDD(sc, Array(this, other)) diff --git a/core/src/main/scala/spark/SparkContext.scala b/core/src/main/scala/spark/SparkContext.scala index 6f7b0a7fec..6e019d6e7f 100644 --- a/core/src/main/scala/spark/SparkContext.scala +++ b/core/src/main/scala/spark/SparkContext.scala @@ -44,7 +44,7 @@ class SparkContext( // Set Spark master host and port system properties if (System.getProperty("spark.master.host") == null) { - System.setProperty("spark.master.host", Utils.localHostName) + System.setProperty("spark.master.host", Utils.localIpAddress) } if (System.getProperty("spark.master.port") == null) { System.setProperty("spark.master.port", "7077") |