use of org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET in project ignite by apache.
the class GridCacheSetImpl method iterator0.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
private GridCloseableIterator<T> iterator0() {
try {
CacheQuery qry = new GridCacheQueryAdapter<>(ctx, SET, null, null, new GridSetQueryPredicate<>(id, collocated), null, false, false);
Collection<ClusterNode> nodes = dataNodes(ctx.affinity().affinityTopologyVersion());
qry.projection(ctx.grid().cluster().forNodes(nodes));
CacheQueryFuture<Map.Entry<T, ?>> fut = qry.execute();
CacheWeakQueryIteratorsHolder.WeakReferenceCloseableIterator it = ctx.itHolder().iterator(fut, new CacheIteratorConverter<T, Map.Entry<T, ?>>() {
@Override
protected T convert(Map.Entry<T, ?> e) {
return e.getKey();
}
@Override
protected void remove(T item) {
GridCacheSetImpl.this.remove(item);
}
});
if (rmvd) {
ctx.itHolder().removeIterator(it);
checkRemoved();
}
return it;
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET in project ignite by apache.
the class GridCacheSetImpl method retainAll.
/**
* {@inheritDoc}
*/
@Override
public boolean retainAll(Collection<?> c) {
try {
onAccess();
try (GridCloseableIterator<T> iter = iterator0()) {
boolean rmv = false;
Set<SetItemKey> rmvKeys = null;
for (T val : iter) {
if (!c.contains(val)) {
rmv = true;
if (rmvKeys == null)
rmvKeys = U.newHashSet(BATCH_SIZE);
rmvKeys.add(itemKey(val));
if (rmvKeys.size() == BATCH_SIZE) {
retryRemoveAll(rmvKeys);
rmvKeys.clear();
}
}
}
if (!F.isEmpty(rmvKeys))
retryRemoveAll(rmvKeys);
return rmv;
}
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET in project ignite by apache.
the class GridCacheSetImpl method sharedCacheIterator.
/**
* @return Shared cache iterator.
*/
@SuppressWarnings("unchecked")
private WeakReferenceCloseableIterator<T> sharedCacheIterator() throws IgniteCheckedException {
CacheQuery qry = new GridCacheQueryAdapter<>(ctx, SET, null, null, new GridSetQueryPredicate<>(id, collocated), collocated ? hdrPart : null, false, false, null);
Collection<ClusterNode> nodes = dataNodes(ctx.affinity().affinityTopologyVersion());
qry.projection(ctx.grid().cluster().forNodes(nodes));
CacheQueryFuture<Map.Entry<T, ?>> fut = qry.execute();
return ctx.itHolder().iterator(fut, new CacheIteratorConverter<T, Map.Entry<T, ?>>() {
@Override
protected T convert(Map.Entry<T, ?> e) {
return e.getKey();
}
@Override
protected void remove(T item) {
GridCacheSetImpl.this.remove(item);
}
});
}
Aggregations