Skip to content
Prev Previous commit
Next Next commit
We can include the last element in the last slice in general for incl…
…usive

range, hence eliminate the need to check Int.MaxValue or Int.MinValue.
  • Loading branch information
advancedxy committed Jan 14, 2015
commit b3f55773a305d874b0a4db8258bbd8561e3c070b
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ private object ParallelCollectionRDD {
}
seq match {
case r: Range => {
// 1 to Int.MaxValue and (-2 to Int.MinValue by -1) can trigger exclusive range int overflow
val needsInclusiveRange = r.isInclusive && (r.end == Int.MaxValue || r.end == Int.MinValue)
positions(r.length, numSlices).zipWithIndex.map({ case ((start, end), index) =>
// If the range needs to be inclusive, include the last element in the last slice
if (needsInclusiveRange && index == numSlices - 1) {
// If the range is inclusive, include the last element in the last slice
if (r.isInclusive && index == numSlices - 1) {
new Range.Inclusive(r.start + start * r.step, r.end, r.step)
}
else {
Expand Down