Search in sources :

Example 16 with Blocklet

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

the class MinMaxIndex method prune.

/**
 * Block Prunning logic for Min Max Index.
 *
 * @param filterExp
 * @param segmentProperties
 * @return
 */
@Override
public List<Blocklet> prune(FilterResolverIntf filterExp, SegmentProperties segmentProperties, List<PartitionSpec> partitions) {
    List<Blocklet> blocklets = new ArrayList<>();
    if (filterExp == null) {
        for (int i = 0; i < readMinMaxIndex.length; i++) {
            for (int j = 0; j < readMinMaxIndex[i].length; j++) {
                blocklets.add(new Blocklet(indexFilePath[i], String.valueOf(readMinMaxIndex[i][j].getBlockletId())));
            }
        }
    } else {
        FilterExecuter filterExecuter = FilterUtil.getFilterExecuterTree(filterExp, segmentProperties, null, false);
        for (int blkIdx = 0; blkIdx < readMinMaxIndex.length; blkIdx++) {
            for (int blkltIdx = 0; blkltIdx < readMinMaxIndex[blkIdx].length; blkltIdx++) {
                BitSet bitSet = filterExecuter.isScanRequired(readMinMaxIndex[blkIdx][blkltIdx].getMaxValues(), readMinMaxIndex[blkIdx][blkltIdx].getMinValues(), null);
                if (!bitSet.isEmpty()) {
                    String blockFileName = indexFilePath[blkIdx].substring(indexFilePath[blkIdx].lastIndexOf(File.separatorChar) + 1, indexFilePath[blkIdx].indexOf(".minmaxindex"));
                    Blocklet blocklet = new Blocklet(blockFileName, String.valueOf(readMinMaxIndex[blkIdx][blkltIdx].getBlockletId()));
                    LOGGER.info(String.format("Need to scan block#%s -> blocklet#%s, %s", blkIdx, blkltIdx, blocklet));
                    blocklets.add(blocklet);
                } else {
                    LOGGER.info(String.format("Skip scan block#%s -> blocklet#%s", blkIdx, blkltIdx));
                }
            }
        }
    }
    return blocklets;
}
Also used : Blocklet(org.apache.carbondata.core.indexstore.Blocklet) ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) FilterExecuter(org.apache.carbondata.core.scan.filter.executer.FilterExecuter)

Aggregations

ArrayList (java.util.ArrayList)16 Blocklet (org.apache.carbondata.core.indexstore.Blocklet)16 ExtendedBlocklet (org.apache.carbondata.core.indexstore.ExtendedBlocklet)12 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)5 CoarseGrainIndex (org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)4 HashSet (java.util.HashSet)3 Index (org.apache.carbondata.core.index.dev.Index)3 FineGrainBlocklet (org.apache.carbondata.core.index.dev.fgindex.FineGrainBlocklet)3 BlockIndex (org.apache.carbondata.core.indexstore.blockletindex.BlockIndex)3 FilterExecuter (org.apache.carbondata.core.scan.filter.executer.FilterExecuter)3 FilterExecutor (org.apache.carbondata.core.scan.filter.executer.FilterExecutor)3 BitSet (java.util.BitSet)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 DataMap (org.apache.carbondata.core.datamap.dev.DataMap)2 CoarseGrainDataMap (org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)2 FineGrainBlocklet (org.apache.carbondata.core.datamap.dev.fgdatamap.FineGrainBlocklet)2 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)2 Expression (org.apache.carbondata.core.scan.expression.Expression)2 IOException (java.io.IOException)1