use of edu.iu.dsc.tws.comms.api.MessageType in project twister2 by DSC-SPIDAL.
the class MPIMessageDeSerializer method getDataBuffers.
@Override
@SuppressWarnings("unchecked")
public Object getDataBuffers(Object partialObject, int edge) {
MPIMessage message = (MPIMessage) partialObject;
MessageType type = message.getType();
// Used when handling multi messages
List<ImmutablePair<byte[], byte[]>> results;
if (!keyed) {
return DataDeserializer.getAsByteBuffer(message.getBuffers(), message.getHeader().getLength(), type);
} else {
Pair<Integer, Object> keyPair = KeyDeserializer.getKeyAsByteBuffer(message.getKeyType(), message.getBuffers());
MessageType keyType = message.getKeyType();
Object data;
if (MessageTypeUtils.isMultiMessageType(keyType)) {
data = DataDeserializer.getAsByteBuffer(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey() - 4 - 4, type, ((List) keyPair.getValue()).size());
results = new ArrayList<>();
List<byte[]> keyList = (List<byte[]>) keyPair.getValue();
List<byte[]> dataList = (List<byte[]>) data;
for (int i = 0; i < keyList.size(); i++) {
results.add(new ImmutablePair<>(keyList.get(i), dataList.get(i)));
}
return results;
} else if (!MessageTypeUtils.isPrimitiveType(keyType)) {
data = DataDeserializer.getAsByteBuffer(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey() - 4, type);
} else {
data = DataDeserializer.getAsByteBuffer(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey(), type);
}
return new ImmutablePair<>(keyPair.getValue(), data);
}
}
use of edu.iu.dsc.tws.comms.api.MessageType in project twister2 by DSC-SPIDAL.
the class MPIMultiMessageDeserializer method getSingleDataBuffers.
public Object getSingleDataBuffers(MPIMessage mpiMessage, List<MPIBuffer> message, int length) {
MessageType type = mpiMessage.getType();
if (!keyed) {
return DataDeserializer.getAsByteBuffer(message, length, type);
} else {
Pair<Integer, Object> keyPair = KeyDeserializer.getKeyAsByteBuffer(mpiMessage.getKeyType(), message);
byte[] data = DataDeserializer.getAsByteBuffer(message, length - keyPair.getKey(), type);
return new ImmutablePair<>(keyPair.getValue(), data);
}
}
use of edu.iu.dsc.tws.comms.api.MessageType in project twister2 by DSC-SPIDAL.
the class MPIMessageDeSerializer method buildMessage.
private Object buildMessage(MPIMessage message) {
MessageType type = message.getType();
if (!keyed) {
return DataDeserializer.deserializeData(message.getBuffers(), message.getHeader().getLength(), serializer, type);
} else {
Pair<Integer, Object> keyPair = KeyDeserializer.deserializeKey(message.getKeyType(), message.getBuffers(), serializer);
MessageType keyType = message.getKeyType();
if (MessageTypeUtils.isMultiMessageType(keyType)) {
return DataDeserializer.deserializeData(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey() - 4 - 4, serializer, type, ((List) keyPair.getValue()).size());
} else if (!MessageTypeUtils.isPrimitiveType(keyType)) {
return DataDeserializer.deserializeData(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey() - 4, serializer, type);
} else {
return DataDeserializer.deserializeData(message.getBuffers(), message.getHeader().getLength() - keyPair.getKey(), serializer, type);
}
}
}
Aggregations