Search in sources :

Example 11 with Profile

use of org.apache.samza.test.table.TestTableData.Profile in project samza by apache.

the class TestLocalTableEndToEnd method testDualStreamTableJoin.

@Test
public void testDualStreamTableJoin() {
    int totalPageViews = 40;
    int partitionCount = 4;
    Map<Integer, List<PageView>> inputPageViews1 = TestTableData.generatePartitionedPageViews(totalPageViews, partitionCount);
    Map<Integer, List<PageView>> inputPageViews2 = TestTableData.generatePartitionedPageViews(totalPageViews, partitionCount);
    // 10 is the max member id for page views
    int numProfiles = 10;
    Map<Integer, List<Profile>> inputProfiles1 = TestTableData.generatePartitionedProfiles(numProfiles, partitionCount);
    Map<Integer, List<Profile>> inputProfiles2 = TestTableData.generatePartitionedProfiles(numProfiles, partitionCount);
    InMemorySystemDescriptor isd = new InMemorySystemDescriptor(SYSTEM_NAME);
    InMemoryInputDescriptor<PageView> pageViewStreamDesc1 = isd.getInputDescriptor(PAGEVIEW_STREAM + "1", new NoOpSerde<>());
    InMemoryInputDescriptor<PageView> pageViewStreamDesc2 = isd.getInputDescriptor(PAGEVIEW_STREAM + "2", new NoOpSerde<>());
    InMemoryInputDescriptor<Profile> profileStreamDesc1 = isd.getInputDescriptor(PROFILE_STREAM + "1", new NoOpSerde<>());
    InMemoryInputDescriptor<Profile> profileStreamDesc2 = isd.getInputDescriptor(PROFILE_STREAM + "2", new NoOpSerde<>());
    TestRunner.of(new DualStreamTableJoinApp()).addInputStream(pageViewStreamDesc1, inputPageViews1).addInputStream(pageViewStreamDesc2, inputPageViews2).addInputStream(profileStreamDesc1, inputProfiles1).addInputStream(profileStreamDesc2, inputProfiles2).run(Duration.ofSeconds(10));
    assertEquals(numProfiles, DualStreamTableJoinApp.sentToProfileTable1.size());
    assertEquals(numProfiles, DualStreamTableJoinApp.sentToProfileTable2.size());
    assertEquals(totalPageViews, DualStreamTableJoinApp.joinedPageViews1.size());
    assertEquals(totalPageViews, DualStreamTableJoinApp.joinedPageViews2.size());
    assertNotNull(DualStreamTableJoinApp.joinedPageViews1.get(0));
    assertNotNull(DualStreamTableJoinApp.joinedPageViews2.get(0));
}
Also used : EnrichedPageView(org.apache.samza.test.table.TestTableData.EnrichedPageView) PageView(org.apache.samza.test.table.TestTableData.PageView) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) InMemorySystemDescriptor(org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor) Profile(org.apache.samza.test.table.TestTableData.Profile) Test(org.junit.Test)

Aggregations

InMemorySystemDescriptor (org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor)11 EnrichedPageView (org.apache.samza.test.table.TestTableData.EnrichedPageView)11 PageView (org.apache.samza.test.table.TestTableData.PageView)11 Profile (org.apache.samza.test.table.TestTableData.Profile)11 Test (org.junit.Test)10 List (java.util.List)9 ArrayList (java.util.ArrayList)8 NoOpSerde (org.apache.samza.serializers.NoOpSerde)8 Duration (java.time.Duration)7 Map (java.util.Map)7 StreamApplication (org.apache.samza.application.StreamApplication)7 StreamApplicationDescriptor (org.apache.samza.application.descriptors.StreamApplicationDescriptor)7 Context (org.apache.samza.context.Context)7 KV (org.apache.samza.operators.KV)7 DelegatingSystemDescriptor (org.apache.samza.system.descriptors.DelegatingSystemDescriptor)7 Table (org.apache.samza.table.Table)7 TestRunner (org.apache.samza.test.framework.TestRunner)7 InMemoryInputDescriptor (org.apache.samza.test.framework.system.descriptors.InMemoryInputDescriptor)7 Arrays (java.util.Arrays)6 HashMap (java.util.HashMap)6