use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeLongMessage.
@Test
public void testBuildLargeLongMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.LONG_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((long[]) inMessage.getDeserializedData(), (long[]) data);
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeObjectMessage.
@Test
public void testBuildLargeObjectMessage() {
int numBuffers = 20;
int size = 1000;
MessageType type = MessageTypes.OBJECT;
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 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.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class KeyedSerializerTest method testBuildLargeDoubleMessage.
@Test
public void testBuildLargeDoubleMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.DOUBLE_ARRAY;
Object data = createKeyedData(800, type, MessageTypes.DOUBLE);
InMessage inMessage = keyedSingleValueCase(numBuffers, size, type, MessageTypes.DOUBLE, data);
Tuple deserializedData = (Tuple) inMessage.getDeserializedData();
Assert.assertEquals((double) deserializedData.getKey(), (double) ((Tuple) data).getKey(), 0.1);
Assert.assertArrayEquals((double[]) deserializedData.getValue(), (double[]) ((Tuple) data).getValue(), 0.01);
}
use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.
the class HashJoinUtils method innerJoin.
public static List<Object> innerJoin(List<Tuple> leftRelation, List<Tuple> rightRelation, MessageType messageType) {
Map<Object, List<Tuple>> leftHash = new THashMap<>(messageType);
List<Object> joinedTuples = new ArrayList<>();
for (Tuple tuple : leftRelation) {
leftHash.computeIfAbsent(tuple.getKey(), k -> new ArrayList<>()).add(tuple);
}
for (Tuple rightTuple : rightRelation) {
List<Tuple> leftTuples = leftHash.getOrDefault(rightTuple.getKey(), Collections.emptyList());
for (Tuple leftTuple : leftTuples) {
joinedTuples.add(JoinedTuple.of(leftTuple.getKey(), leftTuple.getValue(), rightTuple.getValue()));
}
}
return joinedTuples;
}
Aggregations