use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedInvalidExpression.
@Test(expected = InvalidSemanticAnnotationException.class)
public void testForwardedInvalidExpression() {
String[] forwardedFields = { "f0" };
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, intType, threeIntTupleType);
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedBasicType.
@Test
public void testForwardedBasicType() {
String[] forwardedFields = { "f1->*" };
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, intType);
assertTrue(sp.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(sp.getForwardingTargetFields(0, 1).contains(0));
assertTrue(sp.getForwardingTargetFields(0, 2).size() == 0);
forwardedFields[0] = "*->f2";
sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, intType, threeIntTupleType);
assertTrue(sp.getForwardingTargetFields(0, 0).contains(2));
forwardedFields[0] = "*->*";
sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, intType, intType);
assertTrue(sp.getForwardingTargetFields(0, 0).contains(0));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testForwardedWithArrowIndividualStrings.
@Test
public void testForwardedWithArrowIndividualStrings() {
String[] forwardedFields = { "f0->f1", "f1->f2" };
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, forwardedFields, null, null, threeIntTupleType, fiveIntTupleType);
assertTrue(sp.getForwardingTargetFields(0, 0).contains(1));
assertTrue(sp.getForwardingTargetFields(0, 1).contains(2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testNonForwardedInvalidNesting.
@Test(expected = InvalidSemanticAnnotationException.class)
public void testNonForwardedInvalidNesting() {
String[] nonForwardedFields = { "f0.f4" };
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, null, nonForwardedFields, null, nestedTupleType, nestedTupleType);
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class SemanticPropUtilTest method testAddSourceFieldOffset.
// --------------------------------------------------------------------------------------------
// Offset
// --------------------------------------------------------------------------------------------
@Test
public void testAddSourceFieldOffset() {
SingleInputSemanticProperties semProps = new SingleInputSemanticProperties();
semProps.addForwardedField(0, 1);
semProps.addForwardedField(0, 4);
semProps.addForwardedField(2, 0);
semProps.addForwardedField(4, 3);
semProps.addReadFields(new FieldSet(0, 3));
SemanticProperties offsetProps = SemanticPropUtil.addSourceFieldOffset(semProps, 5, 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 0).size() == 2);
assertTrue(offsetProps.getForwardingTargetFields(0, 0).contains(1));
assertTrue(offsetProps.getForwardingTargetFields(0, 0).contains(4));
assertTrue(offsetProps.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 2).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 2).contains(0));
assertTrue(offsetProps.getForwardingTargetFields(0, 3).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 4).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 4).contains(3));
assertTrue(offsetProps.getReadFields(0).size() == 2);
assertTrue(offsetProps.getReadFields(0).contains(0));
assertTrue(offsetProps.getReadFields(0).contains(3));
offsetProps = SemanticPropUtil.addSourceFieldOffset(semProps, 5, 3);
assertTrue(offsetProps.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 2).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 3).size() == 2);
assertTrue(offsetProps.getForwardingTargetFields(0, 3).contains(1));
assertTrue(offsetProps.getForwardingTargetFields(0, 3).contains(4));
assertTrue(offsetProps.getForwardingTargetFields(0, 4).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 5).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 5).contains(0));
assertTrue(offsetProps.getForwardingTargetFields(0, 6).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 7).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 7).contains(3));
assertTrue(offsetProps.getReadFields(0).size() == 2);
assertTrue(offsetProps.getReadFields(0).contains(3));
assertTrue(offsetProps.getReadFields(0).contains(6));
semProps = new SingleInputSemanticProperties();
SemanticPropUtil.addSourceFieldOffset(semProps, 1, 0);
semProps = new SingleInputSemanticProperties();
semProps.addForwardedField(0, 0);
semProps.addForwardedField(1, 2);
semProps.addForwardedField(2, 4);
offsetProps = SemanticPropUtil.addSourceFieldOffset(semProps, 3, 2);
assertTrue(offsetProps.getForwardingTargetFields(0, 0).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 1).size() == 0);
assertTrue(offsetProps.getForwardingTargetFields(0, 2).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 2).contains(0));
assertTrue(offsetProps.getForwardingTargetFields(0, 3).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 3).contains(2));
assertTrue(offsetProps.getForwardingTargetFields(0, 4).size() == 1);
assertTrue(offsetProps.getForwardingTargetFields(0, 4).contains(4));
}
Aggregations