Skip to content

Commit 9a2fb7b

Browse files
committed
Input of the SparkPi is too big
if the Input of the SparkPi is too big, it will throw new UnsupportedOperationException("empty collection"), because the n may be a negative int number.
1 parent 7a3f589 commit 9a2fb7b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/src/main/scala/org/apache/spark/examples/SparkPi.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object SparkPi {
2727
val conf = new SparkConf().setAppName("Spark Pi")
2828
val spark = new SparkContext(conf)
2929
val slices = if (args.length > 0) args(0).toInt else 2
30-
val n = 100000 * slices
30+
val n = if (100000.toLong * slices > Int.MaxValue) Int.MaxValue - 1 else 100000 * slices
3131
val count = spark.parallelize(1 to n, slices).map { i =>
3232
val x = random * 2 - 1
3333
val y = random * 2 - 1

0 commit comments

Comments
 (0)