use of org.apache.carbondata.core.datastore.block.SegmentTaskIndex in project carbondata by apache.
the class SegmentTaskIndexStore method loadBlocks.
/**
* Below method will be used to load the blocks
*
* @param tableBlockInfoList
* @return loaded segment
* @throws IOException
*/
private AbstractIndex loadBlocks(TaskBucketHolder taskBucketHolder, List<TableBlockInfo> tableBlockInfoList, AbsoluteTableIdentifier tableIdentifier) throws IOException {
// all the block of one task id will be loaded together
// so creating a list which will have all the data file meta data to of one task
List<DataFileFooter> footerList = CarbonUtil.readCarbonIndexFile(taskBucketHolder.taskNo, taskBucketHolder.bucketNumber, tableBlockInfoList, tableIdentifier);
// Reuse SegmentProperties object if tableIdentifier, columnsInTable and columnCardinality are
// the same.
List<ColumnSchema> columnsInTable = footerList.get(0).getColumnInTable();
int[] columnCardinality = footerList.get(0).getSegmentInfo().getColumnCardinality();
SegmentPropertiesWrapper segmentPropertiesWrapper = new SegmentPropertiesWrapper(tableIdentifier, columnsInTable, columnCardinality);
SegmentProperties segmentProperties;
if (this.segmentProperties.containsKey(segmentPropertiesWrapper)) {
segmentProperties = this.segmentProperties.get(segmentPropertiesWrapper);
} else {
// create a metadata details
// this will be useful in query handling
// all the data file metadata will have common segment properties we
// can use first one to get create the segment properties
segmentProperties = new SegmentProperties(columnsInTable, columnCardinality);
this.segmentProperties.put(segmentPropertiesWrapper, segmentProperties);
}
AbstractIndex segment = new SegmentTaskIndex(segmentProperties);
// file path of only first block is passed as it all table block info path of
// same task id will be same
segment.buildIndex(footerList);
return segment;
}
Aggregations