use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class LocalPropertiesFilteringTest method testGroupingPreserved1.
@Test
public void testGroupingPreserved1() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2;3" }, null, null, tupleInfo, tupleInfo);
LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 2, 3));
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
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());
assertNull(filtered.getUniqueFields());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class LocalPropertiesFilteringTest method testSortingPreserved3.
@Test
public void testSortingPreserved3() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2" }, null, null, tupleInfo, tupleInfo);
Ordering o = new Ordering();
o.appendOrdering(2, IntValue.class, Order.ASCENDING);
o.appendOrdering(0, StringValue.class, Order.DESCENDING);
o.appendOrdering(5, LongValue.class, Order.DESCENDING);
LocalProperties lProps = LocalProperties.forOrdering(o);
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
FieldList gFields = filtered.getGroupedFields();
Ordering order = filtered.getOrdering();
assertNotNull(gFields);
assertEquals(2, gFields.size());
assertTrue(gFields.contains(0));
assertTrue(gFields.contains(2));
assertNotNull(order);
assertEquals(2, order.getNumberOfFields());
assertEquals(2, order.getFieldNumber(0).intValue());
assertEquals(0, order.getFieldNumber(1).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(Order.DESCENDING, order.getOrder(1));
assertEquals(IntValue.class, order.getType(0));
assertEquals(StringValue.class, order.getType(1));
assertNull(filtered.getUniqueFields());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class LocalPropertiesFilteringTest method testGroupingPreserved2.
@Test
public void testGroupingPreserved2() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0->4;2->0;3->7" }, null, null, tupleInfo, tupleInfo);
LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 2, 3));
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
assertNotNull(filtered.getGroupedFields());
assertEquals(3, filtered.getGroupedFields().size());
assertTrue(filtered.getGroupedFields().contains(4));
assertTrue(filtered.getGroupedFields().contains(0));
assertTrue(filtered.getGroupedFields().contains(7));
assertNull(filtered.getOrdering());
assertNull(filtered.getUniqueFields());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class RequestedGlobalPropertiesFilteringTest method testRangePartitioningPreserved3.
@Test
public void testRangePartitioningPreserved3() {
SingleInputSemanticProperties sProp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[] { "7->3;1->1;2->6" }, null, null, tupleInfo, tupleInfo);
DataDistribution dd = new MockDistribution();
Ordering o = new Ordering();
o.appendOrdering(3, LongValue.class, Order.DESCENDING);
o.appendOrdering(1, IntValue.class, Order.ASCENDING);
o.appendOrdering(6, ByteValue.class, Order.DESCENDING);
RequestedGlobalProperties rgProps = new RequestedGlobalProperties();
rgProps.setRangePartitioned(o, dd);
RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0);
assertNotNull(filtered);
assertEquals(PartitioningProperty.RANGE_PARTITIONED, filtered.getPartitioning());
assertNotNull(filtered.getOrdering());
assertEquals(3, filtered.getOrdering().getNumberOfFields());
assertEquals(7, filtered.getOrdering().getFieldNumber(0).intValue());
assertEquals(1, filtered.getOrdering().getFieldNumber(1).intValue());
assertEquals(2, filtered.getOrdering().getFieldNumber(2).intValue());
assertEquals(LongValue.class, filtered.getOrdering().getType(0));
assertEquals(IntValue.class, filtered.getOrdering().getType(1));
assertEquals(ByteValue.class, filtered.getOrdering().getType(2));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(0));
assertEquals(Order.ASCENDING, filtered.getOrdering().getOrder(1));
assertEquals(Order.DESCENDING, filtered.getOrdering().getOrder(2));
assertNotNull(filtered.getDataDistribution());
assertEquals(dd, filtered.getDataDistribution());
assertNull(filtered.getPartitionedFields());
assertNull(filtered.getCustomPartitioner());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class RequestedGlobalPropertiesFilteringTest method testCustomPartitioningErased.
@Test
public void testCustomPartitioningErased() {
SingleInputSemanticProperties sProp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sProp, new String[] { "0;1;2" }, null, null, tupleInfo, tupleInfo);
RequestedGlobalProperties rgProps = new RequestedGlobalProperties();
rgProps.setCustomPartitioned(new FieldSet(0, 1, 2), new MockPartitioner());
RequestedGlobalProperties filtered = rgProps.filterBySemanticProperties(sProp, 0);
assertNull(filtered);
}
Aggregations