Search in sources :

Example 1 with SegmentTaskIndex

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;
}
Also used : DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) AbstractIndex(org.apache.carbondata.core.datastore.block.AbstractIndex) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) SegmentTaskIndex(org.apache.carbondata.core.datastore.block.SegmentTaskIndex)

Aggregations

AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)1 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)1 SegmentTaskIndex (org.apache.carbondata.core.datastore.block.SegmentTaskIndex)1 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)1 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)1