use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class TransactionalMapKeySetWithPredicateMessageTask method innerCall.
@Override
protected Object innerCall() throws Exception {
final TransactionContext context = getEndpoint().getTransactionContext(parameters.txnId);
final TransactionalMap map = context.getMap(parameters.name);
Predicate predicate = serializationService.toObject(parameters.predicate);
Set keySet = map.keySet(predicate);
List<Data> list = new ArrayList<Data>(keySet.size());
for (Object o : keySet) {
list.add(serializationService.toData(o));
}
return list;
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class PartitionWideEntryOperation method applyPredicate.
private boolean applyPredicate(Data key, Object value) {
Predicate predicate = getPredicate();
if (predicate == null || TruePredicate.INSTANCE == predicate) {
return true;
}
if (FalsePredicate.INSTANCE == predicate) {
return false;
}
QueryableEntry queryEntry = mapContainer.newQueryEntry(key, value);
return getPredicate().apply(queryEntry);
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class BetweenVisitor method rewriteAttribute.
private int rewriteAttribute(Boundaries boundaries, Predicate[] originalPredicates, int toBeRemovedCount) {
GreaterLessPredicate leftBoundary = boundaries.leftBoundary;
GreaterLessPredicate rightBoundary = boundaries.rightBoundary;
Predicate rewritten = boundaries.createEquivalentPredicate();
for (int i = 0; i < originalPredicates.length; i++) {
Predicate currentPredicate = originalPredicates[i];
if (currentPredicate == leftBoundary) {
originalPredicates[i] = rewritten;
} else if (currentPredicate == rightBoundary) {
originalPredicates[i] = null;
toBeRemovedCount++;
} else if (boundaries.canBeEliminated(currentPredicate)) {
originalPredicates[i] = null;
toBeRemovedCount++;
}
}
return toBeRemovedCount;
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class FlatteningVisitor method visit.
@Override
public Predicate visit(OrPredicate orPredicate, Indexes indexes) {
Predicate[] originalPredicates = orPredicate.predicates;
List<Predicate> toBeAdded = null;
boolean modified = false;
Predicate[] target = originalPredicates;
for (int i = 0; i < target.length; i++) {
Predicate predicate = target[i];
if (predicate instanceof OrPredicate) {
Predicate[] subPredicates = ((OrPredicate) predicate).predicates;
if (!modified) {
modified = true;
target = createCopy(target);
}
toBeAdded = replaceFirstAndStoreOthers(target, subPredicates, i, toBeAdded);
}
}
Predicate[] newInners = createNewInners(target, toBeAdded);
if (newInners == originalPredicates) {
return orPredicate;
}
return new OrPredicate(newInners);
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class FlatteningVisitor method visit.
@Override
public Predicate visit(AndPredicate andPredicate, Indexes indexes) {
Predicate[] originalPredicates = andPredicate.predicates;
List<Predicate> toBeAdded = null;
boolean modified = false;
Predicate[] target = originalPredicates;
for (int i = 0; i < target.length; i++) {
Predicate predicate = target[i];
if (predicate instanceof AndPredicate) {
Predicate[] subPredicates = ((AndPredicate) predicate).predicates;
if (!modified) {
modified = true;
target = createCopy(target);
}
toBeAdded = replaceFirstAndStoreOthers(target, subPredicates, i, toBeAdded);
}
}
Predicate[] newInners = createNewInners(target, toBeAdded);
if (newInners == originalPredicates) {
return andPredicate;
}
return new AndPredicate(newInners);
}
Aggregations