Search in sources :

Example 1 with ReusingBuildFirstHashJoinIterator

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

the class HashVsSortMiniBenchmark method testBuildFirst.

@Test
public void testBuildFirst() {
    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
        final ReusingBuildFirstHashJoinIterator<Tuple2<Integer, String>, Tuple2<Integer, String>, Tuple2<Integer, String>> iterator = new ReusingBuildFirstHashJoinIterator<>(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 First Took " + msecs + " msecs.");
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("An exception occurred during the test: " + e.getMessage());
    }
}
Also used : 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) ReusingBuildFirstHashJoinIterator(org.apache.flink.runtime.operators.hash.ReusingBuildFirstHashJoinIterator) Test(org.junit.Test)

Aggregations

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