use of org.apache.flink.api.common.operators.Ordering 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);
}
use of org.apache.flink.api.common.operators.Ordering in project flink by apache.
the class CoGroupNode method initializeDataProperties.
private List<OperatorDescriptorDual> initializeDataProperties(Partitioner<?> customPartitioner) {
Ordering groupOrder1 = null;
Ordering groupOrder2 = null;
CoGroupOperatorBase<?, ?, ?, ?> cgc = getOperator();
groupOrder1 = cgc.getGroupOrderForInputOne();
groupOrder2 = cgc.getGroupOrderForInputTwo();
if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
groupOrder1 = null;
}
if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
groupOrder2 = null;
}
CoGroupDescriptor descr = new CoGroupDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2);
if (customPartitioner != null) {
descr.setCustomPartitioner(customPartitioner);
}
return Collections.<OperatorDescriptorDual>singletonList(descr);
}
use of org.apache.flink.api.common.operators.Ordering in project flink by apache.
the class CoGroupRawNode method initializeDataProperties.
private List<OperatorDescriptorDual> initializeDataProperties() {
Ordering groupOrder1 = null;
Ordering groupOrder2 = null;
CoGroupRawOperatorBase<?, ?, ?, ?> cgc = getOperator();
groupOrder1 = cgc.getGroupOrderForInputOne();
groupOrder2 = cgc.getGroupOrderForInputTwo();
if (groupOrder1 != null && groupOrder1.getNumberOfFields() == 0) {
groupOrder1 = null;
}
if (groupOrder2 != null && groupOrder2.getNumberOfFields() == 0) {
groupOrder2 = null;
}
return Collections.<OperatorDescriptorDual>singletonList(new CoGroupRawDescriptor(this.keys1, this.keys2, groupOrder1, groupOrder2));
}
use of org.apache.flink.api.common.operators.Ordering in project flink by apache.
the class DataSinkNode method computeInterestingPropertiesForInputs.
@Override
public void computeInterestingPropertiesForInputs(CostEstimator estimator) {
final InterestingProperties iProps = new InterestingProperties();
{
final RequestedGlobalProperties partitioningProps = new RequestedGlobalProperties();
iProps.addGlobalProperties(partitioningProps);
}
{
final Ordering localOrder = getOperator().getLocalOrder();
final RequestedLocalProperties orderProps = new RequestedLocalProperties();
if (localOrder != null) {
orderProps.setOrdering(localOrder);
}
iProps.addLocalProperties(orderProps);
}
this.input.setInterestingProperties(iProps);
}
use of org.apache.flink.api.common.operators.Ordering in project flink by apache.
the class DataSourceNode method setDataPropertiesFromSplitProperties.
private void setDataPropertiesFromSplitProperties(SplitDataProperties splitProps) {
// set global properties
int[] partitionKeys = splitProps.getSplitPartitionKeys();
Partitioner<?> partitioner = splitProps.getSplitPartitioner();
if (partitionKeys != null && partitioner != null) {
this.gprops.setCustomPartitioned(new FieldList(partitionKeys), partitioner);
} else if (partitionKeys != null) {
this.gprops.setAnyPartitioning(new FieldList(partitionKeys));
}
// set local properties
int[] groupingKeys = splitProps.getSplitGroupKeys();
Ordering ordering = splitProps.getSplitOrder();
// adapt split grouping and sorting
if (ordering != null) {
// sorting falls back to grouping because a source can read multiple,
// randomly assigned splits
groupingKeys = ordering.getFieldPositions();
}
if (groupingKeys != null && partitionKeys != null) {
// check if grouping is also valid across splits, i.e., whether grouping keys are
// valid superset of partition keys
boolean allFieldsIncluded = true;
for (int i : partitionKeys) {
boolean fieldIncluded = false;
for (int j : groupingKeys) {
if (i == j) {
fieldIncluded = true;
break;
}
}
if (!fieldIncluded) {
allFieldsIncluded = false;
break;
}
}
if (allFieldsIncluded) {
this.lprops = LocalProperties.forGrouping(new FieldList(groupingKeys));
} else {
this.lprops = new LocalProperties();
}
} else {
this.lprops = new LocalProperties();
}
}
Aggregations