use of org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper in project carbondata by apache.
the class BlockletIndexFactory method getExtendedBlocklets.
/**
* Get the blocklet detail information based on blockletId, blockId and segmentId. This method is
* exclusively for BlockletIndexFactory as detail information is only available in this
* default index.
*/
@Override
public List<ExtendedBlocklet> getExtendedBlocklets(List<Blocklet> blocklets, Segment segment) throws IOException {
List<ExtendedBlocklet> detailedBlocklets = new ArrayList<>(blocklets.size() + 1);
// if the blocklets is empty, return the empty detailed blocklets list directly.
if (blocklets.size() == 0) {
return detailedBlocklets;
}
// 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;
}
Set<TableBlockIndexUniqueIdentifier> identifiers = getTableBlockIndexUniqueIdentifiers(segment);
Set<TableBlockIndexUniqueIdentifierWrapper> tableBlockIndexUniqueIdentifierWrappers = new HashSet<>(identifiers.size());
for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : identifiers) {
tableBlockIndexUniqueIdentifierWrappers.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, this.getCarbonTable()));
}
// Retrieve each blocklets detail information from blocklet index
for (Blocklet blocklet : blocklets) {
detailedBlocklets.add(getExtendedBlocklet(tableBlockIndexUniqueIdentifierWrappers, blocklet));
}
return detailedBlocklets;
}
use of org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper 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();
}
}
}
}
}
}
use of org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper in project carbondata by apache.
the class BlockletIndexFactory method getAllUncached.
@Override
public List<IndexInputSplit> getAllUncached(List<IndexInputSplit> distributableList) throws IOException {
List<IndexInputSplit> distributableToBeLoaded = new ArrayList<>(distributableList.size());
for (IndexInputSplit distributable : distributableList) {
Segment segment = distributable.getSegment();
Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = getTableBlockIndexUniqueIdentifiers(segment);
// filter out the tableBlockIndexUniqueIdentifiers based on distributable
TableBlockIndexUniqueIdentifier validIdentifier = BlockletIndexUtil.filterIdentifiersBasedOnDistributable(tableBlockIndexUniqueIdentifiers, (BlockletIndexInputSplit) distributable);
if (null == cache.getIfPresent(new TableBlockIndexUniqueIdentifierWrapper(validIdentifier, this.getCarbonTable()))) {
((BlockletIndexInputSplit) distributable).setTableBlockIndexUniqueIdentifier(validIdentifier);
distributableToBeLoaded.add(distributable);
}
}
return distributableToBeLoaded;
}
use of org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper in project carbondata by apache.
the class BlockletIndexFactory method getExtendedBlocklet.
private ExtendedBlocklet getExtendedBlocklet(Set<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper, Blocklet blocklet) throws IOException {
for (TableBlockIndexUniqueIdentifierWrapper identifierWrapper : identifiersWrapper) {
BlockletIndexWrapper wrapper = cache.get(identifierWrapper);
List<BlockIndex> indexes = wrapper.getIndexes();
for (Index index : indexes) {
if (((BlockIndex) index).getTableTaskInfo(BlockletIndexRowIndexes.SUMMARY_INDEX_FILE_NAME).startsWith(blocklet.getFilePath())) {
return ((BlockIndex) index).getDetailedBlocklet(blocklet.getBlockletId());
}
}
}
throw new IOException("Blocklet not found: " + blocklet.toString());
}
use of org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper in project carbondata by apache.
the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifier.
private List<TableBlockIndexUniqueIdentifierWrapper> getTableBlockIndexUniqueIdentifier(String indexFilePath, String segmentId) throws IOException {
List<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper = new ArrayList<>();
String parent = indexFilePath.substring(0, indexFilePath.lastIndexOf("/"));
String name = indexFilePath.substring(indexFilePath.lastIndexOf("/") + 1);
if (indexFilePath.endsWith(CarbonTablePath.INDEX_FILE_EXT)) {
identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(new TableBlockIndexUniqueIdentifier(parent, name, null, segmentId), this.getCarbonTable()));
} else if (indexFilePath.endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) {
SegmentIndexFileStore fileStore = new SegmentIndexFileStore();
List<String> indexFiles = fileStore.getIndexFilesFromMergeFile(indexFilePath);
for (String indexFile : indexFiles) {
identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(new TableBlockIndexUniqueIdentifier(parent, indexFile, name, segmentId), this.getCarbonTable()));
}
}
return identifiersWrapper;
}
Aggregations