SemanticPropUtil { public static void getSemanticPropsDualFromString(DualInputSemanticProperties result, String[] forwardedFirst, String[] forwardedSecond, String[] nonForwardedFirst, String[] nonForwardedSecond, String[] readFieldsFirst, String[] readFieldsSecond, TypeInformation<?> inType1, TypeInformation<?> inType2, TypeInformation<?> outType) { getSemanticPropsDualFromString(result, forwardedFirst, forwardedSecond, nonForwardedFirst, nonForwardedSecond, readFieldsFirst, readFieldsSecond, inType1, inType2, outType, false); } private  SemanticPropUtil(); static SingleInputSemanticProperties createProjectionPropertiesSingle(int[] fields, CompositeType<?> inType); static DualInputSemanticProperties createProjectionPropertiesDual(
			int[] fields, boolean[] isFromFirst, TypeInformation<?> inType1, TypeInformation<?> inType2); static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props,
																		int numInputFields, int offset); static DualInputSemanticProperties addSourceFieldOffsets(DualInputSemanticProperties props,
																	int numInputFields1, int numInputFields2,
																	int offset1, int offset2); static SingleInputSemanticProperties getSemanticPropsSingle(
			Set<Annotation> set, TypeInformation<?> inType, TypeInformation<?> outType); static DualInputSemanticProperties getSemanticPropsDual(
			Set<Annotation> set, TypeInformation<?> inType1, TypeInformation<?> inType2, TypeInformation<?> outType); static void getSemanticPropsSingleFromString(SingleInputSemanticProperties result,
														String[] forwarded, String[] nonForwarded, String[] readSet,
														TypeInformation<?> inType, TypeInformation<?> outType); static void getSemanticPropsSingleFromString(SingleInputSemanticProperties result,
			String[] forwarded, String[] nonForwarded, String[] readSet,
			TypeInformation<?> inType, TypeInformation<?> outType,
			boolean skipIncompatibleTypes); static void getSemanticPropsDualFromString(DualInputSemanticProperties result,
			String[] forwardedFirst, String[] forwardedSecond,
			String[] nonForwardedFirst, String[] nonForwardedSecond, String[]
			readFieldsFirst, String[] readFieldsSecond,
			TypeInformation<?> inType1, TypeInformation<?> inType2, TypeInformation<?> outType); static void getSemanticPropsDualFromString(DualInputSemanticProperties result,
			String[] forwardedFirst, String[] forwardedSecond,
			String[] nonForwardedFirst, String[] nonForwardedSecond, String[]
			readFieldsFirst, String[] readFieldsSecond,
			TypeInformation<?> inType1, TypeInformation<?> inType2, TypeInformation<?> outType,
			boolean skipIncompatibleTypes);  }
@Test public void testForwardedDual() { String[] forwardedFieldsFirst = { "f1->f2; f2->f3" }; String[] forwardedFieldsSecond = { "f1->f1; f2->f0" }; DualInputSemanticProperties dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, forwardedFieldsFirst, forwardedFieldsSecond, null, null, null, null, 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); forwardedFieldsFirst[0] = "f1->f0;f3->f1"; forwardedFieldsSecond[0] = "*->f2.*"; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, forwardedFieldsFirst, forwardedFieldsSecond, null, null, null, null, fourIntTupleType, pojoType, pojoInTupleType); assertTrue(dsp.getForwardingTargetFields(0, 0).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 1).contains(0)); assertTrue(dsp.getForwardingTargetFields(0, 2).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 3).contains(1)); assertTrue(dsp.getForwardingTargetFields(1, 0).contains(2)); assertTrue(dsp.getForwardingTargetFields(1, 1).contains(3)); assertTrue(dsp.getForwardingTargetFields(1, 2).contains(4)); assertTrue(dsp.getForwardingTargetFields(1, 3).contains(5)); forwardedFieldsFirst[0] = "f1.f0.f2->int1; f2->pojo1.int3"; forwardedFieldsSecond[0] = "string1; int2->pojo1.int1; int1->pojo1.int2"; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, forwardedFieldsFirst, forwardedFieldsSecond, null, null, null, null, deepNestedTupleType, pojoType, nestedPojoType); assertTrue(dsp.getForwardingTargetFields(0, 0).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 2).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 3).contains(0)); assertTrue(dsp.getForwardingTargetFields(0, 4).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 5).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 6).contains(3)); assertTrue(dsp.getForwardingTargetFields(1, 0).contains(2)); assertTrue(dsp.getForwardingTargetFields(1, 1).contains(1)); assertTrue(dsp.getForwardingTargetFields(1, 2).size() == 0); assertTrue(dsp.getForwardingTargetFields(1, 3).contains(5)); String[] forwardedFieldsFirst2 = { "f1.f0.f2->int1", "f2->pojo1.int3" }; String[] forwardedFieldsSecond2 = { "string1", "int2->pojo1.int1", "int1->pojo1.int2" }; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, forwardedFieldsFirst2, forwardedFieldsSecond2, null, null, null, null, deepNestedTupleType, pojoType, nestedPojoType); assertTrue(dsp.getForwardingTargetFields(0, 0).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 1).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 2).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 3).contains(0)); assertTrue(dsp.getForwardingTargetFields(0, 4).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 5).size() == 0); assertTrue(dsp.getForwardingTargetFields(0, 6).contains(3)); assertTrue(dsp.getForwardingTargetFields(1, 0).contains(2)); assertTrue(dsp.getForwardingTargetFields(1, 1).contains(1)); assertTrue(dsp.getForwardingTargetFields(1, 2).size() == 0); assertTrue(dsp.getForwardingTargetFields(1, 3).contains(5)); }
@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)); }
@Test(expected = InvalidSemanticAnnotationException.class) public void testNonForwardedDualInvalidTypes1() { String[] nonNorwardedFieldsFirst = { "f1" }; DualInputSemanticProperties dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, nonNorwardedFieldsFirst, null, null, null, fiveIntTupleType, threeIntTupleType, threeIntTupleType); }
@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); }
@Test public void testReadFieldsDual() { String[] readFieldsFirst = {"f1;f2"}; String[] readFieldsSecond = {"f0"}; DualInputSemanticProperties dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, null, readFieldsFirst, readFieldsSecond, threeIntTupleType, threeIntTupleType, threeIntTupleType); assertTrue(dsp.getReadFields(0).size() == 2); assertTrue(dsp.getReadFields(0).contains(1)); assertTrue(dsp.getReadFields(0).contains(2)); assertTrue(dsp.getReadFields(1).size() == 1); assertTrue(dsp.getReadFields(1).contains(0)); readFieldsFirst[0] = "f0.*; f2"; readFieldsSecond[0] = "int1; string1"; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, null, readFieldsFirst, readFieldsSecond, nestedTupleType, pojoType, threeIntTupleType); assertTrue(dsp.getReadFields(0).size() == 4); assertTrue(dsp.getReadFields(0).contains(0)); assertTrue(dsp.getReadFields(0).contains(1)); assertTrue(dsp.getReadFields(0).contains(2)); assertTrue(dsp.getReadFields(0).contains(4)); assertTrue(dsp.getReadFields(1).size() == 2); assertTrue(dsp.getReadFields(1).contains(0)); assertTrue(dsp.getReadFields(1).contains(3)); readFieldsFirst[0] = "pojo1.int2; string1"; readFieldsSecond[0] = "f2.int2"; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, null, readFieldsFirst, readFieldsSecond, nestedPojoType, pojoInTupleType, threeIntTupleType); assertTrue(dsp.getReadFields(0).size() == 2); assertTrue(dsp.getReadFields(0).contains(2)); assertTrue(dsp.getReadFields(0).contains(5)); assertTrue(dsp.getReadFields(1).size() == 1); assertTrue(dsp.getReadFields(1).contains(3)); String[] readFields = {"f0", "f2", "f4"}; dsp = new DualInputSemanticProperties(); SemanticPropUtil.getSemanticPropsDualFromString(dsp, null, null, null, null, readFields, readFields, fiveIntTupleType, fiveIntTupleType, threeIntTupleType); assertTrue(dsp.getReadFields(0).size() == 3); assertTrue(dsp.getReadFields(0).contains(0)); assertTrue(dsp.getReadFields(0).contains(2)); assertTrue(dsp.getReadFields(0).contains(4)); assertTrue(dsp.getReadFields(1).size() == 3); assertTrue(dsp.getReadFields(1).contains(0)); assertTrue(dsp.getReadFields(1).contains(2)); assertTrue(dsp.getReadFields(1).contains(4)); }
@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)); }
@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); }
@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); }