@SuppressWarnings({"unchecked"}) @Override public boolean apply(Object o) { return ((GridCacheEntry)o).peek() != null; }
@SuppressWarnings({"unchecked"}) @Override public boolean apply(Object o) { return ((GridCacheEntry)o).peek() == null; }
@SuppressWarnings({"unchecked"}) @Nullable @Override public Object apply(Object o) { return ((GridCacheEntry<?, ?>)o).peek(); }
/** {@inheritDoc} */ @Nullable @Override public V peek(@Nullable Collection<GridCachePeekMode> modes) throws GridException { assert impl != null; return impl.peek(modes); }
/** * Gets predicate which returns {@code true} if cache entry matches any given key-value pair. * Both, key and value will be checked for containment. Value will be retrieved using * {@link GridCacheEntry#peek()} method. Note that if collection * of provided entries is empty this method returns predicate that evaluates to {@code false} * when applying. * * @param entries Key-value paris to check for containment. * @param <K> Cache key type. * @param <V> Cache value type. * @return Predicate which returns {@code true} if cache entry matches any given key-value pair. */ public static <K, V> GridPredicate<GridCacheEntry<K, V>> cacheContainsEntriesPeek( @Nullable final Collection<? extends Map.Entry<K, V>> entries) { return isEmpty(entries) ? F.<GridCacheEntry<K, V>>alwaysFalse() : new GridPredicate<GridCacheEntry<K, V>>() { @Override public boolean apply(GridCacheEntry<K, V> e) { K k = e.getKey(); V v = e.peek(); assert entries != null; for (Map.Entry<K, V> entry : entries) { if (eq(k, entry.getKey()) && eq(v, entry.getValue())) return true; } return false; } }; }
/** {@inheritDoc} */ @Override public boolean apply(GridCacheEntry<K, V> e) { if (kvFilter != null) { if (!kvFilter.apply(e.getKey(), e.peek())) return false; } return F.isAll(e, entryFilter); } }
/** * Checks entry for empty value. * * @param entry Entry to check. * @return {@code True} if entry is empty. */ private boolean empty(GridCacheEntry<K, V> entry) { try { return entry.peek(F.asList(GLOBAL)) == null; } catch (GridException e) { U.error(null, e.getMessage(), e); assert false : "Should never happen: " + e; return false; } }
/** * Checks entry for empty value. * * @param entry Entry to check. * @return {@code True} if entry is empty. */ private boolean empty(GridCacheEntry<K, V> entry) { try { return entry.peek(F.asList(GLOBAL)) == null; } catch (GridException e) { U.error(null, e.getMessage(), e); assert false : "Should never happen: " + e; return false; } }
nextVal = next.wrap(true).peek();
/** * Shrinks queue to maximum allowed size. */ private void shrink() { long maxSize = this.maxSize; int maxBlocks = this.maxBlocks; int cnt = queue.sizex(); for (int i = 0; i < cnt && (maxBlocks > 0 && queue.sizex() > maxBlocks || maxSize > 0 && curSize.longValue() > maxSize); i++) { GridCacheEntry<GridGgfsBlockKey, byte[]> entry = queue.poll(); if (entry == null) break; // Queue is empty. byte[] val = entry.peek(); if (val != null) changeSize(-val.length); // Change current size as we polled entry from the queue. if (!entry.evict()) { // Reorder entries which we failed to evict. entry.removeMeta(META_NODE); touch(entry); } } }
/** * Shrinks queue to maximum allowed size. */ private void shrink() { long maxSize = this.maxSize; int maxBlocks = this.maxBlocks; int cnt = queue.sizex(); for (int i = 0; i < cnt && (maxBlocks > 0 && queue.sizex() > maxBlocks || maxSize > 0 && curSize.longValue() > maxSize); i++) { GridCacheEntry<GridGgfsBlockKey, byte[]> entry = queue.poll(); if (entry == null) break; // Queue is empty. byte[] val = entry.peek(); if (val != null) changeSize(-val.length); // Change current size as we polled entry from the queue. if (!entry.evict()) { // Reorder entries which we failed to evict. entry.removeMeta(META_NODE); touch(entry); } } }
byte[] val = entry.peek();
byte[] val = entry.peek();