Search in sources :

Example 26 with DataFileFooter

use of org.apache.carbondata.core.metadata.blocklet.DataFileFooter in project carbondata by apache.

the class CarbonCompactionExecutor method processTableBlocks.

/**
   * For processing of the table blocks.
   *
   * @return List of Carbon iterators
   */
public List<RawResultIterator> processTableBlocks() throws QueryExecutionException, IOException {
    List<RawResultIterator> resultList = new ArrayList<>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
    List<TableBlockInfo> list = null;
    queryModel = prepareQueryModel(list);
    // iterate each seg ID
    for (Map.Entry<String, TaskBlockInfo> taskMap : segmentMapping.entrySet()) {
        String segmentId = taskMap.getKey();
        List<DataFileFooter> listMetadata = dataFileMetadataSegMapping.get(segmentId);
        SegmentProperties sourceSegProperties = getSourceSegmentProperties(listMetadata);
        // for each segment get taskblock info
        TaskBlockInfo taskBlockInfo = taskMap.getValue();
        Set<String> taskBlockListMapping = taskBlockInfo.getTaskSet();
        for (String task : taskBlockListMapping) {
            list = taskBlockInfo.getTableBlockInfoList(task);
            Collections.sort(list);
            LOGGER.info("for task -" + task + "-block size is -" + list.size());
            queryModel.setTableBlockInfos(list);
            resultList.add(new RawResultIterator(executeBlockList(list), sourceSegProperties, destinationSegProperties));
        }
    }
    return resultList;
}
Also used : TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) RawResultIterator(org.apache.carbondata.core.scan.result.iterator.RawResultIterator) ArrayList(java.util.ArrayList) DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) TaskBlockInfo(org.apache.carbondata.core.datastore.block.TaskBlockInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Example 27 with DataFileFooter

use of org.apache.carbondata.core.metadata.blocklet.DataFileFooter in project carbondata by apache.

the class SegmentTaskIndex method buildIndex.

/**
   * Below method is store the blocks in some data structure
   *
   */
public void buildIndex(List<DataFileFooter> footerList) {
    // create a segment builder info
    // in case of segment create we do not need any file path and each column value size
    // as Btree will be build as per min max and start key
    BTreeBuilderInfo btreeBuilderInfo = new BTreeBuilderInfo(footerList, null);
    BtreeBuilder blocksBuilder = new BlockBTreeBuilder();
    // load the metadata
    blocksBuilder.build(btreeBuilderInfo);
    dataRefNode = blocksBuilder.get();
    for (DataFileFooter footer : footerList) {
        totalNumberOfRows += footer.getNumberOfRows();
    }
}
Also used : DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) BTreeBuilderInfo(org.apache.carbondata.core.datastore.BTreeBuilderInfo) BlockBTreeBuilder(org.apache.carbondata.core.datastore.impl.btree.BlockBTreeBuilder) BtreeBuilder(org.apache.carbondata.core.datastore.BtreeBuilder)

Example 28 with DataFileFooter

use of org.apache.carbondata.core.metadata.blocklet.DataFileFooter 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 29 with DataFileFooter

use of org.apache.carbondata.core.metadata.blocklet.DataFileFooter in project carbondata by apache.

the class SegmentTaskIndexStoreTest method getDataFileFooters.

private List<DataFileFooter> getDataFileFooters() {
    SegmentInfo segmentInfo = new SegmentInfo();
    DataFileFooter footer = new DataFileFooter();
    ColumnSchema columnSchema = new ColumnSchema();
    BlockletInfo blockletInfo = new BlockletInfo();
    List<DataFileFooter> footerList = new ArrayList<DataFileFooter>();
    List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>();
    columnSchema.setColumnName("employeeName");
    columnSchemaList.add(new ColumnSchema());
    footer.setSegmentInfo(segmentInfo);
    footer.setColumnInTable(columnSchemaList);
    footer.setBlockletList(Arrays.asList(blockletInfo));
    footerList.add(footer);
    return footerList;
}
Also used : DataFileFooter(org.apache.carbondata.core.metadata.blocklet.DataFileFooter) BlockletInfo(org.apache.carbondata.core.metadata.blocklet.BlockletInfo) ArrayList(java.util.ArrayList) SegmentInfo(org.apache.carbondata.core.metadata.blocklet.SegmentInfo) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Aggregations

DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)29 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)10 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)9 ByteBuffer (java.nio.ByteBuffer)8 BTreeBuilderInfo (org.apache.carbondata.core.datastore.BTreeBuilderInfo)8 BtreeBuilder (org.apache.carbondata.core.datastore.BtreeBuilder)8 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)8 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)7 DataRefNode (org.apache.carbondata.core.datastore.DataRefNode)6 KeyGenerator (org.apache.carbondata.core.keygenerator.KeyGenerator)6 MultiDimKeyVarLengthGenerator (org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator)6 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)6 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)6 DataRefNodeFinder (org.apache.carbondata.core.datastore.DataRefNodeFinder)5 IndexKey (org.apache.carbondata.core.datastore.IndexKey)5 HashMap (java.util.HashMap)3 MockUp (mockit.MockUp)3 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)3 BlockletBTreeIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletBTreeIndex)3