use of org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter in project ignite by apache.
the class DefragIndexFactory method lookupRow.
/**
*/
private static <T extends BPlusIO<IndexRow> & InlineIO> IndexRow lookupRow(InlineIndexRowHandler rowHnd, long pageAddr, int idx, T io) {
long link = io.link(pageAddr, idx);
int off = io.offset(idx);
int inlineSize = io.inlineSize();
byte[] values;
if (rowHnd.inlineIndexKeyTypes().isEmpty())
values = EMPTY_BYTES;
else
values = PageUtils.getBytes(pageAddr, off, inlineSize);
if (io.storeMvccInfo()) {
long mvccCrdVer = io.mvccCoordinatorVersion(pageAddr, idx);
long mvccCntr = io.mvccCounter(pageAddr, idx);
int mvccOpCntr = io.mvccOperationCounter(pageAddr, idx);
MvccDataRow row = new MvccDataRow(null, 0, link, PageIdUtils.partId(PageIdUtils.pageId(link)), CacheDataRowAdapter.RowData.LINK_ONLY, mvccCrdVer, mvccCntr, mvccOpCntr, true);
return new DefragIndexRowImpl(rowHnd, row, values);
}
return new DefragIndexRowImpl(rowHnd, new CacheDataRowAdapter(link), values);
}
use of org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter in project ignite by apache.
the class UpgradePendingTreeToPerPartitionTask method getEntry.
/**
* Return CacheEntry instance for lock purpose.
*
* @param grp Cache group
* @param row Pending row.
* @return CacheEntry if found or null otherwise.
*/
private GridCacheEntryEx getEntry(CacheGroupContext grp, PendingRow row) {
try {
CacheDataRowAdapter rowData = new CacheDataRowAdapter(row.link);
rowData.initFromLink(grp, CacheDataRowAdapter.RowData.KEY_ONLY);
GridCacheContext cctx = grp.shared().cacheContext(row.cacheId);
assert cctx != null;
return cctx.cache().entryEx(rowData.key());
} catch (Throwable ex) {
if (Thread.currentThread().isInterrupted() || X.hasCause(ex, InterruptedException.class))
throw new IgniteException(new InterruptedException());
log.warning("Failed to move old-version pending entry " + "to per-partition PendingTree: key not found (skipping): " + "[grpId=" + grp.groupId() + ", grpName=" + grp.name() + ", pendingRow=" + row + "]");
return null;
}
}
use of org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter in project ignite by apache.
the class PendingRow method initKey.
/**
* @param grp Cache group.
* @return Row.
* @throws IgniteCheckedException If failed.
*/
PendingRow initKey(CacheGroupContext grp) throws IgniteCheckedException {
CacheDataRowAdapter rowData = grp.mvccEnabled() ? new MvccDataRow(link) : new CacheDataRowAdapter(link);
rowData.initFromLink(grp, CacheDataRowAdapter.RowData.KEY_ONLY);
key = rowData.key();
return this;
}
use of org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter in project ignite by apache.
the class H2RowFactory method getRow.
/**
* !!! This method must be invoked in read or write lock of referring index page. It is needed to
* !!! make sure that row at this link will be invisible, when the link will be removed from
* !!! from all the index pages, so that row can be safely erased from the data page.
*
* @param link Link.
* @return Row.
* @throws IgniteCheckedException If failed.
*/
public GridH2Row getRow(long link) throws IgniteCheckedException {
// TODO Avoid extra garbage generation. In upcoming H2 1.4.193 Row will become an interface,
// TODO we need to refactor all this to return CacheDataRowAdapter implementing Row here.
final CacheDataRowAdapter rowBuilder = new CacheDataRowAdapter(link);
rowBuilder.initFromLink(cctx.group(), CacheDataRowAdapter.RowData.FULL);
GridH2Row row;
try {
row = rowDesc.createRow(rowBuilder);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
assert row.version() != null;
return row;
}
use of org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter in project ignite by apache.
the class PageAbstractEvictionTracker method evictDataPage.
/**
* @param pageIdx Page index.
* @return true if at least one data row has been evicted
* @throws IgniteCheckedException If failed.
*/
final boolean evictDataPage(int pageIdx) throws IgniteCheckedException {
long fakePageId = PageIdUtils.pageId(0, (byte) 0, pageIdx);
long page = pageMem.acquirePage(0, fakePageId);
List<CacheDataRowAdapter> rowsToEvict;
try {
long pageAddr = pageMem.readLockForce(0, fakePageId, page);
try {
if (PageIO.getType(pageAddr) != PageIO.T_DATA)
// Can't evict: page has been recycled into non-data page.
return false;
DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
long realPageId = PageIO.getPageId(pageAddr);
if (!checkTouch(realPageId))
// Can't evict: another thread concurrently invoked forgetPage()
return false;
rowsToEvict = io.forAllItems(pageAddr, new DataPageIO.CC<CacheDataRowAdapter>() {
@Override
public CacheDataRowAdapter apply(long link) throws IgniteCheckedException {
CacheDataRowAdapter row = new CacheDataRowAdapter(link);
row.initFromLink(null, sharedCtx, pageMem, CacheDataRowAdapter.RowData.KEY_ONLY, false);
assert row.cacheId() != 0 : "Cache ID should be stored in rows of evictable cache";
return row;
}
});
} finally {
pageMem.readUnlock(0, fakePageId, page);
}
} finally {
pageMem.releasePage(0, fakePageId, page);
}
boolean evictionDone = false;
for (CacheDataRowAdapter dataRow : rowsToEvict) {
GridCacheContext<?, ?> cacheCtx = sharedCtx.cacheContext(dataRow.cacheId());
if (!cacheCtx.userCache())
continue;
GridCacheEntryEx entryEx = cacheCtx.isNear() ? cacheCtx.near().dht().entryEx(dataRow.key()) : cacheCtx.cache().entryEx(dataRow.key());
evictionDone |= entryEx.evictInternal(GridCacheVersionManager.EVICT_VER, null, true);
}
return evictionDone;
}
Aggregations