use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testNonForwardedDual.
@Test
public void testNonForwardedDual() {
String[] nonNorwardedFieldsFirst = { "f1;f2" };
String[] nonNorwardedFieldsSecond = { "f0" };
DualInputSemanticProperties dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, nonNorwardedFieldsFirst, nonNorwardedFieldsSecond, null, null, threeIntTupleType, threeIntTupleType, threeIntTupleType);
assertTrue(dsp.getForwardingTargetFields(0, 0).contains(0));
assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 2).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 0).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 1).contains(1));
assertTrue(dsp.getForwardingTargetFields(1, 2).contains(2));
nonNorwardedFieldsFirst[0] = "f1";
nonNorwardedFieldsSecond[0] = "";
dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, nonNorwardedFieldsFirst, null, null, null, threeIntTupleType, fiveIntTupleType, threeIntTupleType);
assertTrue(dsp.getForwardingTargetFields(0, 0).contains(0));
assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 2).contains(2));
assertTrue(dsp.getForwardingTargetFields(1, 0).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 2).size() == 0);
nonNorwardedFieldsFirst[0] = "";
nonNorwardedFieldsSecond[0] = "f2;f0";
dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, nonNorwardedFieldsSecond, null, null, fiveIntTupleType, threeIntTupleType, threeIntTupleType);
assertTrue(dsp.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 2).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 0).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 1).contains(1));
assertTrue(dsp.getForwardingTargetFields(1, 2).size() == 0);
String[] nonForwardedFields = { "f1", "f3" };
dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, nonForwardedFields, null, null, null, fiveIntTupleType, threeIntTupleType, fiveIntTupleType);
assertTrue(dsp.getForwardingTargetFields(0, 0).contains(0));
assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 2).contains(2));
assertTrue(dsp.getForwardingTargetFields(0, 3).size() == 0);
assertTrue(dsp.getForwardingTargetFields(0, 4).contains(4));
dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, nonForwardedFields, null, null, threeIntTupleType, fiveIntTupleType, fiveIntTupleType);
assertTrue(dsp.getForwardingTargetFields(1, 0).contains(0));
assertTrue(dsp.getForwardingTargetFields(1, 1).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 2).contains(2));
assertTrue(dsp.getForwardingTargetFields(1, 3).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 4).contains(4));
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedReadDual.
@Test
public void testForwardedReadDual() {
String[] forwardedFieldsFirst = { "f1->f2; f2->f3" };
String[] forwardedFieldsSecond = { "f1->f1; f2->f0" };
String[] readFieldsFirst = { "0;2" };
String[] readFieldsSecond = { "1" };
DualInputSemanticProperties dsp = new DualInputSemanticProperties();
SemanticPropUtil.getSemanticPropsDualFromString(dsp, forwardedFieldsFirst, forwardedFieldsSecond, null, null, readFieldsFirst, readFieldsSecond, fourIntTupleType, fourIntTupleType, fourIntTupleType);
assertTrue(dsp.getForwardingTargetFields(0, 1).contains(2));
assertTrue(dsp.getForwardingTargetFields(0, 2).contains(3));
assertTrue(dsp.getForwardingTargetFields(1, 1).contains(1));
assertTrue(dsp.getForwardingTargetFields(1, 2).contains(0));
assertTrue(dsp.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(dsp.getForwardingTargetFields(1, 3).size() == 0);
assertTrue(dsp.getReadFields(0).size() == 2);
assertTrue(dsp.getReadFields(0).contains(0));
assertTrue(dsp.getReadFields(0).contains(2));
assertTrue(dsp.getReadFields(1).size() == 1);
assertTrue(dsp.getReadFields(1).contains(1));
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testAddSourceFieldOffsets.
@Test
public void testAddSourceFieldOffsets() {
DualInputSemanticProperties semProps = new DualInputSemanticProperties();
semProps.addForwardedField(0, 0, 1);
semProps.addForwardedField(0, 3, 3);
semProps.addForwardedField(1, 1, 2);
semProps.addForwardedField(1, 1, 4);
semProps.addReadFields(0, new FieldSet(1, 2));
semProps.addReadFields(1, new FieldSet(0, 3, 4));
DualInputSemanticProperties offsetProps = SemanticPropUtil.addSourceFieldOffsets(semProps, 4, 3, 1, 2);
assertTrue(offsetProps.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 1).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 1).contains(1));
assertTrue(offsetProps.getForwardingTargetFields(0, 2).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 3).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 4).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 4).contains(3));
assertTrue(offsetProps.getForwardingTargetFields(1, 0).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(1, 1).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(1, 2).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(1, 3).size() == 2);
assertTrue(offsetProps.getForwardingTargetFields(1, 3).contains(2));
assertTrue(offsetProps.getForwardingTargetFields(1, 3).contains(4));
assertTrue(offsetProps.getReadFields(0).size() == 2);
assertTrue(offsetProps.getReadFields(0).contains(2));
assertTrue(offsetProps.getReadFields(0).contains(3));
assertTrue(offsetProps.getReadFields(1).size() == 3);
assertTrue(offsetProps.getReadFields(1).contains(2));
assertTrue(offsetProps.getReadFields(1).contains(5));
assertTrue(offsetProps.getReadFields(1).contains(6));
semProps = new DualInputSemanticProperties();
SemanticPropUtil.addSourceFieldOffsets(semProps, 4, 3, 2, 2);
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedNonForwardedFirstCheck.
@Test(expected = InvalidSemanticAnnotationException.class)
public void testForwardedNonForwardedFirstCheck() {
String[] forwarded = { "1" };
String[] nonForwarded = { "1" };
SemanticPropUtil.getSemanticPropsDualFromString(new DualInputSemanticProperties(), forwarded, null, nonForwarded, null, null, null, threeIntTupleType, threeIntTupleType, threeIntTupleType);
}
use of org.apache.flink.api.common.operators.DualInputSemanticProperties in project flink by apache.
the class SemanticPropertiesTranslationTest method testBinaryForwardedAnnotation.
@Test
public void testBinaryForwardedAnnotation() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") DataSet<Tuple2<Long, String>> input1 = env.fromElements(new Tuple2<Long, String>(3l, "test"));
@SuppressWarnings("unchecked") DataSet<Tuple2<Long, Double>> input2 = env.fromElements(new Tuple2<Long, Double>(3l, 3.1415));
input1.join(input2).where(0).equalTo(0).with(new ForwardedBothAnnotationJoin<Long, String, Long, Double>()).output(new DiscardingOutputFormat<Tuple2<String, Double>>());
Plan plan = env.createProgramPlan();
GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
InnerJoinOperatorBase<?, ?, ?, ?> join = (InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput();
DualInputSemanticProperties semantics = join.getSemanticProperties();
assertNotNull(semantics.getForwardingTargetFields(0, 0));
assertNotNull(semantics.getForwardingTargetFields(1, 0));
assertEquals(1, semantics.getForwardingTargetFields(0, 1).size());
assertEquals(1, semantics.getForwardingTargetFields(1, 1).size());
assertTrue(semantics.getForwardingTargetFields(0, 1).contains(0));
assertTrue(semantics.getForwardingTargetFields(1, 1).contains(1));
assertEquals(0, semantics.getForwardingTargetFields(0, 0).size());
assertEquals(0, semantics.getForwardingTargetFields(1, 0).size());
}
Aggregations