use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedWithArrowOneString.
@Test
public void testForwardedWithArrowOneString() {
String[] forwardedFields = { "f0->f0;f1->f2" };
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, fiveIntTupleType);
assertTrue(sp.getForwardingTargetFields(0, 0).contains(0));
assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
forwardedFields[0] = "0->0;1->2";
sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, fiveIntTupleType);
assertTrue(sp.getForwardingTargetFields(0, 0).contains(0));
assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropertiesTranslationTest method testUnaryFunctionWildcardForwardedAnnotation.
@Test
public void testUnaryFunctionWildcardForwardedAnnotation() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple3<Long, String, Integer>> input = env.fromElements(new Tuple3<Long, String, Integer>(3l, "test", 42));
input.map(new WildcardForwardedMapper<Tuple3<Long, String, Integer>>()).output(new DiscardingOutputFormat<Tuple3<Long, String, Integer>>());
Plan plan = env.createProgramPlan();
GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput();
SingleInputSemanticProperties semantics = mapper.getSemanticProperties();
FieldSet fw1 = semantics.getForwardingTargetFields(0, 0);
FieldSet fw2 = semantics.getForwardingTargetFields(0, 1);
FieldSet fw3 = semantics.getForwardingTargetFields(0, 2);
assertNotNull(fw1);
assertNotNull(fw2);
assertNotNull(fw3);
assertTrue(fw1.contains(0));
assertTrue(fw2.contains(1));
assertTrue(fw3.contains(2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropertiesTranslationTest method testUnaryFunctionAllForwardedExceptAnnotation.
@Test
public void testUnaryFunctionAllForwardedExceptAnnotation() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple3<Long, Long, Long>> input = env.fromElements(new Tuple3<Long, Long, Long>(3l, 2l, 1l));
input.map(new AllForwardedExceptMapper<Tuple3<Long, Long, Long>>()).output(new DiscardingOutputFormat<Tuple3<Long, Long, Long>>());
Plan plan = env.createProgramPlan();
GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
MapOperatorBase<?, ?, ?> mapper = (MapOperatorBase<?, ?, ?>) sink.getInput();
SingleInputSemanticProperties semantics = mapper.getSemanticProperties();
FieldSet fw1 = semantics.getForwardingTargetFields(0, 0);
FieldSet fw2 = semantics.getForwardingTargetFields(0, 2);
assertNotNull(fw1);
assertNotNull(fw2);
assertTrue(fw1.contains(0));
assertTrue(fw2.contains(2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testUniqueFieldGroupsErased.
@Test
public void testUniqueFieldGroupsErased() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0; 3; 5; 6; 7" }, null, null, tupleInfo, tupleInfo);
FieldSet set1 = new FieldSet(0, 1, 2);
FieldSet set2 = new FieldSet(3, 4);
FieldSet set3 = new FieldSet(4, 5, 6, 7);
GlobalProperties gprops = new GlobalProperties();
gprops.addUniqueFieldCombination(set1);
gprops.addUniqueFieldCombination(set2);
gprops.addUniqueFieldCombination(set3);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
Assert.assertNull(result.getUniqueFieldCombination());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testAllErased2.
@Test
public void testAllErased2() {
SingleInputSemanticProperties semProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(semProps, new String[] { "2" }, null, null, tupleInfo, tupleInfo);
GlobalProperties gprops = new GlobalProperties();
gprops.setHashPartitioned(new FieldList(0, 1));
gprops.addUniqueFieldCombination(new FieldSet(3, 4));
gprops.addUniqueFieldCombination(new FieldSet(5, 6));
GlobalProperties result = gprops.filterBySemanticProperties(semProps, 0);
assertEquals(PartitioningProperty.RANDOM_PARTITIONED, result.getPartitioning());
assertNull(result.getPartitioningFields());
assertNull(result.getPartitioningOrdering());
assertNull(result.getUniqueFieldCombination());
}
Aggregations