use of org.apache.ignite.internal.cache.query.index.sorted.DurableBackgroundCleanupIndexTreeTaskV2.NoopRowHandlerFactory in project ignite by apache.
the class DurableBackgroundCleanupIndexTreeTask method execute.
/**
* Task execution.
*
* @param ctx Kernal context.
*/
private void execute(GridKernalContext ctx) {
List<InlineIndexTree> trees0 = trees;
if (trees0 == null) {
trees0 = new ArrayList<>(rootPages.size());
GridCacheContext cctx = ctx.cache().context().cacheContext(CU.cacheId(cacheName));
int grpId = CU.cacheGroupId(cacheName, cacheGrpName);
CacheGroupContext grpCtx = ctx.cache().cacheGroup(grpId);
// If group context is null, it means that group doesn't exist and we don't need this task anymore.
if (grpCtx == null)
return;
IgniteCacheOffheapManager offheap = grpCtx.offheap();
if (treeName != null) {
ctx.cache().context().database().checkpointReadLock();
try {
int cacheId = CU.cacheId(cacheName);
for (int segment = 0; segment < rootPages.size(); segment++) {
try {
RootPage rootPage = offheap.findRootPageForIndex(cacheId, treeName, segment);
if (rootPage != null && rootPages.get(segment) == rootPage.pageId().pageId())
offheap.dropRootPageForIndex(cacheId, treeName, segment);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
} finally {
ctx.cache().context().database().checkpointReadUnlock();
}
}
IoStatisticsHolderIndex stats = new IoStatisticsHolderIndex(SORTED_INDEX, cctx.name(), idxName, cctx.kernalContext().metric());
PageMemory pageMem = grpCtx.dataRegion().pageMemory();
for (int i = 0; i < rootPages.size(); i++) {
Long rootPage = rootPages.get(i);
assert rootPage != null;
if (skipDeletedRoot(grpId, pageMem, rootPage)) {
ctx.log(getClass()).warning(S.toString("Skipping deletion of the index tree", "cacheGrpName", cacheGrpName, false, "cacheName", cacheName, false, "idxName", idxName, false, "segment", i, false, "rootPageId", PageIdUtils.toDetailString(rootPage), false));
continue;
}
// because we just going to free memory pages that are occupied by tree structure.
try {
String treeName = "deletedTree_" + i + "_" + name();
InlineIndexTree tree = new InlineIndexTree(null, grpCtx, treeName, cctx.offheap(), cctx.offheap().reuseListForIndex(treeName), cctx.dataRegion().pageMemory(), PageIoResolver.DEFAULT_PAGE_IO_RESOLVER, rootPage, false, 0, 0, new IndexKeyTypeSettings(), null, stats, new NoopRowHandlerFactory(), null);
trees0.add(tree);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
}
ctx.cache().context().database().checkpointReadLock();
try {
for (int i = 0; i < trees0.size(); i++) {
BPlusTree tree = trees0.get(i);
try {
tree.destroy(null, true);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
} finally {
ctx.cache().context().database().checkpointReadUnlock();
}
}
Aggregations