use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class MultiMapValuesMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
List<Data> list = new ArrayList<Data>();
for (Object obj : map.values()) {
if (obj == null) {
continue;
}
MultiMapResponse response = (MultiMapResponse) obj;
Collection<MultiMapRecord> coll = response.getCollection();
if (coll == null) {
continue;
}
for (MultiMapRecord record : coll) {
list.add(serializationService.toData(record.getObject()));
}
}
return list;
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class MultiMapMigrationOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
out.writeInt(map.size());
for (Map.Entry<String, Map> entry : map.entrySet()) {
String name = entry.getKey();
out.writeUTF(name);
Map<Data, MultiMapValue> collections = entry.getValue();
out.writeInt(collections.size());
for (Map.Entry<Data, MultiMapValue> collectionEntry : collections.entrySet()) {
Data key = collectionEntry.getKey();
out.writeData(key);
MultiMapValue multiMapValue = collectionEntry.getValue();
Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
out.writeInt(coll.size());
String collectionType = MultiMapConfig.ValueCollectionType.SET.name();
if (coll instanceof List) {
collectionType = MultiMapConfig.ValueCollectionType.LIST.name();
}
out.writeUTF(collectionType);
for (MultiMapRecord record : coll) {
record.writeData(out);
}
}
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class MultiMapMigrationOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
int mapSize = in.readInt();
map = new HashMap<String, Map>(mapSize);
for (int i = 0; i < mapSize; i++) {
String name = in.readUTF();
int collectionSize = in.readInt();
Map<Data, MultiMapValue> collections = new HashMap<Data, MultiMapValue>();
for (int j = 0; j < collectionSize; j++) {
Data key = in.readData();
int collSize = in.readInt();
String collectionType = in.readUTF();
Collection<MultiMapRecord> coll;
if (collectionType.equals(MultiMapConfig.ValueCollectionType.SET.name())) {
coll = new HashSet<MultiMapRecord>();
} else {
coll = new LinkedList<MultiMapRecord>();
}
for (int k = 0; k < collSize; k++) {
MultiMapRecord record = new MultiMapRecord();
record.readData(in);
coll.add(record);
}
collections.put(key, new MultiMapValue(coll));
}
map.put(name, collections);
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class MultiMapResponse method getRecordCollection.
public Collection<MultiMapRecord> getRecordCollection(NodeEngine nodeEngine) {
if (collection == null) {
return emptyCollection(collectionType);
}
final Collection<MultiMapRecord> newCollection = createCollection(collectionType, collection.size());
for (Object obj : collection) {
MultiMapRecord record = nodeEngine.toObject(obj);
newCollection.add(record);
}
return newCollection;
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class MultiMapResponse method getObjectCollection.
public Collection getObjectCollection(NodeEngine nodeEngine) {
if (collection == null) {
return emptyCollection(collectionType);
}
final Collection newCollection = createCollection(collectionType, collection.size());
for (Object obj : collection) {
MultiMapRecord record = nodeEngine.toObject(obj);
newCollection.add(nodeEngine.toObject(record.getObject()));
}
return newCollection;
}
Aggregations