use of com.hazelcast.query.PagingPredicate in project hazelcast by hazelcast.
the class MapProxyImpl method aggregate.
@Override
public <R> R aggregate(Aggregator<Map.Entry<K, V>, R> aggregator, Predicate<K, V> predicate) {
checkNotNull(aggregator, NULL_AGGREGATOR_IS_NOT_ALLOWED);
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
aggregator = serializationService.toObject(serializationService.toData(aggregator));
MapQueryEngine queryEngine = getMapQueryEngine();
if (predicate instanceof PagingPredicate) {
throw new IllegalArgumentException("PagingPredicate now allowed with EntryAggregator.");
}
Query query = Query.of().mapName(getName()).predicate(predicate).iterationType(IterationType.ENTRY).aggregator(aggregator).build();
AggregationResult result = queryEngine.execute(query, Target.ALL_NODES);
return result.<R>getAggregator().aggregate();
}
use of com.hazelcast.query.PagingPredicate in project hazelcast by hazelcast.
the class ClientMapProxy method keySet.
@Override
@SuppressWarnings("unchecked")
public Set<K> keySet(Predicate predicate) {
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
if (predicate instanceof PagingPredicate) {
return keySetWithPagingPredicate((PagingPredicate) predicate);
}
ClientMessage request = MapKeySetWithPredicateCodec.encodeRequest(name, toData(predicate));
ClientMessage response = invoke(request);
MapKeySetWithPredicateCodec.ResponseParameters resultParameters = MapKeySetWithPredicateCodec.decodeResponse(response);
InflatableSet.Builder<K> setBuilder = InflatableSet.newBuilder(resultParameters.response.size());
for (Data data : resultParameters.response) {
K key = toObject(data);
setBuilder.add(key);
}
return setBuilder.build();
}
use of com.hazelcast.query.PagingPredicate in project hazelcast by hazelcast.
the class ClientMapProxy method entrySet.
@Override
@SuppressWarnings("unchecked")
public Set<Entry<K, V>> entrySet(Predicate predicate) {
if (predicate instanceof PagingPredicate) {
return entrySetWithPagingPredicate((PagingPredicate) predicate);
}
ClientMessage request = MapEntriesWithPredicateCodec.encodeRequest(name, toData(predicate));
ClientMessage response = invoke(request);
MapEntriesWithPredicateCodec.ResponseParameters resultParameters = MapEntriesWithPredicateCodec.decodeResponse(response);
InflatableSet.Builder<Entry<K, V>> setBuilder = InflatableSet.newBuilder(resultParameters.response.size());
InternalSerializationService serializationService = ((InternalSerializationService) getContext().getSerializationService());
for (Entry<Data, Data> row : resultParameters.response) {
LazyMapEntry entry = new LazyMapEntry(row.getKey(), row.getValue(), serializationService);
setBuilder.add(entry);
}
return setBuilder.build();
}
use of com.hazelcast.query.PagingPredicate in project hazelcast by hazelcast.
the class ClientMapProxy method values.
@Override
public Collection<V> values(Predicate predicate) {
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
if (predicate instanceof PagingPredicate) {
return valuesForPagingPredicate((PagingPredicate) predicate);
}
ClientMessage request = MapValuesWithPredicateCodec.encodeRequest(name, toData(predicate));
ClientMessage response = invoke(request);
MapValuesWithPredicateCodec.ResponseParameters resultParameters = MapValuesWithPredicateCodec.decodeResponse(response);
return new UnmodifiableLazyList<V>(resultParameters.response, getSerializationService());
}
use of com.hazelcast.query.PagingPredicate in project hazelcast by hazelcast.
the class ClientPagingPredicateTest method mapPagingPredicateEmployeeObjectWithOrderedIndex.
private void mapPagingPredicateEmployeeObjectWithOrderedIndex(int maxEmployee) {
final IMap<Integer, Employee> map = makeEmployeeMap(maxEmployee);
map.addIndex("id", true);
Predicate pred = Predicates.lessThan("id", 2);
PagingPredicate<Integer, Employee> predicate = new PagingPredicate<Integer, Employee>(pred, 2);
Collection<Employee> values;
values = map.values(predicate);
System.out.println(values);
assertEquals(2, values.size());
predicate.nextPage();
values = map.values(predicate);
System.out.println(values);
assertEquals(0, values.size());
}
Aggregations