Search in sources :

Example 36 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.

the class SemanticPropUtilTest method testNonForwardedInvalidTypes4.

@Test(expected = InvalidSemanticAnnotationException.class)
public void testNonForwardedInvalidTypes4() {
    String[] nonForwardedFields = { "f1; f2" };
    SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sp, null, nonForwardedFields, null, fiveIntTupleType, threeIntTupleType);
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) Test(org.junit.Test)

Example 37 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.

the class GlobalPropertiesFilteringTest method testInvalidInputIndex.

@Test(expected = IndexOutOfBoundsException.class)
public void testInvalidInputIndex() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setHashPartitioned(new FieldList(0, 1));
    gprops.filterBySemanticProperties(sprops, 1);
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 38 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.

the class GlobalPropertiesFilteringTest method testAnyPartitioningPreserved1.

@Test
public void testAnyPartitioningPreserved1() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setAnyPartitioning(new FieldList(0, 1, 4));
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.ANY_PARTITIONING, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(3, pFields.size());
    assertTrue(pFields.contains(0));
    assertTrue(pFields.contains(1));
    assertTrue(pFields.contains(4));
}
Also used : SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 39 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.

the class GlobalPropertiesFilteringTest method testCustomPartitioningPreserved1.

@Test
public void testCustomPartitioningPreserved1() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
    GlobalProperties gprops = new GlobalProperties();
    Partitioner<Tuple2<Long, Integer>> myP = new MockPartitioner();
    gprops.setCustomPartitioned(new FieldList(0, 4), myP);
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.CUSTOM_PARTITIONING, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(2, pFields.size());
    assertTrue(pFields.contains(0));
    assertTrue(pFields.contains(4));
    assertEquals(myP, result.getCustomPartitioner());
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Example 40 with SingleInputSemanticProperties

use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.

the class GlobalPropertiesFilteringTest method testRangePartitioningPreserved2.

@Test
public void testRangePartitioningPreserved2() {
    SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
    SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "1->3; 2->0; 5->1" }, null, null, tupleInfo, tupleInfo);
    Ordering o = new Ordering();
    o.appendOrdering(1, IntValue.class, Order.ASCENDING);
    o.appendOrdering(5, LongValue.class, Order.DESCENDING);
    o.appendOrdering(2, StringValue.class, Order.ASCENDING);
    GlobalProperties gprops = new GlobalProperties();
    gprops.setRangePartitioned(o);
    GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
    assertEquals(PartitioningProperty.RANGE_PARTITIONED, result.getPartitioning());
    FieldList pFields = result.getPartitioningFields();
    assertEquals(3, pFields.size());
    assertEquals(3, pFields.get(0).intValue());
    assertEquals(1, pFields.get(1).intValue());
    assertEquals(0, pFields.get(2).intValue());
    Ordering pOrder = result.getPartitioningOrdering();
    assertEquals(3, pOrder.getNumberOfFields());
    assertEquals(3, pOrder.getFieldNumber(0).intValue());
    assertEquals(1, pOrder.getFieldNumber(1).intValue());
    assertEquals(0, pOrder.getFieldNumber(2).intValue());
    assertEquals(Order.ASCENDING, pOrder.getOrder(0));
    assertEquals(Order.DESCENDING, pOrder.getOrder(1));
    assertEquals(Order.ASCENDING, pOrder.getOrder(2));
    assertEquals(IntValue.class, pOrder.getType(0));
    assertEquals(LongValue.class, pOrder.getType(1));
    assertEquals(StringValue.class, pOrder.getType(2));
}
Also used : Ordering(org.apache.flink.api.common.operators.Ordering) SingleInputSemanticProperties(org.apache.flink.api.common.operators.SingleInputSemanticProperties) FieldList(org.apache.flink.api.common.operators.util.FieldList) Test(org.junit.Test)

Aggregations

SingleInputSemanticProperties (org.apache.flink.api.common.operators.SingleInputSemanticProperties)149 Test (org.junit.Test)131 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)57 FieldList (org.apache.flink.api.common.operators.util.FieldList)26 Ordering (org.apache.flink.api.common.operators.Ordering)15 Plan (org.apache.flink.api.common.Plan)14 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)14 MapOperatorBase (org.apache.flink.api.common.operators.base.MapOperatorBase)12 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)12 DualInputSemanticProperties (org.apache.flink.api.common.operators.DualInputSemanticProperties)5 SemanticProperties (org.apache.flink.api.common.operators.SemanticProperties)5 Internal (org.apache.flink.annotation.Internal)4 SelectorFunctionKeys (org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys)4 InvalidSemanticAnnotationException (org.apache.flink.api.common.operators.SemanticProperties.InvalidSemanticAnnotationException)4 Matcher (java.util.regex.Matcher)3 UnaryOperatorInformation (org.apache.flink.api.common.operators.UnaryOperatorInformation)3 FlatFieldDescriptor (org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor)3 InvalidFieldReferenceException (org.apache.flink.api.common.typeutils.CompositeType.InvalidFieldReferenceException)3 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)3 Annotation (java.lang.annotation.Annotation)2