Search in sources :

Example 1 with MessageType

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()));
        }
    }
}
Also used : MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Example 2 with MessageType

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());
    }
}
Also used : ArrayList(java.util.ArrayList) TBase(edu.iu.dsc.tws.api.tset.TBase) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) HashSet(java.util.HashSet)

Example 3 with MessageType

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);
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Test(org.junit.Test)

Example 4 with MessageType

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);
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Test(org.junit.Test)

Example 5 with MessageType

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);
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Test(org.junit.Test)

Aggregations

MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)37 InMessage (edu.iu.dsc.tws.comms.dfw.InMessage)15 ICompute (edu.iu.dsc.tws.api.compute.nodes.ICompute)14 BaseSource (edu.iu.dsc.tws.api.compute.nodes.BaseSource)13 Test (org.junit.Test)13 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)11 ArrayList (java.util.ArrayList)8 List (java.util.List)5 CommunicationContext (edu.iu.dsc.tws.api.comms.CommunicationContext)4 MessageHeader (edu.iu.dsc.tws.api.comms.messaging.MessageHeader)4 JoinedTuple (edu.iu.dsc.tws.api.comms.structs.JoinedTuple)4 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)4 ResettableIterator (edu.iu.dsc.tws.comms.shuffle.ResettableIterator)4 Collections (java.util.Collections)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 Logger (java.util.logging.Logger)4 Op (edu.iu.dsc.tws.api.comms.Op)2 ChannelMessage (edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)2 DataBuffer (edu.iu.dsc.tws.api.comms.packing.DataBuffer)2