Search in sources :

Example 6 with CacheProvider

use of org.apache.carbondata.core.cache.CacheProvider in project carbondata by apache.

the class RowConverterImpl method initialize.

@Override
public void initialize() throws IOException {
    CacheProvider cacheProvider = CacheProvider.getInstance();
    cache = cacheProvider.createCache(CacheType.REVERSE_DICTIONARY, configuration.getTableIdentifier().getStorePath());
    String nullFormat = configuration.getDataLoadProperty(DataLoadProcessorConstants.SERIALIZATION_NULL_FORMAT).toString();
    boolean isEmptyBadRecord = Boolean.parseBoolean(configuration.getDataLoadProperty(DataLoadProcessorConstants.IS_EMPTY_DATA_BAD_RECORD).toString());
    List<FieldConverter> fieldConverterList = new ArrayList<>();
    localCaches = new Map[fields.length];
    long lruCacheStartTime = System.currentTimeMillis();
    DictionaryClient client = createDictionaryClient();
    dictClients.add(client);
    for (int i = 0; i < fields.length; i++) {
        localCaches[i] = new ConcurrentHashMap<>();
        FieldConverter fieldConverter = FieldEncoderFactory.getInstance().createFieldEncoder(fields[i], cache, configuration.getTableIdentifier().getCarbonTableIdentifier(), i, nullFormat, client, configuration.getUseOnePass(), configuration.getTableIdentifier().getStorePath(), true, localCaches[i], isEmptyBadRecord);
        fieldConverterList.add(fieldConverter);
    }
    CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordLruCacheLoadTime((System.currentTimeMillis() - lruCacheStartTime) / 1000.0);
    fieldConverters = fieldConverterList.toArray(new FieldConverter[fieldConverterList.size()]);
    logHolder = new BadRecordLogHolder();
}
Also used : DictionaryClient(org.apache.carbondata.core.dictionary.client.DictionaryClient) ArrayList(java.util.ArrayList) FieldConverter(org.apache.carbondata.processing.newflow.converter.FieldConverter) CacheProvider(org.apache.carbondata.core.cache.CacheProvider) BadRecordLogHolder(org.apache.carbondata.processing.newflow.converter.BadRecordLogHolder)

Example 7 with CacheProvider

use of org.apache.carbondata.core.cache.CacheProvider in project carbondata by apache.

the class SegmentTaskIndexStoreTest method setUp.

@BeforeClass
public static void setUp() {
    CacheProvider cacheProvider = CacheProvider.getInstance();
    taskIndexStore = (SegmentTaskIndexStore) cacheProvider.<TableSegmentUniqueIdentifier, SegmentTaskIndexWrapper>createCache(CacheType.DRIVER_BTREE, "");
    tableBlockInfo = new TableBlockInfo("file", 0L, "SG100", locations, 10L, ColumnarFormatVersion.valueOf(version));
    absoluteTableIdentifier = new AbsoluteTableIdentifier("/tmp", new CarbonTableIdentifier("testdatabase", "testtable", "TB100"));
}
Also used : TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) SegmentTaskIndexWrapper(org.apache.carbondata.core.datastore.block.SegmentTaskIndexWrapper) AbsoluteTableIdentifier(org.apache.carbondata.core.metadata.AbsoluteTableIdentifier) CacheProvider(org.apache.carbondata.core.cache.CacheProvider) BeforeClass(org.junit.BeforeClass)

Example 8 with CacheProvider

use of org.apache.carbondata.core.cache.CacheProvider in project carbondata by apache.

the class ForwardDictionaryCacheTest method createDictionaryCacheObject.

private void createDictionaryCacheObject() {
    // enable lru cache by setting cache size
    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_MAX_DRIVER_LRU_CACHE_SIZE, "10");
    CacheProvider cacheProvider = CacheProvider.getInstance();
    forwardDictionaryCache = cacheProvider.createCache(CacheType.FORWARD_DICTIONARY, this.carbonStorePath);
}
Also used : CacheProvider(org.apache.carbondata.core.cache.CacheProvider)

Example 9 with CacheProvider

use of org.apache.carbondata.core.cache.CacheProvider in project carbondata by apache.

the class DictionaryDecodeReadSupport method initialize.

/**
   * This initialization is done inside executor task
   * for column dictionary involved in decoding.
   *
   * @param carbonColumns column list
   * @param absoluteTableIdentifier table identifier
   */
@Override
public void initialize(CarbonColumn[] carbonColumns, AbsoluteTableIdentifier absoluteTableIdentifier) throws IOException {
    this.carbonColumns = carbonColumns;
    dictionaries = new Dictionary[carbonColumns.length];
    dataTypes = new DataType[carbonColumns.length];
    for (int i = 0; i < carbonColumns.length; i++) {
        if (carbonColumns[i].hasEncoding(Encoding.DICTIONARY) && !carbonColumns[i].hasEncoding(Encoding.DIRECT_DICTIONARY) && !carbonColumns[i].isComplex()) {
            CacheProvider cacheProvider = CacheProvider.getInstance();
            Cache<DictionaryColumnUniqueIdentifier, Dictionary> forwardDictionaryCache = cacheProvider.createCache(CacheType.FORWARD_DICTIONARY, absoluteTableIdentifier.getStorePath());
            dataTypes[i] = carbonColumns[i].getDataType();
            dictionaries[i] = forwardDictionaryCache.get(new DictionaryColumnUniqueIdentifier(absoluteTableIdentifier.getCarbonTableIdentifier(), carbonColumns[i].getColumnIdentifier(), dataTypes[i]));
        } else {
            dataTypes[i] = carbonColumns[i].getDataType();
        }
    }
}
Also used : Dictionary(org.apache.carbondata.core.cache.dictionary.Dictionary) DictionaryColumnUniqueIdentifier(org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier) CacheProvider(org.apache.carbondata.core.cache.CacheProvider)

Aggregations

CacheProvider (org.apache.carbondata.core.cache.CacheProvider)9 Dictionary (org.apache.carbondata.core.cache.dictionary.Dictionary)3 DictionaryColumnUniqueIdentifier (org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier)3 BeforeClass (org.junit.BeforeClass)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ForwardDictionary (org.apache.carbondata.core.cache.dictionary.ForwardDictionary)1 BlockIndexStore (org.apache.carbondata.core.datastore.BlockIndexStore)1 AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)1 SegmentTaskIndexWrapper (org.apache.carbondata.core.datastore.block.SegmentTaskIndexWrapper)1 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)1 TableBlockUniqueIdentifier (org.apache.carbondata.core.datastore.block.TableBlockUniqueIdentifier)1 DictionaryClient (org.apache.carbondata.core.dictionary.client.DictionaryClient)1 AbsoluteTableIdentifier (org.apache.carbondata.core.metadata.AbsoluteTableIdentifier)1 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)1 DataType (org.apache.carbondata.core.metadata.datatype.DataType)1 QueryMeasure (org.apache.carbondata.core.scan.model.QueryMeasure)1 QueryStatistic (org.apache.carbondata.core.stats.QueryStatistic)1 BadRecordLogHolder (org.apache.carbondata.processing.newflow.converter.BadRecordLogHolder)1 FieldConverter (org.apache.carbondata.processing.newflow.converter.FieldConverter)1