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);
}
}
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);
}
}
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);
}
}
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()));
}
}
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);
}
Aggregations