Search in sources :

Example 1 with OrcMetadataCache

use of org.apache.hadoop.hive.llap.io.metadata.OrcMetadataCache in project hive by apache.

the class TestOrcMetadataCache method testGetPut.

@Test
public void testGetPut() throws Exception {
    DummyMemoryManager mm = new DummyMemoryManager();
    DummyCachePolicy cp = new DummyCachePolicy();
    OrcMetadataCache cache = new OrcMetadataCache(mm, cp, false);
    OrcFileMetadata ofm1 = OrcFileMetadata.createDummy(1), ofm2 = OrcFileMetadata.createDummy(2);
    assertSame(ofm1, cache.putFileMetadata(ofm1));
    assertEquals(1, mm.allocs);
    cp.verifyEquals(1);
    assertSame(ofm2, cache.putFileMetadata(ofm2));
    assertEquals(2, mm.allocs);
    cp.verifyEquals(2);
    assertSame(ofm1, cache.getFileMetadata(1));
    assertSame(ofm2, cache.getFileMetadata(2));
    cp.verifyEquals(4);
    OrcFileMetadata ofm3 = OrcFileMetadata.createDummy(1);
    assertSame(ofm1, cache.putFileMetadata(ofm3));
    assertEquals(2, mm.allocs);
    cp.verifyEquals(5);
    assertSame(ofm1, cache.getFileMetadata(1));
    cp.verifyEquals(6);
    OrcStripeMetadata osm1 = OrcStripeMetadata.createDummy(1), osm2 = OrcStripeMetadata.createDummy(2);
    assertSame(osm1, cache.putStripeMetadata(osm1));
    assertEquals(3, mm.allocs);
    assertSame(osm2, cache.putStripeMetadata(osm2));
    assertEquals(4, mm.allocs);
    assertSame(osm1, cache.getStripeMetadata(osm1.getKey()));
    assertSame(osm2, cache.getStripeMetadata(osm2.getKey()));
    OrcStripeMetadata osm3 = OrcStripeMetadata.createDummy(1);
    assertSame(osm1, cache.putStripeMetadata(osm3));
    assertEquals(4, mm.allocs);
    assertSame(osm1, cache.getStripeMetadata(osm3.getKey()));
    cp.verifyEquals(12);
}
Also used : OrcFileMetadata(org.apache.hadoop.hive.llap.io.metadata.OrcFileMetadata) OrcMetadataCache(org.apache.hadoop.hive.llap.io.metadata.OrcMetadataCache) OrcStripeMetadata(org.apache.hadoop.hive.llap.io.metadata.OrcStripeMetadata) Test(org.junit.Test)

Aggregations

OrcFileMetadata (org.apache.hadoop.hive.llap.io.metadata.OrcFileMetadata)1 OrcMetadataCache (org.apache.hadoop.hive.llap.io.metadata.OrcMetadataCache)1 OrcStripeMetadata (org.apache.hadoop.hive.llap.io.metadata.OrcStripeMetadata)1 Test (org.junit.Test)1