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);
}
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);
}
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);
}
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);
}
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;
}
}
Aggregations