Search in sources :

Example 6 with TableSegmentUniqueIdentifier

use of org.apache.carbondata.core.datastore.TableSegmentUniqueIdentifier in project carbondata by apache.

the class CacheProviderTest method driverExecutorCacheConfTest.

/**
 * to test the driver and executor lru memory configuration
 *
 * @throws IOException
 * @throws NoSuchFieldException
 * @throws IllegalAccessException
 */
@Test
public void driverExecutorCacheConfTest() throws IOException, NoSuchFieldException, IllegalAccessException {
    // get cache provider instance
    CacheProvider cacheProvider = CacheProvider.getInstance();
    cacheProvider.dropAllCache();
    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.IS_DRIVER_INSTANCE, "true");
    Cache<TableSegmentUniqueIdentifier, SegmentTaskIndexStore> driverCache = cacheProvider.createCache(CacheType.DRIVER_BTREE);
    Field carbonLRUCacheField = SegmentTaskIndexStore.class.getDeclaredField("lruCache");
    carbonLRUCacheField.setAccessible(true);
    CarbonLRUCache carbonLRUCache = (CarbonLRUCache) carbonLRUCacheField.get(driverCache);
    Field lruCacheMemorySizeField = CarbonLRUCache.class.getDeclaredField("lruCacheMemorySize");
    lruCacheMemorySizeField.setAccessible(true);
    long lruCacheMemorySize = (long) lruCacheMemorySizeField.get(carbonLRUCache);
    String driverCacheSize = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_MAX_DRIVER_LRU_CACHE_SIZE);
    assertEquals(1024 * 1024 * Integer.parseInt(driverCacheSize), lruCacheMemorySize);
    // drop cache
    cacheProvider.dropAllCache();
    // validation test for the executor memory.
    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.IS_DRIVER_INSTANCE, "false");
    Cache<TableBlockUniqueIdentifier, BlockIndexStore> executorCache = cacheProvider.createCache(CacheType.EXECUTOR_BTREE);
    carbonLRUCacheField = BlockIndexStore.class.getSuperclass().getDeclaredField("lruCache");
    carbonLRUCacheField.setAccessible(true);
    carbonLRUCache = (CarbonLRUCache) carbonLRUCacheField.get(executorCache);
    lruCacheMemorySizeField = CarbonLRUCache.class.getDeclaredField("lruCacheMemorySize");
    lruCacheMemorySizeField.setAccessible(true);
    lruCacheMemorySize = (long) lruCacheMemorySizeField.get(carbonLRUCache);
    String executorCacheSize = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_MAX_EXECUTOR_LRU_CACHE_SIZE);
    assertEquals(1024 * 1024 * Integer.parseInt(executorCacheSize), lruCacheMemorySize);
    cacheProvider.dropAllCache();
}
Also used : Field(java.lang.reflect.Field) BlockIndexStore(org.apache.carbondata.core.datastore.BlockIndexStore) TableBlockUniqueIdentifier(org.apache.carbondata.core.datastore.block.TableBlockUniqueIdentifier) SegmentTaskIndexStore(org.apache.carbondata.core.datastore.SegmentTaskIndexStore) TableSegmentUniqueIdentifier(org.apache.carbondata.core.datastore.TableSegmentUniqueIdentifier) Test(org.junit.Test)

Aggregations

TableSegmentUniqueIdentifier (org.apache.carbondata.core.datastore.TableSegmentUniqueIdentifier)6 SegmentTaskIndexStore (org.apache.carbondata.core.datastore.SegmentTaskIndexStore)3 AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)3 SegmentTaskIndexWrapper (org.apache.carbondata.core.datastore.block.SegmentTaskIndexWrapper)2 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)2 UpdateVO (org.apache.carbondata.core.mutate.UpdateVO)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 BlockIndexStore (org.apache.carbondata.core.datastore.BlockIndexStore)1 DataRefNode (org.apache.carbondata.core.datastore.DataRefNode)1 TableBlockUniqueIdentifier (org.apache.carbondata.core.datastore.block.TableBlockUniqueIdentifier)1 AbsoluteTableIdentifier (org.apache.carbondata.core.metadata.AbsoluteTableIdentifier)1 PartitionInfo (org.apache.carbondata.core.metadata.schema.PartitionInfo)1 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)1 Expression (org.apache.carbondata.core.scan.expression.Expression)1 FilterExpressionProcessor (org.apache.carbondata.core.scan.filter.FilterExpressionProcessor)1