Search in sources :

Example 11 with CompositeType

use of org.apache.flink.api.common.typeutils.CompositeType in project flink by apache.

the class SemanticPropUtilTest method testSingleProjectionProperties.

// --------------------------------------------------------------------------------------------
// Projection Operator Properties
// --------------------------------------------------------------------------------------------
@Test
public void testSingleProjectionProperties() {
    int[] pMap = new int[] { 3, 0, 4 };
    SingleInputSemanticProperties sp = SemanticPropUtil.createProjectionPropertiesSingle(pMap, (CompositeType<?>) fiveIntTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 0).contains(1));
    assertTrue(sp.getForwardingTargetFields(0, 3).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 4).contains(2));
    pMap = new int[] { 2, 2, 1, 1 };
    sp = SemanticPropUtil.createProjectionPropertiesSingle(pMap, (CompositeType<?>) fiveIntTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 1).size() == 2);
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(3));
    assertTrue(sp.getForwardingTargetFields(0, 2).size() == 2);
    assertTrue(sp.getForwardingTargetFields(0, 2).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 2).contains(1));
    pMap = new int[] { 2, 0 };
    sp = SemanticPropUtil.createProjectionPropertiesSingle(pMap, (CompositeType<?>) nestedTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 4).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 0).contains(1));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
    assertTrue(sp.getForwardingTargetFields(0, 2).contains(3));
    pMap = new int[] { 2, 0, 1 };
    sp = SemanticPropUtil.createProjectionPropertiesSingle(pMap, (CompositeType<?>) deepNestedTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 6).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 0).contains(1));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
    assertTrue(sp.getForwardingTargetFields(0, 2).contains(3));
    assertTrue(sp.getForwardingTargetFields(0, 3).contains(4));
    assertTrue(sp.getForwardingTargetFields(0, 4).contains(5));
    assertTrue(sp.getForwardingTargetFields(0, 5).contains(6));
    pMap = new int[] { 2, 1 };
    sp = SemanticPropUtil.createProjectionPropertiesSingle(pMap, (CompositeType<?>) pojoInTupleType);
    assertTrue(sp.getForwardingTargetFields(0, 2).contains(0));
    assertTrue(sp.getForwardingTargetFields(0, 3).contains(1));
    assertTrue(sp.getForwardingTargetFields(0, 4).contains(2));
    assertTrue(sp.getForwardingTargetFields(0, 5).contains(3));
    assertTrue(sp.getForwardingTargetFields(0, 1).contains(4));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) CompositeType(org.apache.flink.api.common.typeutils.CompositeType) Test(org.junit.Test)

Example 12 with CompositeType

use of org.apache.flink.api.common.typeutils.CompositeType in project flink by apache.

the class JoinOperatorTest method testJoinKeyNestedTuplesWithCustom.

@Test
public void testJoinKeyNestedTuplesWithCustom() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple5<CustomType, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyNestedCustomTupleData, nestedCustomTupleTypeInfo);
    DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);
    try {
        TypeInformation<?> t = ds1.join(ds2).where("f0.myInt").equalTo(4).getType();
        assertTrue("not a composite type", t instanceof CompositeType);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}
Also used : Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) CompositeType(org.apache.flink.api.common.typeutils.CompositeType) Test(org.junit.Test)

Aggregations

CompositeType (org.apache.flink.api.common.typeutils.CompositeType)12 Matcher (java.util.regex.Matcher)6 ArrayList (java.util.ArrayList)2 PublicEvolving (org.apache.flink.annotation.PublicEvolving)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)2 ExpressionKeys (org.apache.flink.api.common.operators.Keys.ExpressionKeys)2 Test (org.junit.Test)2 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1 GenericArrayType (java.lang.reflect.GenericArrayType)1 Method (java.lang.reflect.Method)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Aggregator (org.apache.flink.api.common.aggregators.Aggregator)1 ConvergenceCriterion (org.apache.flink.api.common.aggregators.ConvergenceCriterion)1