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