Search in sources :

Example 1 with TableBlockIndexUniqueIdentifier

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

the class BlockletDataMapFactory method getDataMaps.

@Override
public List<CoarseGrainDataMap> getDataMaps(DataMapDistributable distributable) throws IOException {
    BlockletDataMapDistributable mapDistributable = (BlockletDataMapDistributable) distributable;
    List<TableBlockIndexUniqueIdentifier> identifiers = new ArrayList<>();
    Path indexPath = new Path(mapDistributable.getFilePath());
    String segmentNo = mapDistributable.getSegment().getSegmentNo();
    if (indexPath.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT)) {
        String parent = indexPath.getParent().toString();
        identifiers.add(new TableBlockIndexUniqueIdentifier(parent, indexPath.getName(), null, segmentNo));
    } else if (indexPath.getName().endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) {
        SegmentIndexFileStore fileStore = new SegmentIndexFileStore();
        CarbonFile carbonFile = FileFactory.getCarbonFile(indexPath.toString());
        String parentPath = carbonFile.getParentFile().getAbsolutePath();
        List<String> indexFiles = fileStore.getIndexFilesFromMergeFile(carbonFile.getAbsolutePath());
        for (String indexFile : indexFiles) {
            identifiers.add(new TableBlockIndexUniqueIdentifier(parentPath, indexFile, carbonFile.getName(), segmentNo));
        }
    }
    List<CoarseGrainDataMap> dataMaps;
    try {
        dataMaps = cache.getAll(identifiers);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return dataMaps;
}
Also used : Path(org.apache.hadoop.fs.Path) CarbonTablePath(org.apache.carbondata.core.util.path.CarbonTablePath) CarbonFile(org.apache.carbondata.core.datastore.filesystem.CarbonFile) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with TableBlockIndexUniqueIdentifier

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

the class BlockletDataMapFactory method clear.

@Override
public void clear(Segment segment) {
    List<TableBlockIndexUniqueIdentifier> blockIndexes = segmentMap.remove(segment.getSegmentNo());
    if (blockIndexes != null) {
        for (TableBlockIndexUniqueIdentifier blockIndex : blockIndexes) {
            DataMap dataMap = cache.getIfPresent(blockIndex);
            if (dataMap != null) {
                cache.invalidate(blockIndex);
                dataMap.clear();
            }
        }
    }
}
Also used : TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) DataMap(org.apache.carbondata.core.datamap.dev.DataMap) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)

Example 3 with TableBlockIndexUniqueIdentifier

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

the class BlockletDataMapFactory method getTableBlockIndexUniqueIdentifiers.

private List<TableBlockIndexUniqueIdentifier> getTableBlockIndexUniqueIdentifiers(Segment segment) throws IOException {
    List<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = segmentMap.get(segment.getSegmentNo());
    if (tableBlockIndexUniqueIdentifiers == null) {
        tableBlockIndexUniqueIdentifiers = new ArrayList<>();
        Map<String, String> indexFiles;
        if (segment.getSegmentFileName() == null) {
            String path = CarbonTablePath.getSegmentPath(identifier.getTablePath(), segment.getSegmentNo());
            indexFiles = new SegmentIndexFileStore().getIndexFilesFromSegment(path);
        } else {
            SegmentFileStore fileStore = new SegmentFileStore(identifier.getTablePath(), segment.getSegmentFileName());
            indexFiles = fileStore.getIndexFiles();
        }
        for (Map.Entry<String, String> indexFileEntry : indexFiles.entrySet()) {
            Path indexFile = new Path(indexFileEntry.getKey());
            tableBlockIndexUniqueIdentifiers.add(new TableBlockIndexUniqueIdentifier(indexFile.getParent().toString(), indexFile.getName(), indexFileEntry.getValue(), segment.getSegmentNo()));
        }
        segmentMap.put(segment.getSegmentNo(), tableBlockIndexUniqueIdentifiers);
    }
    return tableBlockIndexUniqueIdentifiers;
}
Also used : Path(org.apache.hadoop.fs.Path) CarbonTablePath(org.apache.carbondata.core.util.path.CarbonTablePath) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) SegmentFileStore(org.apache.carbondata.core.metadata.SegmentFileStore) DataMap(org.apache.carbondata.core.datamap.dev.DataMap) HashMap(java.util.HashMap) Map(java.util.Map) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)

Example 4 with TableBlockIndexUniqueIdentifier

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

the class BlockletDataMapFactory method getExtendedBlocklets.

/**
 * Get the blocklet detail information based on blockletid, blockid and segmentid. This method is
 * exclusively for BlockletDataMapFactory as detail information is only available in this
 * default datamap.
 */
@Override
public List<ExtendedBlocklet> getExtendedBlocklets(List<Blocklet> blocklets, Segment segment) throws IOException {
    List<ExtendedBlocklet> detailedBlocklets = new ArrayList<>();
    // 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;
    }
    List<TableBlockIndexUniqueIdentifier> identifiers = getTableBlockIndexUniqueIdentifiers(segment);
    // Retrieve each blocklets detail information from blocklet datamap
    for (Blocklet blocklet : blocklets) {
        detailedBlocklets.add(getExtendedBlocklet(identifiers, blocklet));
    }
    return detailedBlocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) ArrayList(java.util.ArrayList) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet)

Aggregations

TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)4 CoarseGrainDataMap (org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)3 ArrayList (java.util.ArrayList)2 DataMap (org.apache.carbondata.core.datamap.dev.DataMap)2 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)2 Path (org.apache.hadoop.fs.Path)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CarbonFile (org.apache.carbondata.core.datastore.filesystem.CarbonFile)1 Blocklet (org.apache.carbondata.core.indexstore.Blocklet)1 ExtendedBlocklet (org.apache.carbondata.core.indexstore.ExtendedBlocklet)1 SegmentFileStore (org.apache.carbondata.core.metadata.SegmentFileStore)1