use of org.apache.carbondata.core.segmentmeta.SegmentMetaDataInfo in project carbondata by apache.
the class BlockletIndexFactory method getIndexes.
/**
* Get the index for all segments
*/
public Map<Segment, List<CoarseGrainIndex>> getIndexes(List<Segment> segments, Set<Path> partitionLocations, IndexFilter filter) throws IOException {
List<TableBlockIndexUniqueIdentifierWrapper> tableBlockIndexUniqueIdentifierWrappers = new ArrayList<>();
Map<Segment, List<CoarseGrainIndex>> indexMap = new HashMap<>();
Map<String, Segment> segmentMap = new HashMap<>();
for (Segment segment : segments) {
segmentMap.put(segment.getSegmentNo(), segment);
Set<TableBlockIndexUniqueIdentifier> identifiers = getTableBlockIndexUniqueIdentifiers(segment);
if (!partitionLocations.isEmpty()) {
// get tableBlockIndexUniqueIdentifierWrappers from segment file info
getTableBlockUniqueIdentifierWrappers(partitionLocations, tableBlockIndexUniqueIdentifierWrappers, identifiers);
} else {
SegmentMetaDataInfo segmentMetaDataInfo = segment.getSegmentMetaDataInfo();
boolean isLoadAllIndex = Boolean.parseBoolean(CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_LOAD_ALL_SEGMENT_INDEXES_TO_CACHE, CarbonCommonConstants.CARBON_LOAD_ALL_SEGMENT_INDEXES_TO_CACHE_DEFAULT));
if (!isLoadAllIndex && null != segmentMetaDataInfo && null != filter && !filter.isEmpty() && null != filter.getExpression() && null == FilterUtil.getImplicitFilterExpression(filter.getExpression())) {
getTableBlockIndexUniqueIdentifierUsingSegmentMinMax(segment, segmentMetaDataInfo, filter, identifiers, tableBlockIndexUniqueIdentifierWrappers);
} else {
for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : identifiers) {
tableBlockIndexUniqueIdentifierWrappers.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, this.getCarbonTable()));
}
}
}
}
List<BlockletIndexWrapper> blockletIndexWrappers = cache.getAll(tableBlockIndexUniqueIdentifierWrappers);
for (BlockletIndexWrapper wrapper : blockletIndexWrappers) {
Segment segment = segmentMap.get(wrapper.getSegmentId());
List<CoarseGrainIndex> indexes = indexMap.get(segment);
if (null == indexes) {
indexes = new ArrayList<CoarseGrainIndex>();
}
indexes.addAll(wrapper.getIndexes());
indexMap.put(segment, indexes);
}
return indexMap;
}
Aggregations