Skip to content

Commit 9e038d1

Browse files
committed
[SPARK-5860][CORE] Prevent overflowing at the length level
1 parent 7883ad9 commit 9e038d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/main/scala/org/apache/spark/rdd/JdbcRDD.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class JdbcRDD[T: ClassTag](
6262

6363
override def getPartitions: Array[Partition] = {
6464
// bounds are inclusive, hence the + 1 here and - 1 on end
65-
val length = 1 + BigInt(upperBound - lowerBound)
65+
val length = BigInt(1) + upperBound - lowerBound
6666
(0 until numPartitions).map(i => {
67-
val start = lowerBound + ((i * length) / numPartitions).toLong
68-
val end = lowerBound + (((i + 1) * length) / numPartitions).toLong - 1
69-
new JdbcPartition(i, start, end)
67+
val start = lowerBound + ((i * length) / numPartitions)
68+
val end = lowerBound + (((i + 1) * length) / numPartitions) - 1
69+
new JdbcPartition(i, start.toLong, end.toLong)
7070
}).toArray
7171
}
7272

0 commit comments

Comments
 (0)