Search in sources :

Example 1 with CountWindowInformation

use of edu.snu.mist.common.windows.CountWindowInformation 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));
}
Also used : TimeWindowInformation(edu.snu.mist.common.windows.TimeWindowInformation) UDFTestUtils(edu.snu.mist.client.utils.UDFTestUtils) MqttMessage(org.eclipse.paho.client.mqttv3.MqttMessage) Tuple2(edu.snu.mist.common.types.Tuple2) ConfKeys(edu.snu.mist.common.configurations.ConfKeys) MISTEdge(edu.snu.mist.common.graph.MISTEdge) Test(org.junit.Test) IOException(java.io.IOException) MISTQuery(edu.snu.mist.client.MISTQuery) CountWindowInformation(edu.snu.mist.common.windows.CountWindowInformation) SerializeUtils(edu.snu.mist.common.SerializeUtils) DAG(edu.snu.mist.common.graph.DAG) MISTQueryBuilder(edu.snu.mist.client.MISTQueryBuilder) After(org.junit.After) Map(java.util.Map) Direction(edu.snu.mist.formats.avro.Direction) TestParameters(edu.snu.mist.client.utils.TestParameters) InjectionException(org.apache.reef.tang.exceptions.InjectionException) Assert(org.junit.Assert) edu.snu.mist.common.functions(edu.snu.mist.common.functions) SessionWindowInformation(edu.snu.mist.common.windows.SessionWindowInformation) Before(org.junit.Before) Tuple2(edu.snu.mist.common.types.Tuple2) MISTQuery(edu.snu.mist.client.MISTQuery) CountWindowInformation(edu.snu.mist.common.windows.CountWindowInformation) MISTEdge(edu.snu.mist.common.graph.MISTEdge) Test(org.junit.Test)

Example 2 with CountWindowInformation

use of edu.snu.mist.common.windows.CountWindowInformation 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));
}
Also used : Tuple2(edu.snu.mist.common.types.Tuple2) CountWindowInformation(edu.snu.mist.common.windows.CountWindowInformation) MISTEdge(edu.snu.mist.common.graph.MISTEdge) Test(org.junit.Test)

Aggregations

MISTEdge (edu.snu.mist.common.graph.MISTEdge)2 Tuple2 (edu.snu.mist.common.types.Tuple2)2 CountWindowInformation (edu.snu.mist.common.windows.CountWindowInformation)2 Test (org.junit.Test)2 MISTQuery (edu.snu.mist.client.MISTQuery)1 MISTQueryBuilder (edu.snu.mist.client.MISTQueryBuilder)1 TestParameters (edu.snu.mist.client.utils.TestParameters)1 UDFTestUtils (edu.snu.mist.client.utils.UDFTestUtils)1 SerializeUtils (edu.snu.mist.common.SerializeUtils)1 ConfKeys (edu.snu.mist.common.configurations.ConfKeys)1 edu.snu.mist.common.functions (edu.snu.mist.common.functions)1 DAG (edu.snu.mist.common.graph.DAG)1 SessionWindowInformation (edu.snu.mist.common.windows.SessionWindowInformation)1 TimeWindowInformation (edu.snu.mist.common.windows.TimeWindowInformation)1 Direction (edu.snu.mist.formats.avro.Direction)1 IOException (java.io.IOException)1 Map (java.util.Map)1 InjectionException (org.apache.reef.tang.exceptions.InjectionException)1 MqttMessage (org.eclipse.paho.client.mqttv3.MqttMessage)1 After (org.junit.After)1