final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
final LocalMapStatsImpl mapStats = mapService.getLocalMapStatsImpl(name);
final Map<Data, Record> records = recordStore.getReadonlyRecordMap();
for (final Map.Entry<Data, Record> recordEntry : records.entrySet()) {
final long start = System.currentTimeMillis();
final Data dataKey = recordEntry.getKey();
final Record record = recordEntry.getValue();
final Object valueBeforeProcess = record.getValue();
final Object valueBeforeProcessObject = mapService.toObject(valueBeforeProcess);
Object objectKey = mapService.toObject(record.getKey());
if (getPredicate() != null) {
final SerializationService ss = getNodeEngine().getSerializationService();
QueryEntry queryEntry = new QueryEntry(ss, dataKey, objectKey, valueBeforeProcessObject);
if (!getPredicate().apply(queryEntry)) {
continue;
}
}
entry = new MapEntrySimple(objectKey, valueBeforeProcessObject);
final Object result = entryProcessor.process(entry);
final Object valueAfterProcess = entry.getValue();
Data dataValue = null;
if (result != null) {
dataValue = mapService.toData(result);
response.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(dataKey, dataValue));
}
EntryEventType eventType;
if (valueAfterProcess == null) {
recordStore.remove(dataKey);
mapStats.incrementRemoves(getLatencyFrom(start));
eventType = EntryEventType.REMOVED;
} else {
if (valueBeforeProcessObject == null) {
mapStats.incrementPuts(getLatencyFrom(start));
eventType = EntryEventType.ADDED;
}
// take this case as a read so no need to fire an event.
else if (!entry.isModified()) {
mapStats.incrementGets(getLatencyFrom(start));
eventType = __NO_NEED_TO_FIRE_EVENT;
} else {
mapStats.incrementPuts(getLatencyFrom(start));
eventType = EntryEventType.UPDATED;
}
// todo if this is a read only operation, record access operations should be done.
if (eventType != __NO_NEED_TO_FIRE_EVENT) {
recordStore.put(new AbstractMap.SimpleImmutableEntry<Data, Object>(dataKey, valueAfterProcess));
}
}
if (eventType != __NO_NEED_TO_FIRE_EVENT) {
final Data oldValue = mapService.toData(valueBeforeProcess);
final Data value = mapService.toData(valueAfterProcess);
mapService.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, value);
if (mapService.isNearCacheAndInvalidationEnabled(name)) {
mapService.invalidateAllNearCaches(name, dataKey);
}
if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {