/** {@inheritDoc} */ @Override public GridProjection forNodes(Collection<? extends GridNode> nodes) { assert g != null; return g.forNodes(nodes); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") private GridCloseableIterator<T> iterator0() { try { GridCacheQuery qry = new GridCacheQueryAdapter<>(ctx, SET, null, null, null, new GridSetQueryPredicate<>(id, collocated), false, false); Collection<GridNode> nodes = dataNodes(ctx.affinity().affinityTopologyVersion()); qry.projection(ctx.grid().forNodes(nodes)); GridCacheQueryFuture<T> fut = qry.execute(); SetIterator<T> it = new SetIterator<>(fut); itFuts.put(it.weakReference(), fut); if (rmvd) { itFuts.remove(it.weakReference()); it.close(); checkRemoved(); } return it; } catch (GridException e) { throw new GridRuntimeException(e); } } /**
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public int size() { try { onAccess(); if (ctx.isLocal() || ctx.isReplicated()) { GridConcurrentHashSet<GridCacheSetItemKey> set = ctx.dataStructures().setData(id); return set != null ? set.size() : 0; } GridCacheQuery qry = new GridCacheQueryAdapter<>(ctx, SET, null, null, null, new GridSetQueryPredicate<>(id, collocated), false, false); Collection<GridNode> nodes = dataNodes(ctx.affinity().affinityTopologyVersion()); qry.projection(ctx.grid().forNodes(nodes)); Iterable<Integer> col = (Iterable<Integer>) qry.execute(new SumReducer()).get(); int sum = 0; for (Integer val : col) sum += val; return sum; } catch (GridException e) { throw new GridRuntimeException(e); } }