use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class ClientMapStandaloneTest method testPortable_query_with_index.
@Test
public void testPortable_query_with_index() {
IMap<Integer, MyPortableElement> map = createMap();
for (int i = 0; i < 100; i++) {
MyPortableElement element = new MyPortableElement(i);
map.put(i, element);
}
map.addIndex(IndexType.HASH, "id");
Predicate predicate = or(equal("id", 0), equal("id", 1));
Collection values = map.values(predicate);
assertEquals(2, values.size());
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method call.
@Override
protected final Object call() throws Exception {
Collection<AccumulatedResults> result = new LinkedList<AccumulatedResults>();
try {
Predicate predicate = getPredicate();
if (predicate instanceof PartitionPredicate) {
int partitionId = clientMessage.getPartitionId();
QueryResult queryResult = invokeOnPartition((PartitionPredicate) predicate, partitionId);
extractAndAppendResult(result, queryResult);
return reduce(result);
}
int partitionCount = clientEngine.getPartitionService().getPartitionCount();
PartitionIdSet finishedPartitions = invokeOnMembers(result, predicate, partitionCount);
invokeOnMissingPartitions(result, predicate, finishedPartitions);
} catch (Throwable t) {
throw rethrow(t);
}
return reduce(result);
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class MapAddEntryListenerToKeyWithPredicateMessageTask method getEventFilter.
@Override
protected EventFilter getEventFilter() {
Predicate predicate = serializationService.toObject(parameters.predicate);
QueryEventFilter eventFilter = new QueryEventFilter(parameters.key, predicate, parameters.includeValue);
return new EventListenerFilter(parameters.listenerFlags, eventFilter);
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class MapFetchWithQueryMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
Projection<?, ?> projection = nodeEngine.getSerializationService().toObject(parameters.projection);
Predicate predicate = nodeEngine.getSerializationService().toObject(parameters.predicate);
Query query = Query.of().mapName(parameters.name).iterationType(IterationType.VALUE).predicate(predicate).projection(projection).build();
IterationPointer[] pointers = decodePointers(parameters.iterationPointers);
return operationProvider.createFetchWithQueryOperation(parameters.name, pointers, parameters.batch, query);
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class PartitionAccumulatorRegistry method createEventFilter.
private EventFilter createEventFilter() {
boolean includeValue = info.isIncludeValue();
Predicate predicate = info.getPredicate();
return new QueryEventFilter(null, predicate, includeValue);
}
Aggregations