
org.infinispan.commands.read.EntryRetrievalCommand Maven / Gradle / Ivy
package org.infinispan.commands.read;
import org.infinispan.Cache;
import org.infinispan.commands.VisitableCommand;
import org.infinispan.commands.Visitor;
import org.infinispan.context.Flag;
import org.infinispan.context.InvocationContext;
import org.infinispan.filter.KeyValueFilter;
import org.infinispan.iteration.EntryIterable;
import org.infinispan.iteration.impl.EntryIterableImpl;
import org.infinispan.iteration.impl.EntryRetriever;
import java.util.EnumSet;
import java.util.Set;
/**
* Command that returns an iterable instance that can be used to produce iterators that work over the entire
* cache.
*
* @author wburns
* @since 7.0
*/
public class EntryRetrievalCommand extends AbstractLocalCommand implements VisitableCommand {
private final KeyValueFilter filter;
private final EntryRetriever retriever;
private final Cache cache;
public EntryRetrievalCommand(KeyValueFilter filter, EntryRetriever retriever, Set flags,
Cache cache) {
setFlags(flags);
this.filter = filter;
this.retriever = retriever;
this.cache = cache;
}
@Override
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable {
return visitor.visitEntryRetrievalCommand(ctx, this);
}
@Override
public EntryIterable perform(InvocationContext ctx) throws Throwable {
// We need to copy the flag set since it is possible to modify the flags after retrieving the
// EntryIterable and we don't want it to effect that.
return new EntryIterableImpl<>(retriever, filter, flags != null ? EnumSet.copyOf(flags) :
EnumSet.noneOf(Flag.class), cache);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy