Search in sources :

Example 6 with VerifyFastBytesHashMap

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);
}
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 7 with VerifyFastBytesHashMap

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

Example 8 with VerifyFastBytesHashMap

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

Aggregations

Random (java.util.Random)8 VerifyFastBytesHashMap (org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.CheckFastHashTable.VerifyFastBytesHashMap)8 Test (org.junit.Test)8 JoinUtil (org.apache.hadoop.hive.ql.exec.JoinUtil)2 VectorMapJoinHashMapResult (org.apache.hadoop.hive.ql.exec.vector.mapjoin.hashtable.VectorMapJoinHashMapResult)2