Skip to content

Commit

Permalink
Fixing numSlice corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
falaki committed Oct 11, 2016
1 parent 9f103c6 commit 62ab47b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/pkg/R/context.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ parallelize <- function(sc, coll, numSlices = 1) {
coll <- as.list(coll)
}

if (numSlices > length(coll))
numSlices <- length(coll)

sizeLimit <- getMaxAllocationLimit(sc)
objectSize <- object.size(coll)

# For large objects we make sure the size of each slice is also smaller than sizeLimit
numSlices <- max(numSlices, ceiling(objectSize / sizeLimit))
if (numSlices > length(coll))
numSlices <- length(coll)

sliceLen <- ceiling(length(coll) / numSlices)
slices <- split(coll, rep(1: (numSlices + 1), each = sliceLen)[1:length(coll)])
Expand Down

0 comments on commit 62ab47b

Please sign in to comment.