Search in sources :

Example 1 with CoarseGrainDataMap

use of org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap in project carbondata by apache.

the class MinMaxIndexDataMapFactory method getDataMaps.

/**
 * getDataMaps Factory method Initializes the Min Max Data Map and returns.
 *
 * @param segment
 * @return
 * @throws IOException
 */
@Override
public List<CoarseGrainDataMap> getDataMaps(Segment segment) throws IOException {
    List<CoarseGrainDataMap> dataMapList = new ArrayList<>();
    // Form a dataMap of Type MinMaxIndexDataMap.
    MinMaxIndexDataMap dataMap = new MinMaxIndexDataMap();
    try {
        dataMap.init(new DataMapModel(CarbonTablePath.getSegmentPath(identifier.getTablePath(), segment.getSegmentNo())));
    } catch (MemoryException ex) {
        throw new IOException(ex);
    }
    dataMapList.add(dataMap);
    return dataMapList;
}
Also used : MemoryException(org.apache.carbondata.core.memory.MemoryException) DataMapModel(org.apache.carbondata.core.datamap.dev.DataMapModel) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with CoarseGrainDataMap

use of org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap 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 3 with CoarseGrainDataMap

use of org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap in project carbondata by apache.

the class BlockletDataMapFactory method getSegmentProperties.

@Override
public SegmentProperties getSegmentProperties(Segment segment) throws IOException {
    List<CoarseGrainDataMap> dataMaps = getDataMaps(segment);
    assert (dataMaps.size() > 0);
    CoarseGrainDataMap coarseGrainDataMap = dataMaps.get(0);
    assert (coarseGrainDataMap instanceof BlockletDataMap);
    BlockletDataMap dataMap = (BlockletDataMap) coarseGrainDataMap;
    return dataMap.getSegmentProperties();
}
Also used : CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)

Example 4 with CoarseGrainDataMap

use of org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap in project carbondata by apache.

the class BlockletDataMapFactory method getAllBlocklets.

@Override
public List<Blocklet> getAllBlocklets(Segment segment, List<PartitionSpec> partitions) throws IOException {
    List<Blocklet> blocklets = new ArrayList<>();
    List<CoarseGrainDataMap> dataMaps = getDataMaps(segment);
    for (CoarseGrainDataMap dataMap : dataMaps) {
        blocklets.addAll(dataMap.prune(null, getSegmentProperties(segment), partitions));
    }
    return blocklets;
}
Also used : ExtendedBlocklet(org.apache.carbondata.core.indexstore.ExtendedBlocklet) Blocklet(org.apache.carbondata.core.indexstore.Blocklet) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) ArrayList(java.util.ArrayList)

Example 5 with CoarseGrainDataMap

use of org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap in project carbondata by apache.

the class LuceneCoarseGrainDataMapFactory method getDataMaps.

/**
 * Get the datamap for segmentid
 */
@Override
public List<CoarseGrainDataMap> getDataMaps(Segment segment) throws IOException {
    List<CoarseGrainDataMap> lstDataMap = new ArrayList<>();
    CoarseGrainDataMap dataMap = new LuceneCoarseGrainDataMap(analyzer);
    try {
        dataMap.init(new DataMapModel(LuceneDataMapWriter.genDataMapStorePath(tableIdentifier.getTablePath(), segment.getSegmentNo(), dataMapName)));
    } catch (MemoryException e) {
        LOGGER.error("failed to get lucene datamap , detail is {}" + e.getMessage());
        return lstDataMap;
    }
    lstDataMap.add(dataMap);
    return lstDataMap;
}
Also used : MemoryException(org.apache.carbondata.core.memory.MemoryException) DataMapModel(org.apache.carbondata.core.datamap.dev.DataMapModel) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) ArrayList(java.util.ArrayList)

Aggregations

CoarseGrainDataMap (org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)5 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)2 DataMapModel (org.apache.carbondata.core.datamap.dev.DataMapModel)2 MemoryException (org.apache.carbondata.core.memory.MemoryException)2 List (java.util.List)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 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)1 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)1 Path (org.apache.hadoop.fs.Path)1