Search in sources :

Example 1 with SegmentBlockIndexInfo

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

the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifier.

private List<TableBlockIndexUniqueIdentifierWrapper> getTableBlockIndexUniqueIdentifier(IndexInputSplit distributable) throws IOException {
    List<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper = new ArrayList<>();
    SegmentBlockIndexInfo segmentBlockIndexInfo = segmentMap.get(distributable.getSegment().getSegmentNo());
    Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = null;
    if (null != segmentBlockIndexInfo) {
        tableBlockIndexUniqueIdentifiers = segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers();
    }
    if (tableBlockIndexUniqueIdentifiers == null) {
        tableBlockIndexUniqueIdentifiers = new HashSet<>();
        Set<String> indexFiles = distributable.getSegment().getCommittedIndexFile().keySet();
        for (String indexFile : indexFiles) {
            CarbonFile carbonFile = FileFactory.getCarbonFile(indexFile);
            String indexFileName;
            String mergeIndexName;
            if (indexFile.endsWith(CarbonTablePath.INDEX_FILE_EXT)) {
                indexFileName = carbonFile.getName();
                mergeIndexName = null;
            } else {
                indexFileName = carbonFile.getName();
                mergeIndexName = carbonFile.getName();
            }
            String parentPath = carbonFile.getParentFile().getAbsolutePath();
            TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier = new TableBlockIndexUniqueIdentifier(parentPath, indexFileName, mergeIndexName, distributable.getSegment().getSegmentNo());
            identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, this.getCarbonTable()));
            tableBlockIndexUniqueIdentifiers.add(tableBlockIndexUniqueIdentifier);
        }
        segmentMap.put(distributable.getSegment().getSegmentNo(), new SegmentBlockIndexInfo(tableBlockIndexUniqueIdentifiers, distributable.getSegment().getSegmentMetaDataInfo()));
    } else {
        for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : tableBlockIndexUniqueIdentifiers) {
            identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, getCarbonTable()));
        }
    }
    return identifiersWrapper;
}
Also used : CarbonFile(org.apache.carbondata.core.datastore.filesystem.CarbonFile) SegmentBlockIndexInfo(org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo) TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)

Example 2 with SegmentBlockIndexInfo

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

the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifiers.

public Set<TableBlockIndexUniqueIdentifier> getTableBlockIndexUniqueIdentifiers(Segment segment) throws IOException {
    SegmentBlockIndexInfo segmentBlockIndexInfo = segmentMap.get(segment.getSegmentNo());
    Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = null;
    if (null != segmentBlockIndexInfo && CollectionUtils.isNotEmpty(segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers())) {
        if (null != segmentBlockIndexInfo.getSegmentMetaDataInfo()) {
            segment.setSegmentMetaDataInfo(segmentMap.get(segment.getSegmentNo()).getSegmentMetaDataInfo());
        }
        return segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers();
    } else {
        tableBlockIndexUniqueIdentifiers = BlockletIndexUtil.getTableBlockUniqueIdentifiers(segment);
        if (tableBlockIndexUniqueIdentifiers.size() > 0) {
            segmentMap.put(segment.getSegmentNo(), new SegmentBlockIndexInfo(tableBlockIndexUniqueIdentifiers, segment.getSegmentMetaDataInfo()));
        }
    }
    return tableBlockIndexUniqueIdentifiers;
}
Also used : SegmentBlockIndexInfo(org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)

Example 3 with SegmentBlockIndexInfo

use of org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo 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 4 with SegmentBlockIndexInfo

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

the class BlockletIndexFactory method getCacheSize.

@Override
public String getCacheSize() {
    long sum = 0L;
    int numOfIndexFiles = 0;
    for (Map.Entry<String, SegmentBlockIndexInfo> entry : segmentMap.entrySet()) {
        for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : entry.getValue().getTableBlockIndexUniqueIdentifiers()) {
            BlockletIndexWrapper blockletIndexWrapper = cache.getIfPresent(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, getCarbonTable()));
            if (blockletIndexWrapper != null) {
                sum += blockletIndexWrapper.getMemorySize();
                numOfIndexFiles++;
            }
        }
    }
    return numOfIndexFiles + ":" + sum;
}
Also used : SegmentBlockIndexInfo(org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo) TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BlockletIndexWrapper(org.apache.carbondata.core.indexstore.BlockletIndexWrapper)

Aggregations

SegmentBlockIndexInfo (org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo)4 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)4 TableBlockIndexUniqueIdentifierWrapper (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper)3 BlockletIndexWrapper (org.apache.carbondata.core.indexstore.BlockletIndexWrapper)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CarbonFile (org.apache.carbondata.core.datastore.filesystem.CarbonFile)1 CacheableIndex (org.apache.carbondata.core.index.dev.CacheableIndex)1 Index (org.apache.carbondata.core.index.dev.Index)1 CoarseGrainIndex (org.apache.carbondata.core.index.dev.cgindex.CoarseGrainIndex)1