use of org.apache.flink.api.common.operators.util.FieldList in project flink by apache.
the class GlobalPropertiesFilteringTest method testHashPartitioningPreserved2.
@Test
public void testHashPartitioningPreserved2() {
SingleInputSemanticProperties sprops = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sprops, new String[] { "0->1; 1->2; 4->3" }, 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(1));
assertTrue(pFields.contains(2));
assertTrue(pFields.contains(3));
}
use of org.apache.flink.api.common.operators.util.FieldList in project flink by apache.
the class GlobalPropertiesMatchingTest method testMatchingCustomPartitioning.
@Test
public void testMatchingCustomPartitioning() {
try {
final Partitioner<Tuple2<Long, Integer>> partitioner = new MockPartitioner();
RequestedGlobalProperties req = new RequestedGlobalProperties();
req.setCustomPartitioned(new FieldSet(6, 2), partitioner);
// match custom partitionings
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setCustomPartitioned(new FieldList(2, 6), partitioner);
assertTrue(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setCustomPartitioned(new FieldList(6, 2), partitioner);
assertTrue(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setCustomPartitioned(new FieldList(6, 2), new MockPartitioner());
assertFalse(req.isMetBy(gp3));
}
// cannot match other types of partitionings
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setAnyPartitioning(new FieldList(6, 2));
assertFalse(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setHashPartitioned(new FieldList(6, 2));
assertFalse(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setRangePartitioned(new Ordering(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
assertFalse(req.isMetBy(gp3));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.operators.util.FieldList in project flink by apache.
the class GlobalPropertiesMatchingTest method testMatchingAnyPartitioning.
@Test
public void testMatchingAnyPartitioning() {
try {
RequestedGlobalProperties req = new RequestedGlobalProperties();
req.setAnyPartitioning(new FieldSet(6, 2));
// match any partitioning
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setAnyPartitioning(new FieldList(2, 6));
assertTrue(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setAnyPartitioning(new FieldList(6, 2));
assertTrue(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setAnyPartitioning(new FieldList(6, 2, 4));
assertFalse(req.isMetBy(gp3));
GlobalProperties gp4 = new GlobalProperties();
gp4.setAnyPartitioning(new FieldList(6, 1));
assertFalse(req.isMetBy(gp4));
GlobalProperties gp5 = new GlobalProperties();
gp5.setAnyPartitioning(new FieldList(2));
assertTrue(req.isMetBy(gp5));
}
// match hash partitioning
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setHashPartitioned(new FieldList(2, 6));
assertTrue(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setHashPartitioned(new FieldList(6, 2));
assertTrue(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setHashPartitioned(new FieldList(6, 1));
assertFalse(req.isMetBy(gp3));
}
// match range partitioning
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setRangePartitioned(new Ordering(2, null, Order.DESCENDING).appendOrdering(6, null, Order.ASCENDING));
assertTrue(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(2, null, Order.ASCENDING));
assertTrue(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setRangePartitioned(new Ordering(6, null, Order.DESCENDING).appendOrdering(1, null, Order.ASCENDING));
assertFalse(req.isMetBy(gp3));
GlobalProperties gp4 = new GlobalProperties();
gp4.setRangePartitioned(new Ordering(6, null, Order.DESCENDING));
assertTrue(req.isMetBy(gp4));
}
// match custom partitioning
{
GlobalProperties gp1 = new GlobalProperties();
gp1.setCustomPartitioned(new FieldList(2, 6), new MockPartitioner());
assertTrue(req.isMetBy(gp1));
GlobalProperties gp2 = new GlobalProperties();
gp2.setCustomPartitioned(new FieldList(6, 2), new MockPartitioner());
assertTrue(req.isMetBy(gp2));
GlobalProperties gp3 = new GlobalProperties();
gp3.setCustomPartitioned(new FieldList(6, 1), new MockPartitioner());
assertFalse(req.isMetBy(gp3));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.operators.util.FieldList in project flink by apache.
the class LocalPropertiesFilteringTest method testSortingPreserved1.
@Test
public void testSortingPreserved1() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0;2;5" }, 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(0));
assertTrue(gFields.contains(2));
assertTrue(gFields.contains(5));
assertNotNull(order);
assertEquals(3, order.getNumberOfFields());
assertEquals(2, order.getFieldNumber(0).intValue());
assertEquals(0, order.getFieldNumber(1).intValue());
assertEquals(5, 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());
}
use of org.apache.flink.api.common.operators.util.FieldList in project flink by apache.
the class LocalPropertiesFilteringTest method testGroupingErased.
@Test
public void testGroupingErased() {
SingleInputSemanticProperties sp = new SingleInputSemanticProperties();
SemanticPropUtil.getSemanticPropsSingleFromString(sp, new String[] { "0->4;2->0" }, null, null, tupleInfo, tupleInfo);
LocalProperties lProps = LocalProperties.forGrouping(new FieldList(0, 2, 3));
LocalProperties filtered = lProps.filterBySemanticProperties(sp, 0);
assertNull(filtered.getGroupedFields());
assertNull(filtered.getOrdering());
assertNull(filtered.getUniqueFields());
}
Aggregations