Search in sources :

Example 1 with CacheDataRowAdapter

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);
}
Also used : MvccDataRow(org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)

Example 2 with CacheDataRowAdapter

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;
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteException(org.apache.ignite.IgniteException) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)

Example 3 with CacheDataRowAdapter

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;
}
Also used : CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter) MvccDataRow(org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow)

Example 4 with CacheDataRowAdapter

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;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)

Example 5 with CacheDataRowAdapter

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;
}
Also used : DataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)

Aggregations

CacheDataRowAdapter (org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)8 IgniteException (org.apache.ignite.IgniteException)3 MvccDataRow (org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 DataPageIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO)2 UUID (java.util.UUID)1 Cache (javax.cache.Cache)1 EntryProcessor (javax.cache.processor.EntryProcessor)1 IgniteCache (org.apache.ignite.IgniteCache)1 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)1 UnregisteredBinaryTypeException (org.apache.ignite.internal.UnregisteredBinaryTypeException)1 UnregisteredClassException (org.apache.ignite.internal.UnregisteredClassException)1 IndexRowImpl (org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)1 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)1 StorageException (org.apache.ignite.internal.processors.cache.persistence.StorageException)1 DataPagePayload (org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPagePayload)1 CacheContinuousQueryListener (org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryListener)1 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)1