Search in sources :

Example 6 with TableBlockIndexUniqueIdentifierWrapper

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

the class BlockletIndexFactory method getExtendedBlocklets.

/**
 * Get the blocklet detail information based on blockletId, blockId and segmentId. This method is
 * exclusively for BlockletIndexFactory as detail information is only available in this
 * default index.
 */
@Override
public List<ExtendedBlocklet> getExtendedBlocklets(List<Blocklet> blocklets, Segment segment) throws IOException {
    List<ExtendedBlocklet> detailedBlocklets = new ArrayList<>(blocklets.size() + 1);
    // if the blocklets is empty, return the empty detailed blocklets list directly.
    if (blocklets.size() == 0) {
        return detailedBlocklets;
    }
    // If it is already detailed blocklet then type cast and return same
    if (blocklets.size() > 0 && blocklets.get(0) instanceof ExtendedBlocklet) {
        for (Blocklet blocklet : blocklets) {
            detailedBlocklets.add((ExtendedBlocklet) blocklet);
        }
        return detailedBlocklets;
    }
    Set<TableBlockIndexUniqueIdentifier> identifiers = getTableBlockIndexUniqueIdentifiers(segment);
    Set<TableBlockIndexUniqueIdentifierWrapper> tableBlockIndexUniqueIdentifierWrappers = new HashSet<>(identifiers.size());
    for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : identifiers) {
        tableBlockIndexUniqueIdentifierWrappers.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, this.getCarbonTable()));
    }
    // Retrieve each blocklets detail information from blocklet index
    for (Blocklet blocklet : blocklets) {
        detailedBlocklets.add(getExtendedBlocklet(tableBlockIndexUniqueIdentifierWrappers, blocklet));
    }
    return detailedBlocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) HashSet(java.util.HashSet)

Example 7 with TableBlockIndexUniqueIdentifierWrapper

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

the class BlockletIndexFactory method clear.

@Override
public void clear(String segment) {
    SegmentBlockIndexInfo segmentBlockIndexInfo = segmentMap.remove(segment);
    Set<TableBlockIndexUniqueIdentifier> blockIndexes = null;
    if (null != segmentBlockIndexInfo) {
        blockIndexes = segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers();
    }
    if (blockIndexes != null) {
        for (TableBlockIndexUniqueIdentifier blockIndex : blockIndexes) {
            TableBlockIndexUniqueIdentifierWrapper blockIndexWrapper = new TableBlockIndexUniqueIdentifierWrapper(blockIndex, this.getCarbonTable());
            BlockletIndexWrapper wrapper = cache.getIfPresent(blockIndexWrapper);
            if (null != wrapper) {
                List<BlockIndex> indexes = wrapper.getIndexes();
                for (Index index : indexes) {
                    if (index != null) {
                        cache.invalidate(blockIndexWrapper);
                        index.clear();
                    }
                }
            }
        }
    }
}
Also used : SegmentBlockIndexInfo(org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo) TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) Index(org.apache.carbondata.core.index.dev.Index) CacheableIndex(org.apache.carbondata.core.index.dev.CacheableIndex) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex) BlockletIndexWrapper(org.apache.carbondata.core.indexstore.BlockletIndexWrapper)

Example 8 with TableBlockIndexUniqueIdentifierWrapper

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

the class BlockletIndexFactory method getAllUncached.

@Override
public List<IndexInputSplit> getAllUncached(List<IndexInputSplit> distributableList) throws IOException {
    List<IndexInputSplit> distributableToBeLoaded = new ArrayList<>(distributableList.size());
    for (IndexInputSplit distributable : distributableList) {
        Segment segment = distributable.getSegment();
        Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = getTableBlockIndexUniqueIdentifiers(segment);
        // filter out the tableBlockIndexUniqueIdentifiers based on distributable
        TableBlockIndexUniqueIdentifier validIdentifier = BlockletIndexUtil.filterIdentifiersBasedOnDistributable(tableBlockIndexUniqueIdentifiers, (BlockletIndexInputSplit) distributable);
        if (null == cache.getIfPresent(new TableBlockIndexUniqueIdentifierWrapper(validIdentifier, this.getCarbonTable()))) {
            ((BlockletIndexInputSplit) distributable).setTableBlockIndexUniqueIdentifier(validIdentifier);
            distributableToBeLoaded.add(distributable);
        }
    }
    return distributableToBeLoaded;
}
Also used : TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) IndexInputSplit(org.apache.carbondata.core.index.IndexInputSplit) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) Segment(org.apache.carbondata.core.index.Segment)

Example 9 with TableBlockIndexUniqueIdentifierWrapper

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

the class BlockletIndexFactory method getExtendedBlocklet.

private ExtendedBlocklet getExtendedBlocklet(Set<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper, Blocklet blocklet) throws IOException {
    for (TableBlockIndexUniqueIdentifierWrapper identifierWrapper : identifiersWrapper) {
        BlockletIndexWrapper wrapper = cache.get(identifierWrapper);
        List<BlockIndex> indexes = wrapper.getIndexes();
        for (Index index : indexes) {
            if (((BlockIndex) index).getTableTaskInfo(BlockletIndexRowIndexes.SUMMARY_INDEX_FILE_NAME).startsWith(blocklet.getFilePath())) {
                return ((BlockIndex) index).getDetailedBlocklet(blocklet.getBlockletId());
            }
        }
    }
    throw new IOException("Blocklet not found: " + blocklet.toString());
}
Also used : TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) Index(org.apache.carbondata.core.index.dev.Index) CacheableIndex(org.apache.carbondata.core.index.dev.CacheableIndex) CoarseGrainIndex(org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex) IOException(java.io.IOException) BlockletIndexWrapper(org.apache.carbondata.core.indexstore.BlockletIndexWrapper)

Example 10 with TableBlockIndexUniqueIdentifierWrapper

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

the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifier.

private List<TableBlockIndexUniqueIdentifierWrapper> getTableBlockIndexUniqueIdentifier(String indexFilePath, String segmentId) throws IOException {
    List<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper = new ArrayList<>();
    String parent = indexFilePath.substring(0, indexFilePath.lastIndexOf("/"));
    String name = indexFilePath.substring(indexFilePath.lastIndexOf("/") + 1);
    if (indexFilePath.endsWith(CarbonTablePath.INDEX_FILE_EXT)) {
        identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(new TableBlockIndexUniqueIdentifier(parent, name, null, segmentId), this.getCarbonTable()));
    } else if (indexFilePath.endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) {
        SegmentIndexFileStore fileStore = new SegmentIndexFileStore();
        List<String> indexFiles = fileStore.getIndexFilesFromMergeFile(indexFilePath);
        for (String indexFile : indexFiles) {
            identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(new TableBlockIndexUniqueIdentifier(parent, indexFile, name, segmentId), this.getCarbonTable()));
        }
    }
    return identifiersWrapper;
}
Also used : TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

TableBlockIndexUniqueIdentifierWrapper (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper)15 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)13 ArrayList (java.util.ArrayList)9 BlockletIndexWrapper (org.apache.carbondata.core.indexstore.BlockletIndexWrapper)8 CoarseGrainIndex (org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)5 HashMap (java.util.HashMap)4 Segment (org.apache.carbondata.core.index.Segment)4 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 IndexInputSplit (org.apache.carbondata.core.index.IndexInputSplit)3 SegmentBlockIndexInfo (org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 CacheableIndex (org.apache.carbondata.core.index.dev.CacheableIndex)2 Index (org.apache.carbondata.core.index.dev.Index)2 ExtendedBlocklet (org.apache.carbondata.core.indexstore.ExtendedBlocklet)2 BitSet (java.util.BitSet)1 Iterator (java.util.Iterator)1 MockUp (mockit.MockUp)1