Search in sources :

Example 21 with MapContainer

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

the class MapRemoveMessageTask method beforeResponse.

@Override
protected void beforeResponse() {
    final long latency = System.currentTimeMillis() - startTime;
    final MapService mapService = getService(MapService.SERVICE_NAME);
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(parameters.name);
    if (mapContainer.getMapConfig().isStatisticsEnabled()) {
        mapService.getMapServiceContext().getLocalMapStatsProvider().getLocalMapStatsImpl(parameters.name).incrementRemoves(latency);
    }
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 22 with MapContainer

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

the class MapGetMessageTask method beforeResponse.

@Override
protected void beforeResponse() {
    final long latency = System.currentTimeMillis() - startTime;
    final MapService mapService = getService(MapService.SERVICE_NAME);
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(parameters.name);
    if (mapContainer.getMapConfig().isStatisticsEnabled()) {
        mapService.getMapServiceContext().getLocalMapStatsProvider().getLocalMapStatsImpl(parameters.name).incrementGets(latency);
    }
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 23 with MapContainer

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

the class AbstractMapPutMessageTask method beforeResponse.

@Override
protected void beforeResponse() {
    final long latency = System.currentTimeMillis() - startTime;
    final MapService mapService = getService(MapService.SERVICE_NAME);
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(getDistributedObjectName());
    if (mapContainer.getMapConfig().isStatisticsEnabled()) {
        mapService.getMapServiceContext().getLocalMapStatsProvider().getLocalMapStatsImpl(getDistributedObjectName()).incrementPuts(latency);
    }
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 24 with MapContainer

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

the class QueryRunner method runIndexOrPartitionScanQueryOnOwnedPartitions.

// full query = index query (if possible), then partition-scan query
public Result runIndexOrPartitionScanQueryOnOwnedPartitions(Query query) throws ExecutionException, InterruptedException {
    int migrationStamp = getMigrationStamp();
    Collection<Integer> initialPartitions = mapServiceContext.getOwnedPartitions();
    MapContainer mapContainer = mapServiceContext.getMapContainer(query.getMapName());
    // first we optimize the query
    Predicate predicate = queryOptimizer.optimize(query.getPredicate(), mapContainer.getIndexes());
    // then we try to run using an index, but if that doesn't work, we'll try a full table scan
    // This would be the point where a query-plan should be added. It should determine f a full table scan
    // or an index should be used.
    Collection<QueryableEntry> entries = runUsingIndexSafely(predicate, mapContainer, migrationStamp);
    if (entries == null) {
        entries = runUsingPartitionScanSafely(query.getMapName(), predicate, initialPartitions, migrationStamp);
    }
    updateStatistics(mapContainer);
    if (entries != null) {
        // so that caller is aware of partitions from which results were obtained.
        return populateTheResult(query, entries, initialPartitions);
    } else {
        // then return empty result set without any partition IDs set (so that it is ignored by callers).
        return resultProcessorRegistry.get(query.getResultType()).populateResult(query, queryResultSizeLimiter.getNodeResultLimit(initialPartitions.size()));
    }
}
Also used : MapContainer(com.hazelcast.map.impl.MapContainer) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) Predicate(com.hazelcast.query.Predicate)

Example 25 with MapContainer

use of com.hazelcast.map.impl.MapContainer 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

MapContainer (com.hazelcast.map.impl.MapContainer)25 MapService (com.hazelcast.map.impl.MapService)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)6 Data (com.hazelcast.nio.serialization.Data)5 MapConfig (com.hazelcast.config.MapConfig)4 Record (com.hazelcast.map.impl.record.Record)4 Map (java.util.Map)4 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)3 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)3 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 HashMap (java.util.HashMap)3 EntryView (com.hazelcast.core.EntryView)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)2 Predicate (com.hazelcast.query.Predicate)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 Config (com.hazelcast.config.Config)1