use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class TLinkUtils method generateCommsSchema.
public static void generateCommsSchema(Edge edge) {
if (!edge.getMessageSchema().isFixedSchema()) {
MessageType keyType = edge.getKeyType();
MessageType dataType = edge.getDataType();
if (edge.isKeyed()) {
if (keyType.isPrimitive() && dataType.isPrimitive() && !keyType.isArray() && !dataType.isArray()) {
edge.setMessageSchema(MessageSchema.ofSize(keyType.getUnitSizeInBytes() + dataType.getUnitSizeInBytes(), keyType.getUnitSizeInBytes()));
}
} else if (dataType.isPrimitive() && !dataType.isArray()) {
edge.setMessageSchema(MessageSchema.ofSize(dataType.getUnitSizeInBytes()));
}
}
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class JoinTLink method build.
/**
* Uses a different build pattern than the usual {@link edu.iu.dsc.tws.api.tset.link.TLink}s
*
* @param graphBuilder graph builder
* @param buildSequence build seq
*/
@Override
public void build(GraphBuilder graphBuilder, Collection<? extends TBase> buildSequence) {
// filter out the relevant sources out of the predecessors
ArrayList<TBase> sources = new ArrayList<>(getTBaseGraph().getPredecessors(this));
sources.retainAll(buildSequence);
if (sources.size() != 2) {
throw new RuntimeException("Join TLink predecessor count should be 2: Received " + sources.size());
}
// filter out the relevant sources out of the successors
HashSet<TBase> targets = new HashSet<>(getTBaseGraph().getSuccessors(this));
targets.retainAll(buildSequence);
MessageType kType = getSchema().getKeyType();
MessageType dTypeL = getSchema().getDataType();
MessageType dTypeR = getSchema().getDataTypeRight();
for (TBase target : targets) {
// group name = left_right_join_target
String groupName = leftTSet.getId() + "_" + rightTSet.getId() + "_" + getId() + "_" + target.getId();
// build left
buildJoin(graphBuilder, leftTSet, target, 0, groupName, kType, dTypeL, getSchema().isLengthsSpecified(), getSchema().getKeySize(), getSchema().getTotalSize());
// build right
buildJoin(graphBuilder, rightTSet, target, 1, groupName, kType, dTypeR, getSchema().isRightLengthsSpecified(), getSchema().getKeySize(), getSchema().getRightTotalSize());
}
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeDoubleMessage.
@Test
public void testBuildLargeDoubleMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.DOUBLE_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((double[]) inMessage.getDeserializedData(), (double[]) data, .01);
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeIntegerMessage.
@Test
public void testBuildLargeIntegerMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.INTEGER_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((int[]) inMessage.getDeserializedData(), (int[]) data);
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeByteMessage.
@Test
public void testBuildLargeByteMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.BYTE_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((byte[]) inMessage.getDeserializedData(), (byte[]) data);
}
Aggregations