Search in sources :

Example 11 with PartitionContainer

use of com.hazelcast.map.impl.PartitionContainer in project hazelcast by hazelcast.

the class PartitionScanRunner method run.

@SuppressWarnings("unchecked")
public Collection<QueryableEntry> run(String mapName, Predicate predicate, int partitionId) {
    PagingPredicate pagingPredicate = predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
    List<QueryableEntry> resultList = new LinkedList<QueryableEntry>();
    PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    Iterator<Record> iterator = partitionContainer.getRecordStore(mapName).loadAwareIterator(getNow(), false);
    Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(pagingPredicate);
    boolean useCachedValues = isUseCachedDeserializedValuesEnabled(mapContainer);
    Extractors extractors = mapServiceContext.getExtractors(mapName);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data key = (Data) toData(record.getKey());
        Object value = toData(useCachedValues ? Records.getValueOrCachedValue(record, serializationService) : record.getValue());
        if (value == null) {
            continue;
        }
        //we want to always use CachedQueryEntry as these are short-living objects anyway
        QueryableEntry queryEntry = new CachedQueryEntry(serializationService, key, value, extractors);
        if (predicate.apply(queryEntry) && compareAnchor(pagingPredicate, queryEntry, nearestAnchorEntry)) {
            resultList.add(queryEntry);
        }
    }
    return getSortedSubList(resultList, pagingPredicate, nearestAnchorEntry);
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) Data(com.hazelcast.nio.serialization.Data) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PagingPredicate(com.hazelcast.query.PagingPredicate) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) PagingPredicateAccessor.getNearestAnchorEntry(com.hazelcast.query.PagingPredicateAccessor.getNearestAnchorEntry) Extractors(com.hazelcast.query.impl.getters.Extractors) Record(com.hazelcast.map.impl.record.Record) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) Map(java.util.Map) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Aggregations

PartitionContainer (com.hazelcast.map.impl.PartitionContainer)11 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 MapService (com.hazelcast.map.impl.MapService)4 MapContainer (com.hazelcast.map.impl.MapContainer)3 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)2 NearCache (com.hazelcast.internal.nearcache.NearCache)1 EntryCostEstimator (com.hazelcast.map.impl.EntryCostEstimator)1 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)1 Record (com.hazelcast.map.impl.record.Record)1 DefaultRecordStore (com.hazelcast.map.impl.recordstore.DefaultRecordStore)1 NearCacheStats (com.hazelcast.monitor.NearCacheStats)1 Address (com.hazelcast.nio.Address)1 Data (com.hazelcast.nio.serialization.Data)1 PagingPredicate (com.hazelcast.query.PagingPredicate)1 PagingPredicateAccessor.getNearestAnchorEntry (com.hazelcast.query.PagingPredicateAccessor.getNearestAnchorEntry)1 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)1 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)1 Extractors (com.hazelcast.query.impl.getters.Extractors)1 NodeEngine (com.hazelcast.spi.NodeEngine)1