Search in sources :

Example 1 with ExtendedBlocklet

use of org.apache.carbondata.core.indexstore.ExtendedBlocklet in project carbondata by apache.

the class AndDataMapExprWrapper method prune.

@Override
public List<ExtendedBlocklet> prune(List<Segment> segments, List<PartitionSpec> partitionsToPrune) throws IOException {
    List<ExtendedBlocklet> leftPrune = left.prune(segments, partitionsToPrune);
    List<ExtendedBlocklet> rightPrune = right.prune(segments, partitionsToPrune);
    List<ExtendedBlocklet> andBlocklets = new ArrayList<>();
    for (ExtendedBlocklet blocklet : leftPrune) {
        if (rightPrune.contains(blocklet)) {
            andBlocklets.add(blocklet);
        }
    }
    return andBlocklets;
}
Also used : ArrayList(java.util.ArrayList) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet)

Example 2 with ExtendedBlocklet

use of org.apache.carbondata.core.indexstore.ExtendedBlocklet in project carbondata by apache.

the class TableDataMap method prune.

/**
 * Pass the valid segments and prune the datamap using filter expression
 *
 * @param segments
 * @param filterExp
 * @return
 */
public List<ExtendedBlocklet> prune(List<Segment> segments, FilterResolverIntf filterExp, List<PartitionSpec> partitions) throws IOException {
    List<ExtendedBlocklet> blocklets = new ArrayList<>();
    SegmentProperties segmentProperties;
    for (Segment segment : segments) {
        List<Blocklet> pruneBlocklets = new ArrayList<>();
        // if filter is not passed then return all the blocklets
        if (filterExp == null) {
            pruneBlocklets = blockletDetailsFetcher.getAllBlocklets(segment, partitions);
        } else {
            List<DataMap> dataMaps = dataMapFactory.getDataMaps(segment);
            segmentProperties = segmentPropertiesFetcher.getSegmentProperties(segment);
            for (DataMap dataMap : dataMaps) {
                pruneBlocklets.addAll(dataMap.prune(filterExp, segmentProperties, partitions));
            }
        }
        blocklets.addAll(addSegmentId(blockletDetailsFetcher.getExtendedBlocklets(pruneBlocklets, segment), segment.getSegmentNo()));
    }
    return blocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) FineGrainBlocklet(org.apache.carbondata.core.datamap.dev.fgdatamap.FineGrainBlocklet) ArrayList(java.util.ArrayList) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) DataMap(org.apache.carbondata.core.datamap.dev.DataMap)

Example 3 with ExtendedBlocklet

use of org.apache.carbondata.core.indexstore.ExtendedBlocklet in project carbondata by apache.

the class TableDataMap method prune.

/**
 * This method is used from any machine after it is distributed. It takes the distributable object
 * to prune the filters.
 *
 * @param distributable
 * @param filterExp
 * @return
 */
public List<ExtendedBlocklet> prune(DataMapDistributable distributable, FilterResolverIntf filterExp, List<PartitionSpec> partitions) throws IOException {
    List<ExtendedBlocklet> detailedBlocklets = new ArrayList<>();
    List<Blocklet> blocklets = new ArrayList<>();
    List<DataMap> dataMaps = dataMapFactory.getDataMaps(distributable);
    for (DataMap dataMap : dataMaps) {
        blocklets.addAll(dataMap.prune(filterExp, segmentPropertiesFetcher.getSegmentProperties(distributable.getSegment()), partitions));
    }
    BlockletSerializer serializer = new BlockletSerializer();
    String writePath = identifier.getTablePath() + CarbonCommonConstants.FILE_SEPARATOR + dataMapSchema.getDataMapName();
    if (dataMapFactory.getDataMapType() == DataMapLevel.FG) {
        FileFactory.mkdirs(writePath, FileFactory.getFileType(writePath));
    }
    for (Blocklet blocklet : blocklets) {
        ExtendedBlocklet detailedBlocklet = blockletDetailsFetcher.getExtendedBlocklet(blocklet, distributable.getSegment());
        if (dataMapFactory.getDataMapType() == DataMapLevel.FG) {
            String blockletwritePath = writePath + CarbonCommonConstants.FILE_SEPARATOR + System.nanoTime();
            detailedBlocklet.setDataMapWriterPath(blockletwritePath);
            serializer.serializeBlocklet((FineGrainBlocklet) blocklet, blockletwritePath);
        }
        detailedBlocklet.setSegmentId(distributable.getSegment().getSegmentNo());
        detailedBlocklets.add(detailedBlocklet);
    }
    return detailedBlocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) FineGrainBlocklet(org.apache.carbondata.core.datamap.dev.fgdatamap.FineGrainBlocklet) ArrayList(java.util.ArrayList) BlockletSerializer(org.apache.carbondata.core.datamap.dev.BlockletSerializer) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) DataMap(org.apache.carbondata.core.datamap.dev.DataMap)

Example 4 with ExtendedBlocklet

use of org.apache.carbondata.core.indexstore.ExtendedBlocklet in project carbondata by apache.

the class AndDataMapExprWrapper method pruneBlocklets.

@Override
public List<ExtendedBlocklet> pruneBlocklets(List<ExtendedBlocklet> blocklets) throws IOException {
    List<ExtendedBlocklet> leftPrune = left.pruneBlocklets(blocklets);
    List<ExtendedBlocklet> rightPrune = right.pruneBlocklets(blocklets);
    List<ExtendedBlocklet> andBlocklets = new ArrayList<>();
    for (ExtendedBlocklet blocklet : leftPrune) {
        if (rightPrune.contains(blocklet)) {
            andBlocklets.add(blocklet);
        }
    }
    return andBlocklets;
}
Also used : ArrayList(java.util.ArrayList) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet)

Example 5 with ExtendedBlocklet

use of org.apache.carbondata.core.indexstore.ExtendedBlocklet in project carbondata by apache.

the class BlockletDataMap method createBlocklet.

private ExtendedBlocklet createBlocklet(DataMapRow row, int blockletId) {
    ExtendedBlocklet blocklet = new ExtendedBlocklet(new String(row.getByteArray(FILE_PATH_INDEX), CarbonCommonConstants.DEFAULT_CHARSET_CLASS), blockletId + "");
    BlockletDetailInfo detailInfo = new BlockletDetailInfo();
    detailInfo.setRowCount(row.getInt(ROW_COUNT_INDEX));
    detailInfo.setPagesCount(row.getShort(PAGE_COUNT_INDEX));
    detailInfo.setVersionNumber(row.getShort(VERSION_INDEX));
    detailInfo.setBlockletId((short) blockletId);
    detailInfo.setDimLens(columnCardinality);
    detailInfo.setSchemaUpdatedTimeStamp(row.getLong(SCHEMA_UPADATED_TIME_INDEX));
    byte[] byteArray = row.getByteArray(BLOCK_INFO_INDEX);
    BlockletInfo blockletInfo = null;
    try {
        if (byteArray.length > 0) {
            blockletInfo = new BlockletInfo();
            ByteArrayInputStream stream = new ByteArrayInputStream(byteArray);
            DataInputStream inputStream = new DataInputStream(stream);
            blockletInfo.readFields(inputStream);
            inputStream.close();
        }
        blocklet.setLocation(new String(row.getByteArray(LOCATIONS), CarbonCommonConstants.DEFAULT_CHARSET).split(","));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    detailInfo.setBlockletInfo(blockletInfo);
    blocklet.setDetailInfo(detailInfo);
    detailInfo.setBlockFooterOffset(row.getLong(BLOCK_FOOTER_OFFSET));
    detailInfo.setColumnSchemaBinary(getColumnSchemaBinary());
    detailInfo.setBlockSize(row.getLong(BLOCK_LENGTH));
    return blocklet;
}
Also used : BlockletDetailInfo(org.apache.carbondata.core.indexstore.BlockletDetailInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) BlockletInfo(org.apache.carbondata.core.metadata.blocklet.BlockletInfo) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet)

Aggregations

ExtendedBlocklet (org.apache.carbondata.core.indexstore.ExtendedBlocklet)9 ArrayList (java.util.ArrayList)6 Blocklet (org.apache.carbondata.core.indexstore.Blocklet)3 TableDataMap (org.apache.carbondata.core.datamap.TableDataMap)2 DataMap (org.apache.carbondata.core.datamap.dev.DataMap)2 FineGrainBlocklet (org.apache.carbondata.core.datamap.dev.fgdatamap.FineGrainBlocklet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Segment (org.apache.carbondata.core.datamap.Segment)1 BlockletSerializer (org.apache.carbondata.core.datamap.dev.BlockletSerializer)1 DataMapDistributableWrapper (org.apache.carbondata.core.datamap.dev.expr.DataMapDistributableWrapper)1 DataMapExprWrapper (org.apache.carbondata.core.datamap.dev.expr.DataMapExprWrapper)1 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)1 BlockletDetailInfo (org.apache.carbondata.core.indexstore.BlockletDetailInfo)1 PartitionSpec (org.apache.carbondata.core.indexstore.PartitionSpec)1 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)1 BlockletDataMapFactory (org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMapFactory)1