/** {@inheritDoc} */ @Override public K key() { assert key != null : "Entry is being improperly processed."; return key.value(null, false); }
/** * @param cpy Copy flag. * @return Key value. */ protected Object keyValue(boolean cpy) { return key.value(cctx.cacheObjectContext(), cpy); }
/** {@inheritDoc} */ @Override public K getKey() throws IllegalStateException { return cached.key().value(cached.context().cacheObjectContext(), false); }
/** {@inheritDoc} */ @Override public <K, V> CacheEntryImplEx<K, V> wrapVersioned() { lockEntry(); try { return new CacheEntryImplEx<>(key.<K>value(cctx.cacheObjectContext(), false), null, ver); } finally { unlockEntry(); } }
/** {@inheritDoc} */ @Override public Object unwrappedKey() { try { if (keepBinary && key instanceof BinaryObject) return key; Object unwrapped = key.value(cacheObjValCtx, false); if (unwrapped instanceof BinaryObject) { if (keepBinary) return unwrapped; unwrapped = ((BinaryObject)unwrapped).deserialize(); } return unwrapped; } catch (Exception e) { cacheObjValCtx.kernalContext().log(UnwrapDataEntry.class) .error("Unable to convert key [" + key + "]", e); return null; } }
/** {@inheritDoc} */ @Override public Object unwrappedKey() { try { if (keepBinary && key instanceof BinaryObject) return key; Object unwrapped = key.value(cacheObjValCtx, false); if (unwrapped instanceof BinaryObject) { if (keepBinary) return unwrapped; unwrapped = ((BinaryObject)unwrapped).deserialize(); } return unwrapped; } catch (Exception e) { cacheObjValCtx.kernalContext().log(UnwrapMvccDataEntry.class) .error("Unable to convert key [" + key + "]", e); return null; } }
/** * @return Entry which holds key, value and version. */ private <K, V> CacheEntryImplEx<K, V> wrapVersionedWithValue() { lockEntry(); try { V val = this.val == null ? null : this.val.<V>value(cctx.cacheObjectContext(), false); return new CacheEntryImplEx<>(key.<K>value(cctx.cacheObjectContext(), false), val, ver); } finally { unlockEntry(); } }
Class<?> keyCls = key.value(cctx.cacheObjectContext(), false).getClass();
/** * @param cacheName Cache name. * @param rowCache Row cache. * @param key Key to find. * @return Row's link. */ private long getLinkForKey(String cacheName, H2RowCache rowCache, int key) { grid().cache(cacheName) .query(new SqlQuery(Value.class, "_key = " + key)).getAll().size(); ConcurrentLinkedHashMap<Long, GridH2KeyValueRowOnheap> rowsMap = GridTestUtils.getFieldValue(rowCache, "rows"); for (Map.Entry<Long, GridH2KeyValueRowOnheap> e : rowsMap.entrySet()) { GridH2KeyValueRowOnheap val = e.getValue(); if ((Integer)val.key().value(null, false) == key) return e.getKey(); } fail("Row cache doesn't contain key [key=" + key + ']'); return -1; }
/** {@inheritDoc} */ @Override public <K, V> Cache.Entry<K, V> wrap() { try { IgniteInternalTx tx = cctx.tm().userTx(); CacheObject val; if (tx != null) { GridTuple<CacheObject> peek = tx.peek(cctx, false, key); val = peek == null ? rawGet() : peek.get(); } else val = rawGet(); return new CacheEntryImpl<>(key.<K>value(cctx.cacheObjectContext(), false), CU.<V>value(val, cctx, false), ver); } catch (GridCacheFilterFailedException ignored) { throw new IgniteException("Should never happen."); } }
/** * @param info Entry to marshal. * @param ctx Context. * @param cacheObjCtx Cache object context. * @throws IgniteCheckedException If failed. */ protected final void marshalInfo(GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx ) throws IgniteCheckedException { assert ctx != null; if (info != null) { info.marshal(cacheObjCtx); if (addDepInfo) { if (info.key() != null) prepareObject(info.key().value(cacheObjCtx, false), ctx); CacheObject val = info.value(); if (val != null) { val.finishUnmarshal(cacheObjCtx, ctx.deploy().globalLoader()); prepareObject(val.value(cacheObjCtx, false), ctx); } } } }
/** * @param cctx Cache context. * @param key Key. * @param oldVal Old value. * @param newVal New value. */ private void updateIgfsMetrics( GridCacheContext cctx, KeyCacheObject key, CacheObject oldVal, CacheObject newVal ) { GridCacheAdapter cache = cctx.cache(); if (cache == null) return; // In case we deal with IGFS cache, count updated data if (cache.isIgfsDataCache() && !cctx.isNear() && ctx.kernalContext() .igfsHelper() .isIgfsBlockKey(key.value(cctx.cacheObjectContext(), false))) { int oldSize = valueLength(cctx, oldVal); int newSize = valueLength(cctx, newVal); int delta = newSize - oldSize; if (delta != 0) cache.onIgfsDataSizeChanged(delta); } }
Integer key = it.next().value(coctx, false);
fail("[key=" + key.value(null, false) + "; vers=" + vers + ']'); else return false;
CacheDataRow row = cur.get(); int key = row.key().value(coCtx, false);
/** * @param ignite Ignite. * @param orgId Organization id. * @return Count of found Person object with specified orgId * @throws Exception If failed. */ private static int getOrganizationCountFromPartitionMap(final IgniteEx ignite, int orgId) throws Exception { int part = ignite.affinity(Organization.class.getSimpleName()).partition(orgId); GridCacheAdapter<?, ?> cacheAdapterOrg = ignite.context().cache() .internalCache(Organization.class.getSimpleName()); GridDhtLocalPartition pOrgs = cacheAdapterOrg.context().topology() .localPartition(part, AffinityTopologyVersion.NONE, false); int cnt = 0; GridCursor<? extends CacheDataRow> c = pOrgs.dataStore().cursor(); CacheObjectContext ctx = cacheAdapterOrg.context().cacheObjectContext(); while (c.next()) { CacheDataRow e = c.get(); Integer k = e.key().value(ctx, false); Organization org = e.value().value(ctx, false); if (org != null && org.getId() == orgId) ++cnt; } return cnt; }
/** * @param ignite Ignite. * @param orgId Organization id. * @return Count of found Person object with specified orgId * @throws Exception If failed. */ private static int getPersonsCountFromPartitionMap(final IgniteEx ignite, int orgId) throws Exception { int part = ignite.affinity(Organization.class.getSimpleName()).partition(orgId); GridCacheAdapter<?, ?> cacheAdapterPers = ignite.context().cache() .internalCache(Person.class.getSimpleName()); GridDhtLocalPartition pPers = cacheAdapterPers.context().topology() .localPartition(part, AffinityTopologyVersion.NONE, false); int cnt = 0; GridCursor<? extends CacheDataRow> c = pPers.dataStore().cursor(); CacheObjectContext ctx = cacheAdapterPers.context().cacheObjectContext(); while (c.next()) { CacheDataRow e = c.get(); Person.Key k = e.key().value(ctx, false); Person p = e.value().value(ctx, false); if (p != null && p.getOrgId() == orgId && k.orgId == orgId) ++cnt; } return cnt; }
prepareObject(e.key().value(cctx.cacheObjectContext(), false), ctx);
/** * Check versions presence in index tree. * * @param srv Node. * @param afterRebuild Whether index rebuild has occurred. * @throws IgniteCheckedException if failed. */ @SuppressWarnings({"ConstantConditions", "unchecked"}) protected void checkDataState(IgniteEx srv, boolean afterRebuild) throws IgniteCheckedException { IgniteInternalCache icache = srv.cachex(CACHE_NAME); IgniteCache cache = srv.cache(CACHE_NAME); assertNotNull(icache); for (IgniteCacheOffheapManager.CacheDataStore store : icache.context().offheap().cacheDataStores()) { GridCursor<? extends CacheDataRow> cur = store.cursor(); while (cur.next()) { CacheDataRow row = cur.get(); int key = row.key().value(icache.context().cacheObjectContext(), false); if (!afterRebuild || key <= AMOUNT / 2) assertEquals(key, cache.get(key)); else assertEquals(-1, cache.get(key)); } } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { for (int i = 0; i < gridCount(); i++) { GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache(DEFAULT_CACHE_NAME); for (GridCacheEntryEx e : c.map().entries(c.context().cacheId())) { Object key = e.key().value(c.context().cacheObjectContext(), false); Object val = CU.value(e.rawGet(), c.context(), false); if (key instanceof BinaryObject) assert ((BinaryObjectImpl)key).detached() : val; if (val instanceof BinaryObject) assert ((BinaryObjectImpl)val).detached() : val; } } IgniteCache<Object, Object> c = jcache(0); for (int i = 0; i < ENTRY_CNT; i++) c.remove(i); assertEquals(0, c.size()); }