Search in sources :

Example 1 with CoarseGrainIndex

use of org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex in project carbondata by apache.

the class BlockletIndexFactory method getIndexes.

@Override
public List<CoarseGrainIndex> getIndexes(Segment segment, Set<Path> partitionLocations) throws IOException {
    List<CoarseGrainIndex> indexes = new ArrayList<>();
    Set<TableBlockIndexUniqueIdentifier> identifiers = getTableBlockIndexUniqueIdentifiers(segment);
    List<TableBlockIndexUniqueIdentifierWrapper> tableBlockIndexUniqueIdentifierWrappers = new ArrayList<>(identifiers.size());
    getTableBlockUniqueIdentifierWrappers(partitionLocations, tableBlockIndexUniqueIdentifierWrappers, identifiers);
    List<BlockletIndexWrapper> blockletIndexWrappers = cache.getAll(tableBlockIndexUniqueIdentifierWrappers);
    for (BlockletIndexWrapper wrapper : blockletIndexWrappers) {
        indexes.addAll(wrapper.getIndexes());
    }
    return indexes;
}
Also used : TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex) BlockletIndexWrapper(org.apache.carbondata.core.indexstore.BlockletIndexWrapper)

Example 2 with CoarseGrainIndex

use of org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex in project carbondata by apache.

the class BlockletIndexFactory method getSegmentProperties.

@Override
public SegmentProperties getSegmentProperties(Segment segment, Set<Path> partitionLocations) throws IOException {
    List<CoarseGrainIndex> indexes = getIndexes(segment, partitionLocations);
    assert (indexes.size() > 0);
    CoarseGrainIndex coarseGrainIndex = indexes.get(0);
    assert (coarseGrainIndex instanceof BlockIndex);
    BlockIndex index = (BlockIndex) coarseGrainIndex;
    return index.getSegmentProperties();
}
Also used : CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)

Example 3 with CoarseGrainIndex

use of org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex in project carbondata by apache.

the class BlockletIndexFactory method getAllBlocklets.

@Override
public List<Blocklet> getAllBlocklets(Segment segment, Set<Path> partitionLocations) throws IOException {
    List<Blocklet> blocklets = new ArrayList<>();
    List<CoarseGrainIndex> indexes = getIndexes(segment, partitionLocations);
    if (indexes.size() == 0) {
        return blocklets;
    }
    SegmentProperties segmentProperties = getSegmentPropertiesFromIndex(indexes.get(0));
    for (CoarseGrainIndex index : indexes) {
        blocklets.addAll(index.prune(null, segmentProperties, null, this.getCarbonTable()));
    }
    return blocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) ArrayList(java.util.ArrayList) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties)

Example 4 with CoarseGrainIndex

use of org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex in project carbondata by apache.

the class BloomCoarseGrainIndexFactory method getIndexes.

@Override
public List<CoarseGrainIndex> getIndexes(Segment segment) throws IOException {
    List<CoarseGrainIndex> indexes = new ArrayList<>();
    try {
        Set<String> shardPaths = segmentMap.get(segment.getSegmentNo());
        if (shardPaths == null) {
            shardPaths = getAllShardPaths(getCarbonTable().getTablePath(), segment.getSegmentNo(), indexName);
            segmentMap.put(segment.getSegmentNo(), shardPaths);
        }
        Set<String> filteredShards = segment.getFilteredIndexShardNames();
        for (String shard : shardPaths) {
            if (shard.endsWith(BloomIndexFileStore.MERGE_BLOOM_INDEX_SHARD_NAME) || filteredShards.contains(new File(shard).getName())) {
                // Filter out the tasks which are filtered through Main index.
                // for merge shard, shard pruning delay to be done before pruning blocklet
                BloomCoarseGrainIndex bloomDM = new BloomCoarseGrainIndex();
                bloomDM.init(new BloomIndexModel(shard, cache, segment.getConfiguration()));
                bloomDM.initIndexColumnConverters(getCarbonTable(), indexMeta.getIndexedColumns());
                bloomDM.setFilteredShard(filteredShards);
                indexes.add(bloomDM);
            }
        }
    } catch (Exception e) {
        throw new IOException("Error occurs while init Bloom Index", e);
    }
    return indexes;
}
Also used : ArrayList(java.util.ArrayList) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex) IOException(java.io.IOException) CarbonFile(org.apache.carbondata.core.datastore.filesystem.CarbonFile) File(java.io.File) MalformedIndexCommandException(org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException) IOException(java.io.IOException)

Example 5 with CoarseGrainIndex

use of org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex in project carbondata by apache.

the class TableIndex method getBlockRowCount.

/**
 * Prune the index of the given segments and return the Map of blocklet path and row count
 *
 * @param allSegments
 * @param partitions
 * @return
 * @throws IOException
 */
public Map<String, Long> getBlockRowCount(List<Segment> allSegments, final List<PartitionSpec> partitions, TableIndex defaultIndex) throws IOException {
    List<Segment> segments = getCarbonSegments(allSegments);
    Map<String, Long> blockletToRowCountMap = new HashMap<>();
    for (Segment segment : segments) {
        List<CoarseGrainIndex> indexes = defaultIndex.getIndexFactory().getIndexes(segment);
        for (CoarseGrainIndex index : indexes) {
            if (null != partitions && !partitions.isEmpty()) {
                // partitions are dropped so return empty list.
                if (index.validatePartitionInfo(partitions)) {
                    return new HashMap<>();
                }
            }
            index.getRowCountForEachBlock(segment, partitions, blockletToRowCountMap);
        }
    }
    return blockletToRowCountMap;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)

Aggregations

CoarseGrainIndex (org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)8 ArrayList (java.util.ArrayList)5 BlockletIndexWrapper (org.apache.carbondata.core.indexstore.BlockletIndexWrapper)3 TableBlockIndexUniqueIdentifierWrapper (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)2 File (java.io.File)1 List (java.util.List)1 MalformedIndexCommandException (org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException)1 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)1 CarbonFile (org.apache.carbondata.core.datastore.filesystem.CarbonFile)1 Segment (org.apache.carbondata.core.index.Segment)1 Blocklet (org.apache.carbondata.core.indexstore.Blocklet)1 ExtendedBlocklet (org.apache.carbondata.core.indexstore.ExtendedBlocklet)1 SegmentMetaDataInfo (org.apache.carbondata.core.segmentmeta.SegmentMetaDataInfo)1