Skip to content

Commit 06b6a07

Browse files
squitoshivaram
authored andcommitted
[SPARK-9437] [CORE] avoid overflow in SizeEstimator
https://issues.apache.org/jira/browse/SPARK-9437 Author: Imran Rashid <[email protected]> Closes apache#7750 from squito/SPARK-9437_size_estimator_overflow and squashes the following commits: 29493f1 [Imran Rashid] prevent another potential overflow bc1cb82 [Imran Rashid] avoid overflow
1 parent 520ec0f commit 06b6a07

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/main/scala/org/apache/spark/util/SizeEstimator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ object SizeEstimator extends Logging {
217217
var arrSize: Long = alignSize(objectSize + INT_SIZE)
218218

219219
if (elementClass.isPrimitive) {
220-
arrSize += alignSize(length * primitiveSize(elementClass))
220+
arrSize += alignSize(length.toLong * primitiveSize(elementClass))
221221
state.size += arrSize
222222
} else {
223-
arrSize += alignSize(length * pointerSize)
223+
arrSize += alignSize(length.toLong * pointerSize)
224224
state.size += arrSize
225225

226226
if (length <= ARRAY_SIZE_FOR_SAMPLING) {
@@ -336,7 +336,7 @@ object SizeEstimator extends Logging {
336336
// hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/classfile/classFileParser.cpp
337337
var alignedSize = shellSize
338338
for (size <- fieldSizes if sizeCount(size) > 0) {
339-
val count = sizeCount(size)
339+
val count = sizeCount(size).toLong
340340
// If there are internal gaps, smaller field can fit in.
341341
alignedSize = math.max(alignedSize, alignSizeUp(shellSize, size) + size * count)
342342
shellSize += size * count

0 commit comments

Comments
 (0)