Search in sources :

Example 1 with DataCollection

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

the class PutAllOperation method put.

protected void put(Data dataKey, Data dataValue) {
    MultiMapContainer container = getOrCreateContainer();
    Collection<Data> c = ((DataCollection) toObject(dataValue)).getCollection();
    Collection<MultiMapRecord> coll = container.getOrCreateMultiMapValue(dataKey).getCollection(false);
    Iterator<Data> it = c.iterator();
    while (it.hasNext()) {
        Data o = it.next();
        MultiMapRecord record = new MultiMapRecord(container.nextId(), isBinary() ? o : toObject(o));
        if (coll.add(record)) {
            // NB: cant put this in afterRun because we want to notify on each new value
            getOrCreateContainer().update();
            publishEvent(EntryEventType.ADDED, dataKey, o, null);
            response = true;
        }
    // its potentially feasible to publish an event in the else case
    // and publish an event that a supplied value was not added-discarded
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer) DataCollection(com.hazelcast.map.impl.DataCollection) Data(com.hazelcast.internal.serialization.Data)

Example 2 with DataCollection

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

the class KeySetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    List<Object> keys = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        keys.addAll(store.keySet(false));
    }
    ArrayList<Data> dataKeys = new ArrayList<>(keys.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (Object key : keys) {
        dataKeys.add(serializationService.toData(key));
    }
    response = new DataCollection(dataKeys);
}
Also used : DataCollection(com.hazelcast.map.impl.DataCollection) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data)

Example 3 with DataCollection

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

the class PutAllBackupOperation method put.

protected void put(Data dataKey, Data dataValue) {
    MultiMapContainer container = getOrCreateContainer();
    Collection<Data> c = ((DataCollection) toObject(dataValue)).getCollection();
    Collection<MultiMapRecord> coll = container.getOrCreateMultiMapValue(dataKey).getCollection(false);
    Iterator<Data> it = c.iterator();
    while (it.hasNext()) {
        Data o = it.next();
        MultiMapRecord record = new MultiMapRecord(container.nextId(), isBinary() ? o : toObject(o));
        if (coll.add(record)) {
            response = true;
        }
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer) DataCollection(com.hazelcast.map.impl.DataCollection) Data(com.hazelcast.internal.serialization.Data)

Example 4 with DataCollection

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

the class ValuesOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    Collection<ReplicatedRecord> values = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        values.addAll(store.values(false));
    }
    Collection<Data> dataValues = new ArrayList<>(values.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (ReplicatedRecord value : values) {
        dataValues.add(serializationService.toData(value.getValue()));
    }
    response = new DataCollection(dataValues);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) DataCollection(com.hazelcast.map.impl.DataCollection) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data)

Aggregations

Data (com.hazelcast.internal.serialization.Data)4 DataCollection (com.hazelcast.map.impl.DataCollection)4 SerializationService (com.hazelcast.internal.serialization.SerializationService)2 MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)2 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)2 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)2 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)2 ArrayList (java.util.ArrayList)2 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)1