use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap 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.fast.CheckFastHashTable.VerifyFastBytesHashMap in project hive by apache.
the class TestVectorMapJoinFastBytesHashMap method testMultipleKeysSingleValue.
@Test
public void testMultipleKeysSingleValue() throws Exception {
random = new Random(29383);
VectorMapJoinFastMultiKeyHashMap map = new VectorMapJoinFastMultiKeyHashMap(false, CAPACITY, LOAD_FACTOR, WB_SIZE, -1);
VerifyFastBytesHashMap verifyTable = new VerifyFastBytesHashMap();
int keyCount = 100 + random.nextInt(1000);
for (int i = 0; i < keyCount; i++) {
byte[] 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);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap in project hive by apache.
the class TestVectorMapJoinFastBytesHashMap method testExpand.
@Test
public void testExpand() throws Exception {
random = new Random(99221);
// Start with capacity 1; make sure we expand on every put.
VectorMapJoinFastMultiKeyHashMap map = new VectorMapJoinFastMultiKeyHashMap(false, 1, 0.0000001f, WB_SIZE, -1);
VerifyFastBytesHashMap verifyTable = new VerifyFastBytesHashMap();
for (int i = 0; i < 18; ++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);
// assertEquals(1 << 18, map.getCapacity());
}
Aggregations