Search in sources :

Example 36 with CacheObjectContext

use of org.apache.ignite.internal.processors.cache.CacheObjectContext in project ignite by apache.

the class GridNearTxEnlistRequest method finishUnmarshal.

/**
 * {@inheritDoc}
 */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    if (keys != null) {
        rows = new ArrayList<>(keys.length);
        CacheObjectContext objCtx = ctx.cacheContext(cacheId).cacheObjectContext();
        for (int i = 0; i < keys.length; i++) {
            keys[i].finishUnmarshal(objCtx, ldr);
            if (op.isDeleteOrLock())
                rows.add(keys[i]);
            else {
                if (values[i] != null) {
                    if (op.isInvoke())
                        ((GridInvokeValue) values[i]).finishUnmarshal(ctx, ldr);
                    else
                        ((CacheObject) values[i]).finishUnmarshal(objCtx, ldr);
                }
                rows.add(new IgniteBiTuple<>(keys[i], values[i]));
            }
        }
        keys = null;
        values = null;
    }
    if (filter != null)
        filter.finishUnmarshal(ctx.cacheContext(cacheId), ldr);
}
Also used : CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 37 with CacheObjectContext

use of org.apache.ignite.internal.processors.cache.CacheObjectContext in project ignite by apache.

the class GridCacheQueryManager method store.

/**
 * @param newRow New row.
 * @param prevRow Previous row.
 * @param prevRowAvailable Whether previous row is available.
 * @throws IgniteCheckedException In case of error.
 */
public void store(CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable) throws IgniteCheckedException {
    assert enabled();
    assert newRow != null && newRow.value() != null && newRow.link() != 0 : newRow;
    if (!enterBusy())
        throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
    try {
        if (isIndexingSpiEnabled()) {
            CacheObjectContext coctx = cctx.cacheObjectContext();
            Object key0 = unwrapIfNeeded(newRow.key(), coctx);
            Object val0 = unwrapIfNeeded(newRow.value(), coctx);
            cctx.kernalContext().indexing().store(cacheName, key0, val0, newRow.expireTime());
        }
        if (qryProcEnabled)
            qryProc.store(cctx, newRow, prevRow, prevRowAvailable);
    } finally {
        invalidateResultCache();
        leaveBusy();
    }
}
Also used : NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 38 with CacheObjectContext

use of org.apache.ignite.internal.processors.cache.CacheObjectContext in project ignite by apache.

the class StandaloneWalRecordsIterator method postProcessDataRecord.

/**
 * Performs post processing of lazy data record, converts it to unwrap record.
 *
 * @param dataRec data record to post process records.
 * @param kernalCtx kernal context.
 * @param processor processor to convert binary form from WAL into CacheObject/BinaryObject.
 * @return post-processed record.
 * @throws IgniteCheckedException if failed.
 */
@NotNull
private WALRecord postProcessDataRecord(@NotNull DataRecord dataRec, GridKernalContext kernalCtx, IgniteCacheObjectProcessor processor) throws IgniteCheckedException {
    final CacheObjectContext fakeCacheObjCtx = new CacheObjectContext(kernalCtx, null, null, false, false, false, false, false);
    final int entryCnt = dataRec.entryCount();
    final List<DataEntry> postProcessedEntries = new ArrayList<>(entryCnt);
    for (int i = 0; i < entryCnt; i++) {
        final DataEntry postProcessedEntry = postProcessDataEntry(processor, fakeCacheObjCtx, dataRec.get(i));
        postProcessedEntries.add(postProcessedEntry);
    }
    DataRecord res = dataRec instanceof MvccDataRecord ? new MvccDataRecord(postProcessedEntries, dataRec.timestamp()) : new DataRecord(postProcessedEntries, dataRec.timestamp());
    res.size(dataRec.size());
    res.position(dataRec.position());
    return res;
}
Also used : EncryptedDataEntry(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordDataV1Serializer.EncryptedDataEntry) UnwrapDataEntry(org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry) MvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) UnwrapMvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.UnwrapMvccDataEntry) MarshalledDataEntry(org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry) ArrayList(java.util.ArrayList) MvccDataRecord(org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord) MvccDataRecord(org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with CacheObjectContext

use of org.apache.ignite.internal.processors.cache.CacheObjectContext in project ignite by apache.

the class CacheObjectBinaryProcessorImpl method contextForCache.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("deprecation")
@Override
public CacheObjectContext contextForCache(CacheConfiguration ccfg) throws IgniteCheckedException {
    assert ccfg != null;
    boolean storeVal = !ccfg.isCopyOnRead() || (!isBinaryEnabled(ccfg) && (QueryUtils.isEnabled(ccfg) || ctx.config().isPeerClassLoadingEnabled()));
    boolean binaryEnabled = marsh instanceof BinaryMarshaller && !GridCacheUtils.isSystemCache(ccfg.getName());
    AffinityKeyMapper cacheAffMapper = ccfg.getAffinityMapper();
    AffinityKeyMapper dfltAffMapper = binaryEnabled ? new CacheDefaultBinaryAffinityKeyMapper(ccfg.getKeyConfiguration()) : new GridCacheDefaultAffinityKeyMapper();
    ctx.resource().injectGeneric(dfltAffMapper);
    return new CacheObjectContext(ctx, ccfg.getName(), dfltAffMapper, QueryUtils.isCustomAffinityMapper(ccfg.getAffinityMapper()), ccfg.isCopyOnRead(), storeVal, ctx.config().isPeerClassLoadingEnabled() && !isBinaryEnabled(ccfg), binaryEnabled);
}
Also used : GridCacheDefaultAffinityKeyMapper(org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper) AffinityKeyMapper(org.apache.ignite.cache.affinity.AffinityKeyMapper) CacheDefaultBinaryAffinityKeyMapper(org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper) GridCacheDefaultAffinityKeyMapper(org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper) CacheDefaultBinaryAffinityKeyMapper(org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 40 with CacheObjectContext

use of org.apache.ignite.internal.processors.cache.CacheObjectContext in project ignite by apache.

the class CacheDataRowAdapter method initFromLink.

/**
 * Read row from data pages.
 * Can be called with cctx == null, if cache instance is unknown, but its ID is stored in the data row.
 *
 * @param grp Cache group.
 * @param sharedCtx Shared context.
 * @param pageMem Page memory.
 * @param rowData Row data.
 * @param skipVer Whether version read should be skipped.
 * @throws IgniteCheckedException If failed.
 */
public final void initFromLink(@Nullable CacheGroupContext grp, GridCacheSharedContext<?, ?> sharedCtx, PageMemory pageMem, RowData rowData, boolean skipVer) throws IgniteCheckedException {
    // Group is null if try evict page, with persistence evictions should be disabled.
    assert grp != null || pageMem instanceof PageMemoryNoStoreImpl;
    CacheObjectContext coctx = grp != null ? grp.cacheObjectContext() : null;
    boolean readCacheId = grp == null || grp.storeCacheIdInDataPage();
    int grpId = grp != null ? grp.groupId() : 0;
    IoStatisticsHolder statHolder = grp != null ? grp.statisticsHolderData() : IoStatisticsHolderNoOp.INSTANCE;
    doInitFromLink(link, sharedCtx, coctx, pageMem, grpId, statHolder, readCacheId, rowData, null, skipVer);
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) IoStatisticsHolder(org.apache.ignite.internal.metric.IoStatisticsHolder) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Aggregations

CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)45 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)21 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)17 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)7 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 IgniteEx (org.apache.ignite.internal.IgniteEx)6 ArrayList (java.util.ArrayList)5 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)5 Test (org.junit.Test)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 MvccDataEntry (org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry)4 GridCacheOperation (org.apache.ignite.internal.processors.cache.GridCacheOperation)4 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)4 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)4 AffinityKeyMapper (org.apache.ignite.cache.affinity.AffinityKeyMapper)3 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)3 GridCacheDefaultAffinityKeyMapper (org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper)3 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)3 Message (org.apache.ignite.plugin.extensions.communication.Message)3