/** * @param p Single predicate. * @return Array containing single predicate. */ @SuppressWarnings({"unchecked"}) public GridPredicate<GridCacheEntry<K, V>>[] vararg(GridPredicate<GridCacheEntry<K, V>> p) { return p == null ? CU.<K, V>empty() : new GridPredicate[]{p}; }
/** * @return Near entries. */ public Set<GridCacheEntry<K, V>> nearEntries() { return super.entrySet(CU.<K, V>empty()); }
/** * Same as {@link #entrySet()} but for internal use only to * avoid casting. * * @return Set of entry wrappers. */ public Set<GridCacheEntryImpl<K, V>> wrappers() { return map.wrappers(CU.<K, V>empty()); }
/** {@inheritDoc} */ @Override public void transformAll(@Nullable Map<? extends K, ? extends GridClosure<V, V>> map) throws GridException { putAllAsync0(null, map, null, false, null, -1, CU.<K, V>empty()).get(); }
/** {@inheritDoc} */ @Override public V peek(@Nullable Collection<GridCachePeekMode> modes) throws GridException { if (modes.contains(NEAR_ONLY) && ctx.isNear()) return peekNear0(modes, CU.<K, V>empty()); V val = null; if (!modes.contains(PARTITIONED_ONLY)) val = super.peek(modes); if (val == null) val = peekDht0(modes, CU.<K, V>empty()); return val; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <R> GridFuture<R> transformAndComputeAsync(K key, GridClosure<V, GridBiTuple<V, R>> transformer) { return updateAllAsync0(null, Collections.singletonMap(key, new GridCacheTransformComputeClosure<>(transformer)), true, false, -1, CU.<K, V>empty()); }
/** {@inheritDoc} */ @Nullable @Override public V setValue(V val) { try { return set(val, CU.<K, V>empty()); } catch (GridException e) { throw new GridRuntimeException(e); } }
/** {@inheritDoc} */ @Override public V peek(@Nullable Collection<GridCachePeekMode> modes) throws GridException { if (!ctx.isNear() && modes.contains(NEAR_ONLY)) return null; V val = null; if (!modes.contains(PARTITIONED_ONLY)) val = super.peek(modes); if (val == null) val = peekDht0(modes, CU.<K, V>empty()); return val; }
@Override protected GridCacheReturn<V> postLock(GridCacheReturn<V> ret) throws GridException { if (log.isDebugEnabled()) log.debug("Acquired transaction lock on keys: " + passedKeys); postLockWrite(passedKeys, skipped, null, null, ret, /*remove*/false, /*retval*/false, filter == null ? CU.<K, V>empty() : filter); return ret; } },
/** * Gets all internal entry set, including {@link GridCacheInternal} entries. * * @return All internal entry set, including {@link GridCacheInternal} entries. */ public Set<GridCacheEntryEx<K, V>> allEntries0() { checkWeakQueue(); return new Set0<>(this, CU.<K, V>empty()); }
@Override public GridFuture<?> inOp(GridCacheTxLocalAdapter<K, V> tx) { return tx.removeAllAsync(keys, null, tx.implicit(), false, CU.<K, V>empty()); }
/** {@inheritDoc} */ @Override public boolean transform(K key, GridClosure<V, V> transformer) throws GridException { return putAllAsync0(null, Collections.singletonMap(key, transformer), null, false, null, -1, CU.<K, V>empty()).get().success(); }
/** {@inheritDoc} */ @Override public void clear() { ctx.cache().clearAll0(F.viewReadOnly(map.values(), F.<K>mapEntry2Key(), filter), CU.<K, V>empty()); map.clear(); }
/** {@inheritDoc} */ @Override public void clear() { ctx.cache().clearAll0(F.viewReadOnly(map.values(), F.<K>mapEntry2Key(), filter), CU.<K, V>empty()); map.clear(); }
/** {@inheritDoc} */ @Override public void clear() { ctx.cache().clearAll0(F.viewReadOnly(set, F.<K>mapEntry2Key(), filter), CU.<K, V>empty()); set.clear(); }
/** {@inheritDoc} */ @Override public void clear() { ctx.cache().clearAll0(new KeySet<>(map, filter), CU.<K, V>empty()); }
/** {@inheritDoc} */ @Override public void remove() { if (cur == null) throw new IllegalStateException(); GridCacheMapEntry<K, V> e = cur; cur = null; curVal = null; try { ctx.cache().remove(e.key(), CU.<K, V>empty()); } catch (GridException ex) { throw new GridRuntimeException(ex); } }
/** * @param k Key to remove. * @return If key has been removed. */ boolean removeKey(K k) { try { return ctx.cache().remove(k, CU.<K, V>empty()) != null; } catch (GridException e) { throw new GridRuntimeException("Failed to remove cache entry for key: " + k, e); } }
/** {@inheritDoc} */ @Override public V peek(@Nullable Collection<GridCachePeekMode> modes) throws GridException { return peek0(modes, CU.<K, V>empty(), cached.context().tm().localTxx()); }
/** {@inheritDoc} */ @Override public <R> R transformCompute(K key, GridClosure<V, GridBiTuple<V, R>> transformer) throws GridException { GridFuture<GridCacheReturn<V>> fut = putAllAsync0(null, Collections.singletonMap(key, new GridCacheTransformComputeClosure<>(transformer)), null, true, null, -1, CU.<K, V>empty()); GridCacheReturn<V> ret = fut.get(); return transformer.apply(ret.value()).get2(); }