Search in sources :

Example 16 with CacheObjectContext

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

the class RecordDataV1Serializer method entrySize.

/**
 * @param entry Entry to get size for.
 * @return Entry size.
 * @throws IgniteCheckedException If failed to get key or value bytes length.
 */
protected int entrySize(DataEntry entry) throws IgniteCheckedException {
    GridCacheContext cctx = this.cctx.cacheContext(entry.cacheId());
    CacheObjectContext coCtx = cctx.cacheObjectContext();
    return /*cache ID*/
    4 + /*key*/
    entry.key().valueBytesLength(coCtx) + /*value*/
    (entry.value() == null ? 4 : entry.value().valueBytesLength(coCtx)) + /*op*/
    1 + /*near xid ver*/
    CacheVersionIO.size(entry.nearXidVersion(), true) + /*write ver*/
    CacheVersionIO.size(entry.writeVersion(), false) + /*part ID*/
    4 + /*expire Time*/
    8 + /*part cnt*/
    8 + /*primary*/
    (entry instanceof MvccDataEntry ? 0 : 1);
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) MvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 17 with CacheObjectContext

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

the class GridCacheAffinityImpl method affinityKey.

/**
 * {@inheritDoc}
 */
@Override
public Object affinityKey(K key) {
    A.notNull(key, "key");
    if (key instanceof CacheObject && !(key instanceof BinaryObject)) {
        CacheObjectContext ctx = cctx.cacheObjectContext();
        if (ctx == null)
            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
        key = ((CacheObject) key).value(ctx, false);
    }
    CacheConfiguration ccfg = cctx.config();
    if (ccfg == null)
        throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
    return ccfg.getAffinityMapper().affinityKey(key);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteException(org.apache.ignite.IgniteException) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 18 with CacheObjectContext

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

the class IgniteSnapshotManager method partitionRowIterator.

/**
 * @param grpName Cache group name.
 * @param partId Partition id.
 * @param pageStore File page store to iterate over.
 * @return Iterator over partition.
 * @throws IgniteCheckedException If and error occurs.
 */
public GridCloseableIterator<CacheDataRow> partitionRowIterator(GridKernalContext ctx, String grpName, int partId, FilePageStore pageStore) throws IgniteCheckedException {
    CacheObjectContext coctx = new CacheObjectContext(ctx, grpName, null, false, false, false, false, false);
    GridCacheSharedContext<?, ?> sctx = new GridCacheSharedContext<>(ctx, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
    return new DataPageIterator(sctx, coctx, pageStore, partId);
}
Also used : CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext)

Example 19 with CacheObjectContext

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

the class GridNearTxEnlistRequest method prepareMarshal.

/**
 * {@inheritDoc}
 */
@Override
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);
    GridCacheContext cctx = ctx.cacheContext(cacheId);
    CacheObjectContext objCtx = cctx.cacheObjectContext();
    if (rows != null && keys == null) {
        if (!addDepInfo && ctx.deploymentEnabled())
            addDepInfo = true;
        keys = new KeyCacheObject[rows.size()];
        int i = 0;
        boolean keysOnly = op.isDeleteOrLock();
        values = keysOnly ? null : new Message[keys.length];
        for (Object row : rows) {
            Object key, val = null;
            if (keysOnly)
                key = row;
            else {
                key = ((IgniteBiTuple) row).getKey();
                val = ((IgniteBiTuple) row).getValue();
            }
            assert key != null && (keysOnly || val != null) : "key=" + key + ", val=" + val;
            KeyCacheObject key0 = cctx.toCacheKeyObject(key);
            assert key0 != null;
            key0.prepareMarshal(objCtx);
            keys[i] = key0;
            if (!keysOnly) {
                if (op.isInvoke()) {
                    GridInvokeValue val0 = (GridInvokeValue) val;
                    prepareInvokeValue(cctx, val0);
                    values[i] = val0;
                } else {
                    if (addDepInfo)
                        prepareObject(val, cctx);
                    CacheObject val0 = cctx.toCacheObject(val);
                    assert val0 != null;
                    val0.prepareMarshal(objCtx);
                    values[i] = val0;
                }
            }
            i++;
        }
    }
    if (filter != null)
        filter.prepareMarshal(cctx);
}
Also used : GridInvokeValue(org.apache.ignite.internal.processors.cache.distributed.dht.GridInvokeValue) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridCacheIdMessage(org.apache.ignite.internal.processors.cache.GridCacheIdMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 20 with CacheObjectContext

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

the class GridNearTxQueryResultsEnlistRequest 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)
                    values[i].finishUnmarshal(objCtx, ldr);
                rows.add(new IgniteBiTuple<>(keys[i], values[i]));
            }
        }
        keys = null;
        values = null;
    }
}
Also used : 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