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