Search in sources :

Example 16 with StreamOperator

use of org.apache.flink.streaming.api.operators.StreamOperator in project flink by apache.

the class String2SortMergeJoinOperatorTest method testInnerJoin.

@Test
public void testInnerJoin() throws Exception {
    StreamOperator joinOperator = newOperator(FlinkJoinType.INNER, leftIsSmall);
    TwoInputStreamTaskTestHarness<BinaryRowData, BinaryRowData, JoinedRowData> testHarness = buildSortMergeJoin(joinOperator);
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    expectedOutput.add(new StreamRecord<>(newRow("a", "02")));
    expectedOutput.add(new StreamRecord<>(newRow("b", "14")));
    testHarness.waitForTaskCompletion();
    TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, transformToBinary(testHarness.getOutput()));
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) Test(org.junit.Test)

Example 17 with StreamOperator

use of org.apache.flink.streaming.api.operators.StreamOperator in project flink by apache.

the class String2SortMergeJoinOperatorTest method testRightOuterJoin.

@Test
public void testRightOuterJoin() throws Exception {
    StreamOperator joinOperator = newOperator(FlinkJoinType.RIGHT, leftIsSmall);
    TwoInputStreamTaskTestHarness<BinaryRowData, BinaryRowData, JoinedRowData> testHarness = buildSortMergeJoin(joinOperator);
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    expectedOutput.add(new StreamRecord<>(newRow("a", "02")));
    expectedOutput.add(new StreamRecord<>(newRow("b", "14")));
    expectedOutput.add(new StreamRecord<>(newRow("c", "2null")));
    testHarness.waitForTaskCompletion();
    TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, transformToBinary(testHarness.getOutput()));
}
Also used : JoinedRowData(org.apache.flink.table.data.utils.JoinedRowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) Test(org.junit.Test)

Example 18 with StreamOperator

use of org.apache.flink.streaming.api.operators.StreamOperator in project flink by apache.

the class RandomSortMergeInnerJoinTest method test.

@Test
public void test() throws Exception {
    final TupleGenerator generator1 = new TupleGenerator(SEED1, 500, 4096, KeyMode.SORTED, ValueMode.RANDOM_LENGTH);
    final TupleGenerator generator2 = new TupleGenerator(SEED2, 500, 2048, KeyMode.SORTED, ValueMode.RANDOM_LENGTH);
    final TestData.TupleGeneratorIterator input1 = new TestData.TupleGeneratorIterator(generator1, INPUT_FIRST_SIZE);
    final TestData.TupleGeneratorIterator input2 = new TestData.TupleGeneratorIterator(generator2, INPUT_SECOND_SIZE);
    // collect expected data
    final Map<Integer, Collection<Match>> expectedMatchesMap = matchValues(collectData(input1), collectData(input2));
    // reset the generators
    generator1.reset();
    generator2.reset();
    input1.reset();
    input2.reset();
    StreamOperator operator = getOperator();
    match(expectedMatchesMap, transformToBinary(join(operator, input1, input2)));
    // assert that each expected match was seen
    for (Map.Entry<Integer, Collection<Match>> entry : expectedMatchesMap.entrySet()) {
        Assert.assertTrue("Collection for key " + entry.getKey() + " is not empty", entry.getValue().isEmpty());
    }
}
Also used : TestData(org.apache.flink.runtime.operators.testutils.TestData) TupleGenerator(org.apache.flink.runtime.operators.testutils.TestData.TupleGenerator) Collection(java.util.Collection) StreamOperator(org.apache.flink.streaming.api.operators.StreamOperator) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

StreamOperator (org.apache.flink.streaming.api.operators.StreamOperator)18 Test (org.junit.Test)10 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)7 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)5 AbstractStreamOperator (org.apache.flink.streaming.api.operators.AbstractStreamOperator)5 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)5 HashMap (java.util.HashMap)4 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)4 Configuration (org.apache.flink.configuration.Configuration)4 StreamEdge (org.apache.flink.streaming.api.graph.StreamEdge)4 StreamNode (org.apache.flink.streaming.api.graph.StreamNode)4 OneInputStreamOperator (org.apache.flink.streaming.api.operators.OneInputStreamOperator)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Map (java.util.Map)3 TupleGenerator (org.apache.flink.runtime.operators.testutils.TestData.TupleGenerator)3 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 ExecutionException (java.util.concurrent.ExecutionException)2 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)2