diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java index 89087e1450..e401b21545 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java @@ -208,6 +208,10 @@ protected final long findReadSlot( protected long[] slotTriples; private void allocateBucketArray() { + // We allocate triples, so we cannot go above highest Integer power of 2 / 6. + if (logicalHashBucketCount > ONE_SIXTH_LIMIT) { + throwExpandError(ONE_SIXTH_LIMIT, "Bytes"); + } int slotTripleArraySize = 3 * logicalHashBucketCount; slotTriples = new long[slotTripleArraySize]; } diff --git a/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/TestVectorMapJoinFastBytesHashMap.java b/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/TestVectorMapJoinFastBytesHashMap.java index 905180431f..9ed9d1ef44 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/TestVectorMapJoinFastBytesHashMap.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/TestVectorMapJoinFastBytesHashMap.java @@ -298,6 +298,17 @@ public void testReallyBig() throws Exception { addAndVerifyMultipleKeyMultipleValue(keyCount, map, verifyTable); } + @Test + public void testOutOfBounds() throws Exception { + random = new Random(42662); + + int HIGHEST_INT_POWER_OF_2 = 1073741824; + // The c'tor should throw the error + VectorMapJoinFastMultiKeyHashMap map = + new VectorMapJoinFastMultiKeyHashMap( + false, HIGHEST_INT_POWER_OF_2, LOAD_FACTOR, MODERATE_WB_SIZE, -1); + } + /* // Can't seem to get mvn to give enough memory to run this successfully. @Test