diff options
author | Sylvain Zimmer <sylvain@sylvainzimmer.com> | 2016-07-28 09:51:45 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-07-28 09:51:45 -0700 |
commit | 1178d61ede816bf1c8d5bb3dbb3b965c9b944407 (patch) | |
tree | 8333924d7f3131d6791d36c5672fc3ed9cb1f28b | |
parent | 9ade77c3fa2e1bf436b79368a97d5980c12fe215 (diff) | |
download | spark-1178d61ede816bf1c8d5bb3dbb3b965c9b944407.tar.gz spark-1178d61ede816bf1c8d5bb3dbb3b965c9b944407.tar.bz2 spark-1178d61ede816bf1c8d5bb3dbb3b965c9b944407.zip |
[SPARK-16740][SQL] Fix Long overflow in LongToUnsafeRowMap
## What changes were proposed in this pull request?
Avoid overflow of Long type causing a NegativeArraySizeException a few lines later.
## How was this patch tested?
Unit tests for HashedRelationSuite still pass.
I can confirm the python script I included in https://issues.apache.org/jira/browse/SPARK-16740 works fine with this patch. Unfortunately I don't have the knowledge/time to write a Scala test case for HashedRelationSuite right now. As the patch is pretty obvious I hope it can be included without this.
Thanks!
Author: Sylvain Zimmer <sylvain@sylvainzimmer.com>
Closes #14373 from sylvinus/master.
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala index 412e8c54ca..cf4454c033 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala @@ -608,7 +608,8 @@ private[execution] final class LongToUnsafeRowMap(val mm: TaskMemoryManager, cap def optimize(): Unit = { val range = maxKey - minKey // Convert to dense mode if it does not require more memory or could fit within L1 cache - if (range < array.length || range < 1024) { + // SPARK-16740: Make sure range doesn't overflow if minKey has a large negative value + if (range >= 0 && (range < array.length || range < 1024)) { try { ensureAcquireMemory((range + 1) * 8L) } catch { |