Search in sources :

Example 1 with MapEntries

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

the class AbstractCacheProxy method getAll.

@Override
public Map<K, V> getAll(Set<? extends K> keys, ExpiryPolicy expiryPolicy) {
    ensureOpen();
    validateNotNull(keys);
    if (keys.isEmpty()) {
        return Collections.EMPTY_MAP;
    }
    Set<Data> ks = new HashSet<Data>(keys.size());
    for (K key : keys) {
        Data dataKey = serializationService.toData(key);
        ks.add(dataKey);
    }
    Map<K, V> result = new HashMap<K, V>();
    Collection<Integer> partitions = getPartitionsForKeys(ks);
    try {
        OperationFactory factory = operationProvider.createGetAllOperationFactory(ks, expiryPolicy);
        OperationService operationService = getNodeEngine().getOperationService();
        Map<Integer, Object> responses = operationService.invokeOnPartitions(getServiceName(), factory, partitions);
        for (Object response : responses.values()) {
            MapEntries mapEntries = serializationService.toObject(response);
            mapEntries.putAllToMap(serializationService, result);
        }
    } catch (Throwable e) {
        throw rethrowAllowedTypeFirst(e, CacheException.class);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) CacheException(javax.cache.CacheException) Data(com.hazelcast.nio.serialization.Data) MapEntries(com.hazelcast.map.impl.MapEntries) OperationService(com.hazelcast.spi.OperationService) HashSet(java.util.HashSet) OperationFactory(com.hazelcast.spi.OperationFactory)

Example 2 with MapEntries

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

the class AbstractCacheRecordStore method getAll.

@Override
public MapEntries getAll(Set<Data> keySet, ExpiryPolicy expiryPolicy) {
    expiryPolicy = getExpiryPolicy(expiryPolicy);
    MapEntries result = new MapEntries(keySet.size());
    for (Data key : keySet) {
        Object value = get(key, expiryPolicy);
        if (value != null) {
            result.add(key, toHeapData(value));
        }
    }
    return result;
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) Data(com.hazelcast.nio.serialization.Data)

Example 3 with MapEntries

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

the class CacheGetAllMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    List<Map.Entry<Data, Data>> reducedMap = new ArrayList<Map.Entry<Data, Data>>(map.size());
    for (Map.Entry<Integer, Object> entry : map.entrySet()) {
        MapEntries mapEntries = (MapEntries) nodeEngine.toObject(entry.getValue());
        mapEntries.putAllToList(reducedMap);
    }
    return reducedMap;
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 4 with MapEntries

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

the class MapExecuteWithPredicateMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    List<Map.Entry<Data, Data>> dataMap = new ArrayList<Map.Entry<Data, Data>>();
    MapService mapService = getService(MapService.SERVICE_NAME);
    for (Object o : map.values()) {
        if (o != null) {
            MapEntries mapEntries = (MapEntries) mapService.getMapServiceContext().toObject(o);
            mapEntries.putAllToList(dataMap);
        }
    }
    return dataMap;
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) MapService(com.hazelcast.map.impl.MapService) Map(java.util.Map)

Example 5 with MapEntries

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

the class MapPutAllMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    MapEntries mapEntries = new MapEntries(parameters.entries);
    MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
    return operationProvider.createPutAllOperation(parameters.name, mapEntries);
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider)

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