Search in sources :

Example 6 with BlockInfo

use of org.apache.carbondata.core.datastore.block.BlockInfo in project carbondata by apache.

the class AbstractBlockIndexStoreCache method checkAndLoadTableBlocks.

/**
   * This method will get the value for the given key. If value does not exist
   * for the given key, it will check and load the value.
   *
   * @param tableBlock
   * @param tableBlockUniqueIdentifier
   * @param lruCacheKey
   */
protected void checkAndLoadTableBlocks(AbstractIndex tableBlock, TableBlockUniqueIdentifier tableBlockUniqueIdentifier, String lruCacheKey) throws IOException {
    // calculate the required size is
    TableBlockInfo blockInfo = tableBlockUniqueIdentifier.getTableBlockInfo();
    long requiredMetaSize = CarbonUtil.calculateMetaSize(blockInfo);
    if (requiredMetaSize > 0) {
        tableBlock.setMemorySize(requiredMetaSize);
        // load table blocks data
        // getting the data file meta data of the block
        DataFileFooter footer = CarbonUtil.readMetadatFile(blockInfo);
        footer.setBlockInfo(new BlockInfo(blockInfo));
        // building the block
        tableBlock.buildIndex(Collections.singletonList(footer));
        tableBlock.incrementAccessCount();
        boolean isTableBlockAddedToLruCache = lruCache.put(lruCacheKey, tableBlock, requiredMetaSize);
        if (!isTableBlockAddedToLruCache) {
            throw new IndexBuilderException("Cannot load table blocks into memory. Not enough memory available");
        }
    } else {
        throw new IndexBuilderException("Invalid carbon data file: " + blockInfo.getFilePath());
    }
}
Also used : TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) BlockInfo(org.apache.carbondata.core.datastore.block.BlockInfo) TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) IndexBuilderException(org.apache.carbondata.core.datastore.exception.IndexBuilderException)

Example 7 with BlockInfo

use of org.apache.carbondata.core.datastore.block.BlockInfo in project carbondata by apache.

the class BlockIndexStore method getIfPresent.

/**
   * method returns the B-Tree meta
   *
   * @param tableBlockUniqueIdentifier Unique table block info
   * @return
   */
@Override
public AbstractIndex getIfPresent(TableBlockUniqueIdentifier tableBlockUniqueIdentifier) {
    BlockInfo blockInfo = new BlockInfo(tableBlockUniqueIdentifier.getTableBlockInfo());
    BlockIndex cacheable = (BlockIndex) lruCache.get(getLruCacheKey(tableBlockUniqueIdentifier.getAbsoluteTableIdentifier(), blockInfo));
    if (null != cacheable) {
        cacheable.incrementAccessCount();
    }
    return cacheable;
}
Also used : BlockInfo(org.apache.carbondata.core.datastore.block.BlockInfo) TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) BlockIndex(org.apache.carbondata.core.datastore.block.BlockIndex)

Example 8 with BlockInfo

use of org.apache.carbondata.core.datastore.block.BlockInfo in project carbondata by apache.

the class BlockIndexStore method removeTableBlocks.

/**
   * This will be used to remove a particular blocks useful in case of
   * deletion of some of the blocks in case of retention or may be some other
   * scenario
   *
   * @param segmentIds              list of table blocks to be removed
   * @param absoluteTableIdentifier absolute table identifier
   */
public void removeTableBlocks(List<String> segmentIds, AbsoluteTableIdentifier absoluteTableIdentifier) {
    if (null == segmentIds) {
        return;
    }
    for (String segmentId : segmentIds) {
        TableSegmentUniqueIdentifier tableSegmentUniqueIdentifier = new TableSegmentUniqueIdentifier(absoluteTableIdentifier, segmentId);
        List<BlockInfo> blockInfos = segmentIdToBlockListMap.remove(tableSegmentUniqueIdentifier.getUniqueTableSegmentIdentifier());
        if (null != blockInfos) {
            for (BlockInfo blockInfo : blockInfos) {
                String lruCacheKey = getLruCacheKey(absoluteTableIdentifier, blockInfo);
                lruCache.remove(lruCacheKey);
            }
        }
    }
}
Also used : BlockInfo(org.apache.carbondata.core.datastore.block.BlockInfo) TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo)

Aggregations

BlockInfo (org.apache.carbondata.core.datastore.block.BlockInfo)8 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)8 AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)2 BlockIndex (org.apache.carbondata.core.datastore.block.BlockIndex)2 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 IndexBuilderException (org.apache.carbondata.core.datastore.exception.IndexBuilderException)1 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)1 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)1 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)1 UpdateVO (org.apache.carbondata.core.mutate.UpdateVO)1 CarbonIndexFileReader (org.apache.carbondata.core.reader.CarbonIndexFileReader)1 BlockIndex (org.apache.carbondata.format.BlockIndex)1