use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap 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.fast.CheckFastHashTable.VerifyFastLongHashMap in project hive by apache.
the class TestVectorMapJoinFastLongHashMap method testLargeAndExpand.
@Test
public void testLargeAndExpand() throws Exception {
random = new Random(20);
// Use a large capacity that doesn't require expansion, yet.
VectorMapJoinFastLongHashMap map = new VectorMapJoinFastLongHashMap(false, false, HashTableKeyType.LONG, MODERATE_CAPACITY, LOAD_FACTOR, MODERATE_WB_SIZE, -1);
VerifyFastLongHashMap verifyTable = new VerifyFastLongHashMap();
int keyCount = 1000;
addAndVerifyMultipleKeyMultipleValue(keyCount, map, verifyTable);
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap 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.fast.CheckFastHashTable.VerifyFastLongHashMap in project hive by apache.
the class TestVectorMapJoinFastLongHashMap method testExpand.
@Test
public void testExpand() throws Exception {
random = new Random(5227);
// Start with capacity 1; make sure we expand on every put.
VectorMapJoinFastLongHashMap map = new VectorMapJoinFastLongHashMap(false, false, HashTableKeyType.LONG, 1, 0.0000001f, WB_SIZE, -1);
VerifyFastLongHashMap verifyTable = new VerifyFastLongHashMap();
for (int i = 0; i < 18; ++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);
// assertEquals(1 << 18, map.getCapacity());
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap in project hive by apache.
the class TestVectorMapJoinFastLongHashMap method testOneKey.
@Test
public void testOneKey() throws Exception {
random = new Random(33221);
VectorMapJoinFastLongHashMap map = new VectorMapJoinFastLongHashMap(false, false, HashTableKeyType.LONG, CAPACITY, LOAD_FACTOR, WB_SIZE, -1);
VerifyFastLongHashMap verifyTable = new VerifyFastLongHashMap();
long key = random.nextLong();
byte[] value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key, value);
verifyTable.add(key, value);
verifyTable.verify(map);
// Second value.
value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key, value);
verifyTable.add(key, value);
verifyTable.verify(map);
// Third value.
value = new byte[random.nextInt(MAX_VALUE_LENGTH)];
random.nextBytes(value);
map.testPutRow(key, value);
verifyTable.add(key, value);
verifyTable.verify(map);
}
Aggregations