Github user SaintBacchus commented on the pull request:
https://github.com/apache/spark/pull/2874#issuecomment-69496171
Sorry for forgetting explain why there must be `Int.MaxValue -1` instead
of `Int.MaxValue` .
As the SparkPi using the `parallelize` to generator the RDD so it has a
limit of input seq, and go through the implement of this:
```scala
def positions(length: Long, numSlices: Int): Iterator[(Int, Int)] = {
(0 until numSlices).iterator.map(i => {
val start = ((i * length) / numSlices).toInt
val end = (((i + 1) * length) / numSlices).toInt
(start, end)
})
}
```
in line 122 at `ParallelCollectionRDD.scala`
The max size of the input seq was `Int.MaxValue - 1`, otherwise the `end =
(((i + 1) * length) / numSlices).toInt` will overflow and lead an uncorrect
reslut.
I tested this:
```scala
sc.makeRDD(1 to (Int.MaxValue)).count // result = 0
sc.makeRDD(1 to (Int.MaxValue - 1)).count // result = 2147483646 =
Int.MaxValue - 1
sc.makeRDD(1 until (Int.MaxValue)).count // result = 2147483646 =
Int.MaxValue - 1
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]