use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testNonForwardedDualInvalidTypes2.
@Test(expected = InvalidSemanticAnnotationException.class)
public void testNonForwardedDualInvalidTypes2() {
String[] nonNorwardedFieldsSecond = { "f1" };
DualInputSemanticProperties dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, nonNorwardedFieldsSecond, null, null, threeIntTupleType, pojoInTupleType, threeIntTupleType);
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedNonForwardedSecondCheck.
@Test(expected = InvalidSemanticAnnotationException.class)
public void testForwardedNonForwardedSecondCheck() {
String[] forwarded = { "1" };
String[] nonForwarded = { "1" };
SemanticPropUtil.getSemanticPropsDualFromString(new DualInputSemanticProperties(), null, forwarded, null, nonForwarded, null, null, threeIntTupleType, threeIntTupleType, threeIntTupleType);
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class CoGroupNode method getSemanticPropertiesForLocalPropertyFiltering.
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
// Local properties for CoGroup may only be preserved on key fields.
DualInputSemanticProperties origProps = ((DualInputOperator<?, ?, ?, ?>) getOperator()).getSemanticProperties();
DualInputSemanticProperties filteredProps = new DualInputSemanticProperties();
FieldSet readSet1 = origProps.getReadFields(0);
FieldSet readSet2 = origProps.getReadFields(1);
if (readSet1 != null) {
filteredProps.addReadFields(0, readSet1);
}
if (readSet2 != null) {
filteredProps.addReadFields(1, readSet2);
}
// preserve only key fields (first input)
for (int f : this.keys1) {
FieldSet targets = origProps.getForwardingTargetFields(0, f);
for (int t : targets) {
filteredProps.addForwardedField(0, f, t);
}
}
// preserve only key fields (second input)
for (int f : this.keys2) {
FieldSet targets = origProps.getForwardingTargetFields(1, f);
for (int t : targets) {
filteredProps.addForwardedField(1, f, t);
}
}
return filteredProps;
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class UdfAnalyzerTest method compareAnalyzerResultWithAnnotationsDualInputWithKeys.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void compareAnalyzerResultWithAnnotationsDualInputWithKeys(Class<?> baseClass, Class<?> clazz, String in1, String in2, String out, String[] keys1, String[] keys2) {
final TypeInformation<?> in1Type = TypeInfoParser.parse(in1);
final TypeInformation<?> in2Type = TypeInfoParser.parse(in2);
final TypeInformation<?> outType = TypeInfoParser.parse(out);
// expected
final Set<Annotation> annotations = FunctionAnnotation.readDualForwardAnnotations(clazz);
final DualInputSemanticProperties expected = SemanticPropUtil.getSemanticPropsDual(annotations, in1Type, in2Type, outType);
// actual
final UdfAnalyzer ua = new UdfAnalyzer(baseClass, clazz, "operator", in1Type, in2Type, outType, (keys1 == null) ? null : new Keys.ExpressionKeys(keys1, in1Type), (keys2 == null) ? null : new Keys.ExpressionKeys(keys2, in2Type), true);
ua.analyze();
final DualInputSemanticProperties actual = (DualInputSemanticProperties) ua.getSemanticProperties();
assertEquals(expected.toString(), actual.toString());
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropertiesTranslationTest method testBinaryForwardedInLine2.
@Test
public void testBinaryForwardedInLine2() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(3l, 4l));
@SuppressWarnings("unchecked") DataSet<Tuple2<Long, Long>> input2 = env.fromElements(new Tuple2<Long, Long>(3l, 2l));
input1.join(input2).where(0).equalTo(0).with(new ReadSetJoin<Long>()).withForwardedFieldsFirst("0->1; 1->2").withForwardedFieldsSecond("1->0").output(new DiscardingOutputFormat<Tuple3<Long, Long, Long>>());
Plan plan = env.createProgramPlan();
GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
InnerJoinOperatorBase<?, ?, ?, ?> join = (InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput();
DualInputSemanticProperties semantics = join.getSemanticProperties();
assertNotNull(semantics.getForwardingTargetFields(1, 0));
assertEquals(1, semantics.getForwardingTargetFields(0, 0).size());
assertEquals(1, semantics.getForwardingTargetFields(0, 1).size());
assertEquals(1, semantics.getForwardingTargetFields(1, 1).size());
assertTrue(semantics.getForwardingTargetFields(0, 0).contains(1));
assertTrue(semantics.getForwardingTargetFields(0, 1).contains(2));
assertTrue(semantics.getForwardingTargetFields(1, 1).contains(0));
assertNotNull(semantics.getReadFields(0));
assertNotNull(semantics.getReadFields(1));
assertEquals(1, semantics.getReadFields(0).size());
assertEquals(1, semantics.getReadFields(1).size());
assertTrue(semantics.getReadFields(0).contains(1));
assertTrue(semantics.getReadFields(1).contains(0));
assertEquals(0, semantics.getForwardingTargetFields(1, 0).size());
}
Aggregations