Search in sources :

Example 76 with Tuple

use of edu.iu.dsc.tws.api.comms.structs.Tuple in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeIntegerMessage.

@Test
public void testBuildLargeIntegerMessage() {
    int numBuffers = 10;
    int size = 1000;
    MessageType type = MessageTypes.INTEGER_ARRAY;
    Object data = createKeyedData(800, type, MessageTypes.INTEGER);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.INTEGER, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((int) deserializedData.getKey(), (int) ((Tuple) data).getKey());
    Assert.assertArrayEquals((int[]) deserializedData.getValue(), (int[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 77 with Tuple

use of edu.iu.dsc.tws.api.comms.structs.Tuple in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeListIntegerByteMessage.

@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListIntegerByteMessage() {
    int numBuffers = 128;
    int size = 1000;
    List<Object> data = new AggregatedObjects<>();
    for (int i = 0; i < 128; i++) {
        Object o = createKeyedData(320, MessageTypes.BYTE_ARRAY, MessageTypes.INTEGER);
        data.add(o);
    }
    InMessage inMessage = keyedListValueCase(numBuffers, size, data, MessageTypes.BYTE_ARRAY, MessageTypes.INTEGER);
    List<Object> result = (List<Object>) inMessage.getDeserializedData();
    for (int i = 0; i < result.size(); i++) {
        Tuple deserializedData = (Tuple) result.get(i);
        Tuple d = (Tuple) data.get(i);
        Assert.assertEquals(deserializedData.getKey(), d.getKey());
        Assert.assertArrayEquals((byte[]) deserializedData.getValue(), (byte[]) d.getValue());
    }
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) List(java.util.List) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 78 with Tuple

use of edu.iu.dsc.tws.api.comms.structs.Tuple in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildIntegerMessage.

@Test
public void testBuildIntegerMessage() {
    int numBuffers = 4;
    int size = 1000;
    MessageType type = MessageTypes.INTEGER_ARRAY;
    Object data = createKeyedData(80, type, MessageTypes.INTEGER);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.INTEGER, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((int) deserializedData.getKey(), (int) ((Tuple) data).getKey());
    Assert.assertArrayEquals((int[]) deserializedData.getValue(), (int[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 79 with Tuple

use of edu.iu.dsc.tws.api.comms.structs.Tuple in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildObjectMessage.

@Test
public void testBuildObjectMessage() {
    int numBuffers = 4;
    int size = 1000;
    MessageType type = MessageTypes.OBJECT;
    Object data = createKeyedData(80, type, MessageTypes.OBJECT);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.OBJECT, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertArrayEquals((byte[]) deserializedData.getKey(), (byte[]) ((Tuple) data).getKey());
    Assert.assertArrayEquals((byte[]) deserializedData.getValue(), (byte[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Example 80 with Tuple

use of edu.iu.dsc.tws.api.comms.structs.Tuple in project twister2 by DSC-SPIDAL.

the class KeyedSerializerTest method testBuildLargeShortMessage.

@Test
public void testBuildLargeShortMessage() {
    int numBuffers = 10;
    int size = 1000;
    MessageType type = MessageTypes.SHORT_ARRAY;
    Object data = createKeyedData(800, type, MessageTypes.SHORT);
    InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.SHORT, data);
    Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
    Assert.assertEquals((short) deserializedData.getKey(), (short) ((Tuple) data).getKey());
    Assert.assertArrayEquals((short[]) deserializedData.getValue(), (short[]) ((Tuple) data).getValue());
}
Also used : InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Test(org.junit.Test)

Aggregations

Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)98 Iterator (java.util.Iterator)38 List (java.util.List)35 Logger (java.util.logging.Logger)34 ArrayList (java.util.ArrayList)29 Config (edu.iu.dsc.tws.api.config.Config)27 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)24 Test (org.junit.Test)24 BatchEnvironment (edu.iu.dsc.tws.tset.env.BatchEnvironment)18 InMessage (edu.iu.dsc.tws.comms.dfw.InMessage)17 HashMap (java.util.HashMap)16 TSetEnvironment (edu.iu.dsc.tws.tset.env.TSetEnvironment)15 JobConfig (edu.iu.dsc.tws.api.JobConfig)14 MessageTypes (edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes)14 JoinedTuple (edu.iu.dsc.tws.api.comms.structs.JoinedTuple)14 ResourceAllocator (edu.iu.dsc.tws.rsched.core.ResourceAllocator)14 SourceTSet (edu.iu.dsc.tws.tset.sets.batch.SourceTSet)13 CommunicationContext (edu.iu.dsc.tws.api.comms.CommunicationContext)11 MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)11 Comparator (java.util.Comparator)11