Search in sources :

Example 26 with TupleWindow

use of org.apache.storm.windowing.TupleWindow in project storm by apache.

the class TestJoinBolt method testThreeStreamLeftJoin_2.

@Test
public void testThreeStreamLeftJoin_2() throws Exception {
    ArrayList<Tuple> userStream = makeStream("users", userFields, users, "usersSpout");
    ArrayList<Tuple> storesStream = makeStream("stores", storeFields, stores, "storesSpout");
    ArrayList<Tuple> cityStream = makeStream("cities", cityFields, cities, "citiesSpout");
    TupleWindow window = makeTupleWindow(userStream, cityStream, storesStream);
    JoinBolt bolt = new JoinBolt(JoinBolt.Selector.STREAM, "users", "city").leftJoin("stores", "city", "users").leftJoin("cities", "cityName", // join against diff stream compared to testThreeStreamLeftJoin_1
    "stores").select("name,storeName,city,country");
    MockCollector collector = new MockCollector();
    bolt.prepare(null, null, collector);
    bolt.execute(window);
    printResults(collector);
    // stores.length+1 as 2 users in Bengaluru
    Assert.assertEquals(stores.length + 1, collector.actualResults.size());
}
Also used : TupleWindow(org.apache.storm.windowing.TupleWindow) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Example 27 with TupleWindow

use of org.apache.storm.windowing.TupleWindow in project storm by apache.

the class TestJoinBolt method testThreeStreamInnerJoin.

@Test
public void testThreeStreamInnerJoin() throws Exception {
    ArrayList<Tuple> userStream = makeStream("users", userFields, users, "usersSpout");
    ArrayList<Tuple> storesStream = makeStream("stores", storeFields, stores, "storesSpout");
    ArrayList<Tuple> cityStream = makeStream("cities", cityFields, cities, "citiesSpout");
    TupleWindow window = makeTupleWindow(userStream, storesStream, cityStream);
    JoinBolt bolt = new JoinBolt(JoinBolt.Selector.STREAM, "users", userFields[2]).join("stores", "city", "users").join("cities", "cityName", "stores").select("name,storeName,city,country");
    MockCollector collector = new MockCollector();
    bolt.prepare(null, null, collector);
    bolt.execute(window);
    printResults(collector);
    Assert.assertEquals(6, collector.actualResults.size());
}
Also used : TupleWindow(org.apache.storm.windowing.TupleWindow) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test)

Aggregations

TupleWindow (org.apache.storm.windowing.TupleWindow)27 Tuple (org.apache.storm.tuple.Tuple)22 Test (org.junit.Test)18 BaseBoltTest (org.apache.metron.test.bolt.BaseBoltTest)10 MessageDistributor (org.apache.metron.profiler.MessageDistributor)9 ProfileMeasurement (org.apache.metron.profiler.ProfileMeasurement)4 Test (org.junit.jupiter.api.Test)4 ProfilerConfigurations (org.apache.metron.common.configuration.profiler.ProfilerConfigurations)3 MessageRoute (org.apache.metron.profiler.MessageRoute)3 RulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor)1 Window (com.hortonworks.streamline.streams.layout.component.rule.expression.Window)1 String.format (java.lang.String.format)1 MethodHandles (java.lang.invoke.MethodHandles)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LongSummaryStatistics (java.util.LongSummaryStatistics)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Executors (java.util.concurrent.Executors)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1