use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult in project hive by apache.
the class TestVectorMapJoinFastLongHashMap method testGetNonExistent.
@Test
public void testGetNonExistent() throws Exception {
random = new Random(450);
VectorMapJoinFastLongHashMap map = new VectorMapJoinFastLongHashMap(false, false, HashTableKeyType.LONG, CAPACITY, LOAD_FACTOR, WB_SIZE, -1);
VerifyFastLongHashMap verifyTable = new VerifyFastLongHashMap();
long key1 = random.nextLong();
byte[] value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key1, value);
verifyTable.add(key1, value);
verifyTable.verify(map);
long key2 = key1 += 1;
VectorMapJoinHashMapResult hashMapResult = map.createHashMapResult();
JoinUtil.JoinResult joinResult = map.lookup(key2, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
assertTrue(!hashMapResult.hasRows());
map.testPutRow(key2, value);
verifyTable.add(key2, value);
verifyTable.verify(map);
long key3 = key2 += 1;
hashMapResult = map.createHashMapResult();
joinResult = map.lookup(key3, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
assertTrue(!hashMapResult.hasRows());
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult in project hive by apache.
the class TestVectorMapJoinFastLongHashMap method testFullMap.
@Test
public void testFullMap() throws Exception {
random = new Random(93440);
// Make sure the map does not expand; should be able to find space.
VectorMapJoinFastLongHashMap map = new VectorMapJoinFastLongHashMap(false, false, HashTableKeyType.LONG, CAPACITY, 1f, WB_SIZE, -1);
VerifyFastLongHashMap verifyTable = new VerifyFastLongHashMap();
for (int i = 0; i < CAPACITY; i++) {
long key;
while (true) {
key = random.nextLong();
if (!verifyTable.contains(key)) {
// Unique keys for this test.
break;
}
}
byte[] value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key, value);
verifyTable.add(key, value);
// verifyTable.verify(map);
}
verifyTable.verify(map);
long anotherKey;
while (true) {
anotherKey = random.nextLong();
if (!verifyTable.contains(anotherKey)) {
// Unique keys for this test.
break;
}
}
VectorMapJoinHashMapResult hashMapResult = map.createHashMapResult();
JoinUtil.JoinResult joinResult = map.lookup(anotherKey, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult in project hive by apache.
the class TestVectorMapJoinFastBytesHashMap method testGetNonExistent.
@Test
public void testGetNonExistent() throws Exception {
random = new Random(1002);
VectorMapJoinFastMultiKeyHashMap map = new VectorMapJoinFastMultiKeyHashMap(false, CAPACITY, LOAD_FACTOR, WB_SIZE, -1);
VerifyFastBytesHashMap verifyTable = new VerifyFastBytesHashMap();
byte[] key1 = new byte[random.nextInt(MAX_KEY_LENGTH)];
random.nextBytes(key1);
byte[] value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key1, value);
verifyTable.add(key1, value);
verifyTable.verify(map);
byte[] key2 = new byte[random.nextInt(MAX_KEY_LENGTH)];
random.nextBytes(key2);
VectorMapJoinHashMapResult hashMapResult = map.createHashMapResult();
JoinUtil.JoinResult joinResult = map.lookup(key2, 0, key2.length, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
assertTrue(!hashMapResult.hasRows());
map.testPutRow(key2, value);
verifyTable.add(key2, value);
verifyTable.verify(map);
byte[] key3 = new byte[random.nextInt(MAX_KEY_LENGTH)];
random.nextBytes(key3);
hashMapResult = map.createHashMapResult();
joinResult = map.lookup(key3, 0, key3.length, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
assertTrue(!hashMapResult.hasRows());
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult in project hive by apache.
the class TestVectorMapJoinFastBytesHashMap method testFullMap.
@Test
public void testFullMap() throws Exception {
random = new Random(200001);
// Make sure the map does not expand; should be able to find space.
VectorMapJoinFastMultiKeyHashMap map = new VectorMapJoinFastMultiKeyHashMap(false, CAPACITY, 1f, WB_SIZE, -1);
VerifyFastBytesHashMap verifyTable = new VerifyFastBytesHashMap();
for (int i = 0; i < CAPACITY; i++) {
byte[] key;
while (true) {
key = new byte[random.nextInt(MAX_KEY_LENGTH)];
random.nextBytes(key);
if (!verifyTable.contains(key)) {
// Unique keys for this test.
break;
}
}
byte[] value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key, value);
verifyTable.add(key, value);
// verifyTable.verify(map);
}
verifyTable.verify(map);
byte[] anotherKey;
while (true) {
anotherKey = new byte[random.nextInt(MAX_KEY_LENGTH)];
random.nextBytes(anotherKey);
if (!verifyTable.contains(anotherKey)) {
// Unique keys for this test.
break;
}
}
VectorMapJoinHashMapResult hashMapResult = map.createHashMapResult();
JoinUtil.JoinResult joinResult = map.lookup(anotherKey, 0, anotherKey.length, hashMapResult);
assertTrue(joinResult == JoinUtil.JoinResult.NOMATCH);
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult in project hive by apache.
the class VectorMapJoinOptimizedHashMap method lookup.
@Override
public JoinUtil.JoinResult lookup(byte[] keyBytes, int keyOffset, int keyLength, VectorMapJoinHashMapResult hashMapResult) throws IOException {
HashMapResult implementationHashMapResult = (HashMapResult) hashMapResult;
JoinUtil.JoinResult joinResult = doLookup(keyBytes, keyOffset, keyLength, implementationHashMapResult.bytesBytesMultiHashMapResult(), (VectorMapJoinHashTableResult) hashMapResult);
return joinResult;
}
Aggregations