use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeListByteMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListByteMessage() {
int numBuffers = 32;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createKeyedData(800, MessageTypes.BYTE_ARRAY, MessageTypes.BYTE_ARRAY);
data.add(o);
}
InMessage inMessage = keyedListValueCase(numBuffers, size, data, MessageTypes.BYTE_ARRAY, MessageTypes.BYTE_ARRAY);
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.assertArrayEquals((byte[]) deserializedData.getKey(), (byte[]) ((Tuple) d).getKey());
Assert.assertArrayEquals((byte[]) deserializedData.getValue(), (byte[]) ((Tuple) d).getValue());
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeLongMessage.
@Test
public void testBuildLargeLongMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.LONG_ARRAY;
Object data = createKeyedData(800, type, MessageTypes.LONG);
InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.LONG, data);
Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
Assert.assertEquals((long) deserializedData.getKey(), (long) ((Tuple) data).getKey());
Assert.assertArrayEquals((long[]) deserializedData.getValue(), (long[]) ((Tuple) data).getValue());
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeListDoubleMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListDoubleMessage() {
int numBuffers = 32;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createKeyedData(800, MessageTypes.DOUBLE_ARRAY, MessageTypes.DOUBLE);
data.add(o);
}
InMessage inMessage = keyedListValueCase(numBuffers, size, data, MessageTypes.DOUBLE_ARRAY, MessageTypes.DOUBLE);
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((double) deserializedData.getKey(), (double) ((Tuple) d).getKey(), 0.1);
Assert.assertArrayEquals((double[]) deserializedData.getValue(), (double[]) ((Tuple) d).getValue(), 0.01);
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeListLongMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListLongMessage() {
int numBuffers = 32;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createKeyedData(800, MessageTypes.LONG_ARRAY, MessageTypes.LONG);
data.add(o);
}
InMessage inMessage = keyedListValueCase(numBuffers, size, data, MessageTypes.LONG_ARRAY, MessageTypes.LONG);
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((long) deserializedData.getKey(), (long) ((Tuple) d).getKey(), 0.1);
Assert.assertArrayEquals((long[]) deserializedData.getValue(), (long[]) ((Tuple) d).getValue());
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeListIntMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListIntMessage() {
int numBuffers = 16;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createKeyedData(800, MessageTypes.INTEGER_ARRAY, MessageTypes.INTEGER);
data.add(o);
}
InMessage inMessage = keyedListValueCase(numBuffers, size, data, MessageTypes.INTEGER_ARRAY, MessageTypes.INTEGER);
List<Object> result = (List<Object>) inMessage.getDeserializedData();
for (int i = 0; i < result.size(); i++) {
Tuple exp = (Tuple) result.get(i);
Tuple d = (Tuple) data.get(i);
Assert.assertEquals((int) exp.getKey(), (int) ((Tuple) d).getKey());
Assert.assertArrayEquals((int[]) exp.getValue(), (int[]) ((Tuple) d).getValue());
}
}
Aggregations