Search in sources :

Example 1 with ReusingBuildSecondHashJoinIterator

use of org.apache.flink.runtime.operators.hash.ReusingBuildSecondHashJoinIterator in project flink by apache.

the class HashVsSortMiniBenchmark method testBuildSecond.

@Test
public void testBuildSecond() {
    try {
        TestData.TupleGenerator generator1 = new TestData.TupleGenerator(SEED1, INPUT_1_SIZE / 10, 100, KeyMode.RANDOM, ValueMode.RANDOM_LENGTH);
        TestData.TupleGenerator generator2 = new TestData.TupleGenerator(SEED2, INPUT_2_SIZE, 100, KeyMode.RANDOM, ValueMode.RANDOM_LENGTH);
        final TestData.TupleGeneratorIterator input1 = new TestData.TupleGeneratorIterator(generator1, INPUT_1_SIZE);
        final TestData.TupleGeneratorIterator input2 = new TestData.TupleGeneratorIterator(generator2, INPUT_2_SIZE);
        final FlatJoinFunction matcher = new NoOpMatcher();
        final Collector<Tuple2<Integer, String>> collector = new DiscardingOutputCollector<>();
        long start = System.nanoTime();
        // compare with iterator values
        ReusingBuildSecondHashJoinIterator<Tuple2<Integer, String>, Tuple2<Integer, String>, Tuple2<Integer, String>> iterator = new ReusingBuildSecondHashJoinIterator<>(input1, input2, this.serializer1.getSerializer(), this.comparator1, this.serializer2.getSerializer(), this.comparator2, this.pairComparator11, this.memoryManager, this.ioManager, this.parentTask, 1, false, false, true);
        iterator.open();
        while (iterator.callWithNextKey(matcher, collector)) ;
        iterator.close();
        long elapsed = System.nanoTime() - start;
        double msecs = elapsed / (1000 * 1000);
        System.out.println("Hash Build Second took " + msecs + " msecs.");
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("An exception occurred during the test: " + e.getMessage());
    }
}
Also used : ReusingBuildSecondHashJoinIterator(org.apache.flink.runtime.operators.hash.ReusingBuildSecondHashJoinIterator) TestData(org.apache.flink.runtime.operators.testutils.TestData) FlatJoinFunction(org.apache.flink.api.common.functions.FlatJoinFunction) DiscardingOutputCollector(org.apache.flink.runtime.operators.testutils.DiscardingOutputCollector) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Aggregations

FlatJoinFunction (org.apache.flink.api.common.functions.FlatJoinFunction)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 ReusingBuildSecondHashJoinIterator (org.apache.flink.runtime.operators.hash.ReusingBuildSecondHashJoinIterator)1 DiscardingOutputCollector (org.apache.flink.runtime.operators.testutils.DiscardingOutputCollector)1 TestData (org.apache.flink.runtime.operators.testutils.TestData)1 Test (org.junit.Test)1