Search in sources :

Example 6 with PagingPredicateImpl

use of com.hazelcast.query.impl.predicates.PagingPredicateImpl in project hazelcast by hazelcast.

the class QueryEngineImpl method adjustQuery.

private Query adjustQuery(Query query) {
    IterationType retrievalIterationType = getRetrievalIterationType(query.getPredicate(), query.getIterationType());
    Query adjustedQuery = Query.of(query).iterationType(retrievalIterationType).build();
    if (adjustedQuery.getPredicate() instanceof PagingPredicateImpl) {
        ((PagingPredicateImpl) adjustedQuery.getPredicate()).setIterationType(query.getIterationType());
    } else {
        if (adjustedQuery.getPredicate() == Predicates.alwaysTrue()) {
            queryResultSizeLimiter.precheckMaxResultLimitOnLocalPartitions(adjustedQuery.getMapName());
        }
    }
    return adjustedQuery;
}
Also used : IterationType(com.hazelcast.internal.util.IterationType) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Example 7 with PagingPredicateImpl

use of com.hazelcast.query.impl.predicates.PagingPredicateImpl in project hazelcast by hazelcast.

the class ParallelPartitionScanExecutor method execute.

@SuppressWarnings("unchecked")
@Override
public void execute(String mapName, Predicate predicate, Collection<Integer> partitions, Result result) {
    runUsingPartitionScanWithoutPaging(mapName, predicate, partitions, result);
    if (predicate instanceof PagingPredicateImpl) {
        PagingPredicateImpl pagingPredicate = (PagingPredicateImpl) predicate;
        Map.Entry<Integer, Map.Entry> nearestAnchorEntry = pagingPredicate.getNearestAnchorEntry();
        result.orderAndLimit(pagingPredicate, nearestAnchorEntry);
    }
}
Also used : Map(java.util.Map) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Example 8 with PagingPredicateImpl

use of com.hazelcast.query.impl.predicates.PagingPredicateImpl in project hazelcast by hazelcast.

the class ClientMapProxy method keySetWithPagingPredicate.

@SuppressWarnings("unchecked")
private Set keySetWithPagingPredicate(Predicate predicate) {
    PagingPredicateImpl pagingPredicate = unwrapPagingPredicate(predicate);
    pagingPredicate.setIterationType(IterationType.KEY);
    PagingPredicateHolder pagingPredicateHolder = PagingPredicateHolder.of(predicate, getSerializationService());
    ClientMessage request = MapKeySetWithPagingPredicateCodec.encodeRequest(name, pagingPredicateHolder);
    ClientMessage response = invokeWithPredicate(request, predicate);
    MapKeySetWithPagingPredicateCodec.ResponseParameters resultParameters = MapKeySetWithPagingPredicateCodec.decodeResponse(response);
    SerializationService serializationService = getSerializationService();
    pagingPredicate.setAnchorList(resultParameters.anchorDataList.asAnchorList(serializationService));
    return new UnmodifiableLazySet(resultParameters.response, serializationService);
}
Also used : PagingPredicateHolder(com.hazelcast.client.impl.protocol.codec.holder.PagingPredicateHolder) MapKeySetWithPagingPredicateCodec(com.hazelcast.client.impl.protocol.codec.MapKeySetWithPagingPredicateCodec) SerializationService(com.hazelcast.internal.serialization.SerializationService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) UnmodifiableLazySet(com.hazelcast.spi.impl.UnmodifiableLazySet) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Example 9 with PagingPredicateImpl

use of com.hazelcast.query.impl.predicates.PagingPredicateImpl in project hazelcast by hazelcast.

the class ClientMapProxy method entrySetWithPagingPredicate.

private Set entrySetWithPagingPredicate(Predicate predicate) {
    PagingPredicateImpl pagingPredicate = unwrapPagingPredicate(predicate);
    pagingPredicate.setIterationType(IterationType.ENTRY);
    PagingPredicateHolder pagingPredicateHolder = PagingPredicateHolder.of(predicate, getSerializationService());
    ClientMessage request = MapEntriesWithPagingPredicateCodec.encodeRequest(name, pagingPredicateHolder);
    ClientMessage response = invokeWithPredicate(request, predicate);
    MapEntriesWithPagingPredicateCodec.ResponseParameters resultParameters = MapEntriesWithPagingPredicateCodec.decodeResponse(response);
    pagingPredicate.setAnchorList(resultParameters.anchorDataList.asAnchorList(getSerializationService()));
    return getEntriesAsImmutableLazySet(resultParameters.response);
}
Also used : PagingPredicateHolder(com.hazelcast.client.impl.protocol.codec.holder.PagingPredicateHolder) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) MapEntriesWithPagingPredicateCodec(com.hazelcast.client.impl.protocol.codec.MapEntriesWithPagingPredicateCodec) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Example 10 with PagingPredicateImpl

use of com.hazelcast.query.impl.predicates.PagingPredicateImpl in project hazelcast by hazelcast.

the class ClientMapProxy method valuesForPagingPredicate.

@SuppressWarnings("unchecked")
private Collection<V> valuesForPagingPredicate(Predicate predicate) {
    PagingPredicateImpl pagingPredicate = unwrapPagingPredicate(predicate);
    pagingPredicate.setIterationType(IterationType.VALUE);
    PagingPredicateHolder pagingPredicateHolder = PagingPredicateHolder.of(predicate, getSerializationService());
    ClientMessage request = MapValuesWithPagingPredicateCodec.encodeRequest(name, pagingPredicateHolder);
    ClientMessage response = invokeWithPredicate(request, predicate);
    MapValuesWithPagingPredicateCodec.ResponseParameters resultParameters = MapValuesWithPagingPredicateCodec.decodeResponse(response);
    SerializationService serializationService = getSerializationService();
    pagingPredicate.setAnchorList(resultParameters.anchorDataList.asAnchorList(serializationService));
    return (Collection<V>) new UnmodifiableLazyList(resultParameters.response, serializationService);
}
Also used : PagingPredicateHolder(com.hazelcast.client.impl.protocol.codec.holder.PagingPredicateHolder) SerializationService(com.hazelcast.internal.serialization.SerializationService) Collection(java.util.Collection) CollectionUtil.objectToDataCollection(com.hazelcast.internal.util.CollectionUtil.objectToDataCollection) UnmodifiableLazyList(com.hazelcast.spi.impl.UnmodifiableLazyList) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) MapValuesWithPagingPredicateCodec(com.hazelcast.client.impl.protocol.codec.MapValuesWithPagingPredicateCodec) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl)

Aggregations

PagingPredicateImpl (com.hazelcast.query.impl.predicates.PagingPredicateImpl)13 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)5 Map (java.util.Map)5 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 PagingPredicateHolder (com.hazelcast.client.impl.protocol.codec.holder.PagingPredicateHolder)3 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)3 AbstractMap (java.util.AbstractMap)3 Data (com.hazelcast.internal.serialization.Data)2 SerializationService (com.hazelcast.internal.serialization.SerializationService)2 IterationType (com.hazelcast.internal.util.IterationType)2 Predicate (com.hazelcast.query.Predicate)2 MapEntriesWithPagingPredicateCodec (com.hazelcast.client.impl.protocol.codec.MapEntriesWithPagingPredicateCodec)1 MapKeySetWithPagingPredicateCodec (com.hazelcast.client.impl.protocol.codec.MapKeySetWithPagingPredicateCodec)1 MapValuesWithPagingPredicateCodec (com.hazelcast.client.impl.protocol.codec.MapValuesWithPagingPredicateCodec)1 CollectionUtil.objectToDataCollection (com.hazelcast.internal.util.CollectionUtil.objectToDataCollection)1 ToHeapDataConverter.toHeapData (com.hazelcast.internal.util.ToHeapDataConverter.toHeapData)1 LazyMapEntry (com.hazelcast.map.impl.LazyMapEntry)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)1 Record (com.hazelcast.map.impl.record.Record)1