Search in sources :

Example 1 with VectorMapJoinHashMapResult

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());
}
Also used : JoinUtil(org.apache.hadoop.hive.ql.exec.JoinUtil) VerifyFastLongHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap) Random(java.util.Random) VectorMapJoinHashMapResult(org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult) VectorMapJoinFastLongHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastLongHashMap) Test(org.junit.Test)

Example 2 with VectorMapJoinHashMapResult

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);
}
Also used : JoinUtil(org.apache.hadoop.hive.ql.exec.JoinUtil) VerifyFastLongHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap) Random(java.util.Random) VectorMapJoinHashMapResult(org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult) VectorMapJoinFastLongHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastLongHashMap) Test(org.junit.Test)

Example 3 with VectorMapJoinHashMapResult

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());
}
Also used : VerifyFastBytesHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap) JoinUtil(org.apache.hadoop.hive.ql.exec.JoinUtil) Random(java.util.Random) VectorMapJoinHashMapResult(org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult) Test(org.junit.Test)

Example 4 with VectorMapJoinHashMapResult

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);
}
Also used : VerifyFastBytesHashMap(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap) JoinUtil(org.apache.hadoop.hive.ql.exec.JoinUtil) Random(java.util.Random) VectorMapJoinHashMapResult(org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult) Test(org.junit.Test)

Example 5 with VectorMapJoinHashMapResult

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;
}
Also used : JoinUtil(org.apache.hadoop.hive.ql.exec.JoinUtil) VectorMapJoinHashMapResult(org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult)

Aggregations

VectorMapJoinHashMapResult (org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult)7 JoinUtil (org.apache.hadoop.hive.ql.exec.JoinUtil)5 Random (java.util.Random)4 Test (org.junit.Test)4 VerifyFastBytesHashMap (org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap)2 VerifyFastLongHashMap (org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastLongHashMap)2 VectorMapJoinFastLongHashMap (org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastLongHashMap)2 VectorMapJoinHashTableResult (org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashTableResult)2