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;
}
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();
}
}
}
}
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;
}
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;
}
Aggregations