Search in sources :

Example 1 with VerifyFastLongHashMap

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());
}
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 VerifyFastLongHashMap

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

Example 3 with VerifyFastLongHashMap

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

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

Example 5 with VerifyFastLongHashMap

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

Aggregations

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