use of edu.snu.mist.common.graph.MISTEdge in project mist by snuspl.
the class ContinuousStreamTest method testConditionalBranchOperatorStream.
/**
* Test for creating conditional branch operator.
*/
@Test
public void testConditionalBranchOperatorStream() {
final ContinuousStream<Tuple2<String, Integer>> branch1 = filteredMappedStream.routeIf((t) -> t.get(1).equals(1));
final ContinuousStream<Tuple2<String, Integer>> branch2 = filteredMappedStream.routeIf((t) -> t.get(1).equals(2));
final ContinuousStream<Tuple2<String, Integer>> branch3 = filteredMappedStream.routeIf((t) -> t.get(1).equals(3));
final ContinuousStream<String> mapStream = filteredMappedStream.map((t) -> (String) t.get(0));
// --> branch 1
// filteredMappedStream --> branch 2
// --> branch 3
// --> mapStream
final DAG<MISTStream, MISTEdge> dag = queryBuilder.build().getDAG();
final Map<MISTStream, MISTEdge> edges = dag.getEdges(filteredMappedStream);
Assert.assertEquals(3, filteredMappedStream.getCondBranchCount());
Assert.assertEquals(4, edges.size());
Assert.assertEquals(new MISTEdge(Direction.LEFT), edges.get(branch1));
Assert.assertEquals(new MISTEdge(Direction.LEFT), edges.get(branch2));
Assert.assertEquals(new MISTEdge(Direction.LEFT), edges.get(branch3));
Assert.assertEquals(new MISTEdge(Direction.LEFT), edges.get(mapStream));
Assert.assertEquals(1, branch1.getBranchIndex());
Assert.assertEquals(2, branch2.getBranchIndex());
Assert.assertEquals(3, branch3.getBranchIndex());
Assert.assertEquals(0, mapStream.getBranchIndex());
}
use of edu.snu.mist.common.graph.MISTEdge in project mist by snuspl.
the class ContinuousStreamTest method testApplyStatefulOperatorStream.
/**
* Test for stateful UDF operator.
*/
@Test
public void testApplyStatefulOperatorStream() throws InjectionException, IOException, ClassNotFoundException {
final ApplyStatefulFunction<Tuple2<String, Integer>, Integer> applyStatefulFunction = new UDFTestUtils.TestApplyStatefulFunction();
final ContinuousStream<Integer> statefulOperatorStream = filteredMappedStream.applyStateful(applyStatefulFunction);
/* Simulate two data inputs on UDF stream */
final Map<String, String> conf = statefulOperatorStream.getConfiguration();
Assert.assertEquals(SerializeUtils.serializeToString(applyStatefulFunction), conf.get(ConfKeys.OperatorConf.UDF_STRING.name()));
// Check filter -> map -> applyStateful
checkEdges(queryBuilder.build().getDAG(), 1, filteredMappedStream, statefulOperatorStream, new MISTEdge(Direction.LEFT));
}
use of edu.snu.mist.common.graph.MISTEdge in project mist by snuspl.
the class ContinuousStreamTest method testJoinOperatorStream.
/**
* Test for join operation.
*/
@Test
public void testJoinOperatorStream() throws InjectionException, IOException, ClassNotFoundException {
final ContinuousStream<String> firstInputStream = queryBuilder.socketTextStream(TestParameters.LOCAL_TEXT_SOCKET_SOURCE_CONF);
final ContinuousStream<String> secondInputStream = queryBuilder.socketTextStream(TestParameters.LOCAL_TEXT_SOCKET_SOURCE_CONF);
final MISTBiPredicate<String, String> joinBiPred = (string1, string2) -> string1.equals(string2);
final WindowedStream<Tuple2<String, String>> joinedStream = firstInputStream.join(secondInputStream, joinBiPred, new CountWindowInformation(5, 3));
final Map<String, String> conf = joinedStream.getConfiguration();
Assert.assertEquals(SerializeUtils.serializeToString(joinBiPred), conf.get(ConfKeys.OperatorConf.UDF_STRING.name()));
// Check first input -> mapped
final MISTQuery query = queryBuilder.build();
final DAG<MISTStream, MISTEdge> dag = query.getDAG();
final MISTStream firstMappedInputStream = getNextOperatorStream(dag, 1, firstInputStream, new MISTEdge(Direction.LEFT));
// Check second input -> mapped
final MISTStream secondMappedInputStream = getNextOperatorStream(dag, 1, secondInputStream, new MISTEdge(Direction.LEFT));
// Check two mapped input -> unified
final MISTStream firstUnifiedStream = getNextOperatorStream(dag, 1, firstMappedInputStream, new MISTEdge(Direction.LEFT));
final MISTStream secondUnifiedStream = getNextOperatorStream(dag, 1, secondMappedInputStream, new MISTEdge(Direction.RIGHT));
Assert.assertEquals(firstUnifiedStream, secondUnifiedStream);
// Check unified stream -> windowed
final MISTStream windowedStream = getNextOperatorStream(dag, 1, firstUnifiedStream, new MISTEdge(Direction.LEFT));
// Check windowed stream -> joined
checkEdges(dag, 1, windowedStream, joinedStream, new MISTEdge(Direction.LEFT));
}
use of edu.snu.mist.common.graph.MISTEdge in project mist by snuspl.
the class ContinuousStreamTest method testBasicOperatorStream.
/**
* Test for basic stateless OperatorStreams.
*/
@Test
public void testBasicOperatorStream() throws IOException {
final Map<String, String> filteredConf = filteredMappedStream.getConfiguration();
Assert.assertEquals(SerializeUtils.serializeToString(defaultMap), filteredConf.get(ConfKeys.OperatorConf.UDF_STRING.name()));
final MISTQuery query = queryBuilder.build();
final DAG<MISTStream, MISTEdge> dag = query.getDAG();
// Check src -> filiter
final Map<MISTStream, MISTEdge> neighbors = dag.getEdges(sourceStream);
Assert.assertEquals(1, neighbors.size());
final MISTEdge edgeInfo = neighbors.get(filteredStream);
Assert.assertEquals(Direction.LEFT, edgeInfo.getDirection());
Assert.assertEquals(0, edgeInfo.getIndex());
// Check filter -> map
final Map<MISTStream, MISTEdge> neighbors2 = dag.getEdges(filteredStream);
Assert.assertEquals(1, neighbors2.size());
final MISTEdge edgeInfo2 = neighbors2.get(filteredMappedStream);
Assert.assertEquals(Direction.LEFT, edgeInfo2.getDirection());
Assert.assertEquals(0, edgeInfo2.getIndex());
}
use of edu.snu.mist.common.graph.MISTEdge in project mist by snuspl.
the class ContinuousStreamTest method testCountWindowedStream.
/**
* Test for creating count-based WindowedStream from ContinuousStream.
*/
@Test
public void testCountWindowedStream() throws InjectionException {
/* Creates a test windowed stream containing 5000 inputs and emits windowed stream every 1000 inputs */
final WindowedStream<Tuple2<String, Integer>> countWindowedStream = filteredMappedStream.window(new CountWindowInformation(windowSize, windowEmissionInterval));
checkSizeBasedWindowInfo(windowSize, windowEmissionInterval, countWindowedStream.getConfiguration());
// Check map -> countWindow
checkEdges(queryBuilder.build().getDAG(), 1, filteredMappedStream, countWindowedStream, new MISTEdge(Direction.LEFT));
}
Aggregations