use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testUniqueFieldGroupsPreserved1.
@Test
public void testUniqueFieldGroupsPreserved1() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;2;3;4" }, 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);
Set<FieldSet> unique = result.getUniqueFieldCombination();
FieldSet expected1 = new FieldSet(0, 1, 2);
FieldSet expected2 = new FieldSet(3, 4);
Assert.assertTrue(unique.size() == 2);
Assert.assertTrue(unique.contains(expected1));
Assert.assertTrue(unique.contains(expected2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testRangePartitioningPreserved1.
@Test
public void testRangePartitioningPreserved1() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "1;2;5" }, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
o.appendOrdering(2, StringValue.class, Order.ASCENDING);
GlobalProperties gprops = new GlobalProperties();
gprops.setRangePartitioned(o);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.RANGE_PARTITIONED, result.getPartitioning());
FieldList pFields = result.getPartitioningFields();
assertEquals(3, pFields.size());
assertEquals(1, pFields.get(0).intValue());
assertEquals(5, pFields.get(1).intValue());
assertEquals(2, pFields.get(2).intValue());
Ordering pOrder = result.getPartitioningOrdering();
assertEquals(3, pOrder.getNumberOfFields());
assertEquals(1, pOrder.getFieldNumber(0).intValue());
assertEquals(5, pOrder.getFieldNumber(1).intValue());
assertEquals(2, pOrder.getFieldNumber(2).intValue());
assertEquals(Order.ASCENDING, pOrder.getOrder(0));
assertEquals(Order.DESCENDING, pOrder.getOrder(1));
assertEquals(Order.ASCENDING, pOrder.getOrder(2));
assertEquals(IntValue.class, pOrder.getType(0));
assertEquals(LongValue.class, pOrder.getType(1));
assertEquals(StringValue.class, pOrder.getType(2));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class RequestedLocalPropertiesFilteringTest method testGroupingPreserved1.
@Test
public void testGroupingPreserved1() {
SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[] { "0;2;3" }, null, null, tupleInfo, tupleInfo);
RequestedLocalProperties rlProp = new RequestedLocalProperties();
rlProp.setGroupedFields(new FieldSet(0, 2, 3));
RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0);
assertNotNull(filtered);
assertNotNull(filtered.getGroupedFields());
assertEquals(3, filtered.getGroupedFields().size());
assertTrue(filtered.getGroupedFields().contains(0));
assertTrue(filtered.getGroupedFields().contains(2));
assertTrue(filtered.getGroupedFields().contains(3));
assertNull(filtered.getOrdering());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class RequestedLocalPropertiesFilteringTest method testInvalidInputIndex.
@Test(expected = IndexOutOfBoundsException.class)
public void testInvalidInputIndex() {
SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[] { "1; 4" }, null, null, tupleInfo, tupleInfo);
RequestedLocalProperties rlProp = new RequestedLocalProperties();
rlProp.setGroupedFields(new FieldSet(1, 4));
rlProp.filterBySemanticProperties(sProps, 1);
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class RequestedLocalPropertiesFilteringTest method testOrderErased.
@Test
public void testOrderErased() {
SingleInputSemanticProperties sProps = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProps, new String[] { "1; 4" }, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(4, LongValue.class, Order.DESCENDING);
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
RequestedLocalProperties rlProp = new RequestedLocalProperties();
rlProp.setOrdering(o);
RequestedLocalProperties filtered = rlProp.filterBySemanticProperties(sProps, 0);
assertNull(filtered);
}
Aggregations