Search in sources :

Example 6 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyMixing2.

@Test
public void testCoGroupKeyMixing2() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should work
    try {
        ds1.coGroup(ds2).where(3).equalTo(new KeySelector<CustomType, Long>() {

            @Override
            public Long getKey(CustomType value) {
                return value.myLong;
            }
        });
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 7 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions3Nested.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyExpressions3Nested() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, incompatible number of cogroup keys
    ds1.coGroup(ds2).where("nested.myInt", "nested.myString").equalTo("nested.myString");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 8 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyAtomicExpression2.

@Test
public void testCoGroupKeyAtomicExpression2() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Integer> ds1 = env.fromElements(0, 0, 1);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    ds1.coGroup(ds2).where("*").equalTo("myInt");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 9 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions3.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyExpressions3() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, incompatible number of cogroup keys
    ds1.coGroup(ds2).where("myInt", "myString").equalTo("myString");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 10 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeySelectors1.

@Test
public void testCoGroupKeySelectors1() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should work
    try {
        ds1.coGroup(ds2).where(new KeySelector<CustomType, Long>() {

            @Override
            public Long getKey(CustomType value) {
                return value.myLong;
            }
        }).equalTo(new KeySelector<CustomType, Long>() {

            @Override
            public Long getKey(CustomType value) {
                return value.myLong;
            }
        });
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) KeySelector(org.apache.flink.api.java.functions.KeySelector) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)20 CustomType (org.apache.flink.api.java.operator.JoinOperatorTest.CustomType)20 Test (org.junit.Test)20 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)5 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)5 KeySelector (org.apache.flink.api.java.functions.KeySelector)2