diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java index 79b39b4de5..80f4546245 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastBytesHashTable.java @@ -53,6 +53,12 @@ public void putRow(BytesWritable currentKey, BytesWritable currentValue) throws add(keyBytes, 0, keyLength, currentValue); } + @Override + public boolean containsLongKey(long currentKey) { + // Only supported for Long-Hash implementations + throw new RuntimeException("Not supported yet!"); + } + public abstract void add(byte[] keyBytes, int keyStart, int keyLength, BytesWritable currentValue); diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMap.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMap.java index f9074f3847..bfc829f688 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMap.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMap.java @@ -155,6 +155,11 @@ public void putRow(BytesWritable currentKey, BytesWritable currentValue) } } + @Override + public boolean containsLongKey(long currentKey) { + return containsKey(currentKey); + } + /* * A Unit Test convenience method for putting key and value into the hash table using the * actual types. diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMultiSet.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMultiSet.java index a9d1ed779e..55f038b6f9 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMultiSet.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashMultiSet.java @@ -64,6 +64,11 @@ public void putRow(BytesWritable currentKey, BytesWritable currentValue) } } + @Override + public boolean containsLongKey(long currentKey) { + return containsKey(currentKey); + } + /* * A Unit Test convenience method for putting the key into the hash table using the * actual type. diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashSet.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashSet.java index 10e887a5b9..3fb994144c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashSet.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashSet.java @@ -56,6 +56,11 @@ public void putRow(BytesWritable currentKey, BytesWritable currentValue) adaptPutRow(currentKey, currentValue); } + @Override + public boolean containsLongKey(long currentKey) { + return containsKey(currentKey); + } + /* * A Unit Test convenience method for putting the key into the hash table using the * actual type. diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashTable.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashTable.java index b9ee7c336b..d275a3e493 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashTable.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/VectorMapJoinFastLongHashTable.java @@ -216,6 +216,11 @@ private void expandAndRehash() { metricExpands++; } + protected boolean containsKey(long key) { + long hashCode = HashCodeUtil.calculateLongHashCode(key); + return findReadSlot(key, hashCode) != -1; + } + protected int findReadSlot(long key, long hashCode) { int intHashCode = (int) hashCode; diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/hashtable/VectorMapJoinHashTable.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/hashtable/VectorMapJoinHashTable.java index ce5c597316..93e8440e64 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/hashtable/VectorMapJoinHashTable.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/hashtable/VectorMapJoinHashTable.java @@ -41,6 +41,15 @@ void putRow(BytesWritable currentKey, BytesWritable currentValue) throws SerDeException, HiveException, IOException; + /** + * + * @param currentKey + * The key to check for existence. + * @return true + * If HashTable contains the given key. + */ + boolean containsLongKey(long currentKey); + /** * Get hash table size */ diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/optimized/VectorMapJoinOptimizedHashTable.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/optimized/VectorMapJoinOptimizedHashTable.java index 45faa9713a..c6a9323374 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/optimized/VectorMapJoinOptimizedHashTable.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/optimized/VectorMapJoinOptimizedHashTable.java @@ -75,6 +75,12 @@ public void putRow(BytesWritable currentKey, BytesWritable currentValue) putRowInternal(currentKey, currentValue); } + @Override + public boolean containsLongKey(long currentKey) { + // Method only supported by FAST HashTable implementations + throw new RuntimeException("Not implemented"); + } + protected void putRowInternal(BytesWritable key, BytesWritable value) throws SerDeException, HiveException, IOException { diff --git ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/CheckFastRowHashMap.java ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/CheckFastRowHashMap.java index 10ed6d7ee2..476ecd3b0b 100644 --- ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/CheckFastRowHashMap.java +++ ql/src/test/org/apache/hadoop/hive/ql/exec/vector/mapjoin/fast/CheckFastRowHashMap.java @@ -361,7 +361,7 @@ public void verify(VectorMapJoinFastHashTable map, throw new RuntimeException("Unexpected hash table key type " + hashTableKeyType.name()); } joinResult = longHashMap.lookup(longKey, hashMapResult); - if (joinResult != JoinUtil.JoinResult.MATCH) { + if (joinResult != JoinUtil.JoinResult.MATCH || !longHashMap.containsLongKey(longKey)) { assertTrue(false); } }