Search in sources :

Example 6 with MapEntries

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

the class PartitionWideEntryOperation method run.

@Override
public void run() {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    responses = new MapEntries(recordStore.size());
    Iterator<Record> iterator = recordStore.iterator(now, false);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data dataKey = record.getKey();
        Object oldValue = record.getValue();
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        if (!applyPredicate(dataKey, value)) {
            continue;
        }
        Map.Entry entry = createMapEntry(dataKey, value);
        Data response = process(entry);
        if (response != null) {
            responses.add(dataKey, response);
        }
        // first call noOp, other if checks below depends on it.
        if (noOp(entry, oldValue, now)) {
            continue;
        }
        if (entryRemoved(entry, dataKey, oldValue, now)) {
            continue;
        }
        entryAddedOrUpdated(entry, dataKey, oldValue, now);
        evict(dataKey);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) SerializationService(com.hazelcast.spi.serialization.SerializationService) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 7 with MapEntries

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

the class MapProxySupport method getAllObjectInternal.

protected void getAllObjectInternal(List<Data> keys, List<Object> resultingKeyValuePairs) {
    if (keys == null || keys.isEmpty()) {
        return;
    }
    if (keys.isEmpty()) {
        return;
    }
    Collection<Integer> partitions = getPartitionsForKeys(keys);
    Map<Integer, Object> responses;
    try {
        OperationFactory operationFactory = operationProvider.createGetAllOperationFactory(name, keys);
        long time = System.currentTimeMillis();
        responses = operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions);
        for (Object response : responses.values()) {
            MapEntries entries = toObject(response);
            for (int i = 0; i < entries.size(); i++) {
                resultingKeyValuePairs.add(toObject(entries.getKey(i)));
                resultingKeyValuePairs.add(toObject(entries.getValue(i)));
            }
        }
        localMapStats.incrementGets(keys.size(), System.currentTimeMillis() - time);
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) OperationFactory(com.hazelcast.spi.OperationFactory) IsEmptyOperationFactory(com.hazelcast.map.impl.operation.IsEmptyOperationFactory) BinaryOperationFactory(com.hazelcast.spi.impl.BinaryOperationFactory) IsPartitionLoadedOperationFactory(com.hazelcast.map.impl.operation.IsPartitionLoadedOperationFactory)

Example 8 with MapEntries

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

the class PutAllBackupOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    entries = new MapEntries();
    entries.readData(in);
    int size = entries.size();
    recordInfos = new ArrayList<RecordInfo>(size);
    for (int i = 0; i < size; i++) {
        RecordInfo recordInfo = new RecordInfo();
        recordInfo.readData(in);
        recordInfos.add(recordInfo);
    }
}
Also used : RecordInfo(com.hazelcast.map.impl.record.RecordInfo) Records.applyRecordInfo(com.hazelcast.map.impl.record.Records.applyRecordInfo) MapEntries(com.hazelcast.map.impl.MapEntries)

Example 9 with MapEntries

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

the class PutAllOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    mapEntries = new MapEntries();
    mapEntries.readData(in);
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries)

Example 10 with MapEntries

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

the class PutAllPartitionAwareOperationFactory method writeData.

@Override
public void writeData(ObjectDataOutput out) throws IOException {
    out.writeUTF(name);
    out.writeIntArray(partitions);
    for (MapEntries entry : mapEntries) {
        entry.writeData(out);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries)

Aggregations

MapEntries (com.hazelcast.map.impl.MapEntries)19 Data (com.hazelcast.nio.serialization.Data)11 Map (java.util.Map)7 ArrayList (java.util.ArrayList)5 OperationFactory (com.hazelcast.spi.OperationFactory)4 MapService (com.hazelcast.map.impl.MapService)3 IsEmptyOperationFactory (com.hazelcast.map.impl.operation.IsEmptyOperationFactory)3 IsPartitionLoadedOperationFactory (com.hazelcast.map.impl.operation.IsPartitionLoadedOperationFactory)3 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)3 InitializingObject (com.hazelcast.spi.InitializingObject)3 BinaryOperationFactory (com.hazelcast.spi.impl.BinaryOperationFactory)3 Record (com.hazelcast.map.impl.record.Record)2 SerializationService (com.hazelcast.spi.serialization.SerializationService)2 HashMap (java.util.HashMap)2 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)1 RecordInfo (com.hazelcast.map.impl.record.RecordInfo)1 Records.applyRecordInfo (com.hazelcast.map.impl.record.Records.applyRecordInfo)1 Address (com.hazelcast.nio.Address)1 OperationService (com.hazelcast.spi.OperationService)1