use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testCustomPartitioningPreserved1.
@Test
public void testCustomPartitioningPreserved1() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
GlobalProperties gprops = new GlobalProperties();
Partitioner<Tuple2<Long, Integer>> myP = new MockPartitioner();
gprops.setCustomPartitioned(new FieldList(0, 4), myP);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.CUSTOM_PARTITIONING, result.getPartitioning());
FieldList pFields = result.getPartitioningFields();
assertEquals(2, pFields.size());
assertTrue(pFields.contains(0));
assertTrue(pFields.contains(4));
assertEquals(myP, result.getCustomPartitioner());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testRangePartitioningPreserved2.
@Test
public void testRangePartitioningPreserved2() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "1->3; 2->0; 5->1" }, 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(3, pFields.get(0).intValue());
assertEquals(1, pFields.get(1).intValue());
assertEquals(0, pFields.get(2).intValue());
Ordering pOrder = result.getPartitioningOrdering();
assertEquals(3, pOrder.getNumberOfFields());
assertEquals(3, pOrder.getFieldNumber(0).intValue());
assertEquals(1, pOrder.getFieldNumber(1).intValue());
assertEquals(0, 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 GlobalPropertiesFilteringTest method testHashPartitioningPreserved1.
@Test
public void testHashPartitioningPreserved1() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0;1;4" }, null, null, tupleInfo, tupleInfo);
GlobalProperties gprops = new GlobalProperties();
gprops.setHashPartitioned(new FieldList(0, 1, 4));
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.HASH_PARTITIONED, result.getPartitioning());
FieldList pFields = result.getPartitioningFields();
assertEquals(3, pFields.size());
assertTrue(pFields.contains(0));
assertTrue(pFields.contains(1));
assertTrue(pFields.contains(4));
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class GlobalPropertiesFilteringTest method testCustomPartitioningPreserved2.
@Test
public void testCustomPartitioningPreserved2() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0->1; 1->2; 4->3" }, null, null, tupleInfo, tupleInfo);
GlobalProperties gprops = new GlobalProperties();
Partitioner<Tuple2<Long, Integer>> myP = new MockPartitioner();
gprops.setCustomPartitioned(new FieldList(0, 4), myP);
GlobalProperties result = gprops.filterBySemanticProperties(sprops, 0);
assertEquals(PartitioningProperty.CUSTOM_PARTITIONING, result.getPartitioning());
FieldList pFields = result.getPartitioningFields();
assertEquals(2, pFields.size());
assertTrue(pFields.contains(1));
assertTrue(pFields.contains(3));
assertEquals(myP, result.getCustomPartitioner());
}
use of org.apache.flink.api.common.operators.SingleInputSemanticProperties in project flink by apache.
the class LocalPropertiesFilteringTest method testSortingPreserved2.
@Test
public void testSortingPreserved2() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0->3;2->7;5->1" }, 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(3, gFields.size());
assertTrue(gFields.contains(3));
assertTrue(gFields.contains(7));
assertTrue(gFields.contains(1));
assertNotNull(order);
assertEquals(3, order.getNumberOfFields());
assertEquals(7, order.getFieldNumber(0).intValue());
assertEquals(3, order.getFieldNumber(1).intValue());
assertEquals(1, order.getFieldNumber(2).intValue());
assertEquals(Order.ASCENDING, order.getOrder(0));
assertEquals(Order.DESCENDING, order.getOrder(1));
assertEquals(Order.DESCENDING, order.getOrder(2));
assertEquals(IntValue.class, order.getType(0));
assertEquals(StringValue.class, order.getType(1));
assertEquals(LongValue.class, order.getType(2));
assertNull(filtered.getUniqueFields());
}
Aggregations