use of org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo in project carbondata by apache.
the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifier.
private List<TableBlockIndexUniqueIdentifierWrapper> getTableBlockIndexUniqueIdentifier(IndexInputSplit distributable) throws IOException {
List<TableBlockIndexUniqueIdentifierWrapper> identifiersWrapper = new ArrayList<>();
SegmentBlockIndexInfo segmentBlockIndexInfo = segmentMap.get(distributable.getSegment().getSegmentNo());
Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = null;
if (null != segmentBlockIndexInfo) {
tableBlockIndexUniqueIdentifiers = segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers();
}
if (tableBlockIndexUniqueIdentifiers == null) {
tableBlockIndexUniqueIdentifiers = new HashSet<>();
Set<String> indexFiles = distributable.getSegment().getCommittedIndexFile().keySet();
for (String indexFile : indexFiles) {
CarbonFile carbonFile = FileFactory.getCarbonFile(indexFile);
String indexFileName;
String mergeIndexName;
if (indexFile.endsWith(CarbonTablePath.INDEX_FILE_EXT)) {
indexFileName = carbonFile.getName();
mergeIndexName = null;
} else {
indexFileName = carbonFile.getName();
mergeIndexName = carbonFile.getName();
}
String parentPath = carbonFile.getParentFile().getAbsolutePath();
TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier = new TableBlockIndexUniqueIdentifier(parentPath, indexFileName, mergeIndexName, distributable.getSegment().getSegmentNo());
identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, this.getCarbonTable()));
tableBlockIndexUniqueIdentifiers.add(tableBlockIndexUniqueIdentifier);
}
segmentMap.put(distributable.getSegment().getSegmentNo(), new SegmentBlockIndexInfo(tableBlockIndexUniqueIdentifiers, distributable.getSegment().getSegmentMetaDataInfo()));
} else {
for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : tableBlockIndexUniqueIdentifiers) {
identifiersWrapper.add(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, getCarbonTable()));
}
}
return identifiersWrapper;
}
use of org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo in project carbondata by apache.
the class BlockletIndexFactory method getTableBlockIndexUniqueIdentifiers.
public Set<TableBlockIndexUniqueIdentifier> getTableBlockIndexUniqueIdentifiers(Segment segment) throws IOException {
SegmentBlockIndexInfo segmentBlockIndexInfo = segmentMap.get(segment.getSegmentNo());
Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = null;
if (null != segmentBlockIndexInfo && CollectionUtils.isNotEmpty(segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers())) {
if (null != segmentBlockIndexInfo.getSegmentMetaDataInfo()) {
segment.setSegmentMetaDataInfo(segmentMap.get(segment.getSegmentNo()).getSegmentMetaDataInfo());
}
return segmentBlockIndexInfo.getTableBlockIndexUniqueIdentifiers();
} else {
tableBlockIndexUniqueIdentifiers = BlockletIndexUtil.getTableBlockUniqueIdentifiers(segment);
if (tableBlockIndexUniqueIdentifiers.size() > 0) {
segmentMap.put(segment.getSegmentNo(), new SegmentBlockIndexInfo(tableBlockIndexUniqueIdentifiers, segment.getSegmentMetaDataInfo()));
}
}
return tableBlockIndexUniqueIdentifiers;
}
use of org.apache.carbondata.core.indexstore.SegmentBlockIndexInfo 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.SegmentBlockIndexInfo in project carbondata by apache.
the class BlockletIndexFactory method getCacheSize.
@Override
public String getCacheSize() {
long sum = 0L;
int numOfIndexFiles = 0;
for (Map.Entry<String, SegmentBlockIndexInfo> entry : segmentMap.entrySet()) {
for (TableBlockIndexUniqueIdentifier tableBlockIndexUniqueIdentifier : entry.getValue().getTableBlockIndexUniqueIdentifiers()) {
BlockletIndexWrapper blockletIndexWrapper = cache.getIfPresent(new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, getCarbonTable()));
if (blockletIndexWrapper != null) {
sum += blockletIndexWrapper.getMemorySize();
numOfIndexFiles++;
}
}
}
return numOfIndexFiles + ":" + sum;
}
Aggregations