Java Code Examples for org.apache.flink.api.common.operators.Ordering#getOrder()

The following examples show how to use org.apache.flink.api.common.operators.Ordering#getOrder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupReduceProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupReduceProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
	super(groupKeys);
	
	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	if (additionalOrderKeys != null) {
		this.ordering = new Ordering();
		for (Integer key : this.keyList) {
			this.ordering.appendOrdering(key, null, Order.ANY);
		}
	
		// and next the additional order fields
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}
	else {
		this.ordering = null;
	}
	
	this.customPartitioner = customPartitioner;
}
 
Example 2
Source File: CoGroupRawDescriptor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean areCoFulfilled(RequestedLocalProperties requested1, RequestedLocalProperties requested2,
		LocalProperties produced1, LocalProperties produced2) {
	int numRelevantFields = this.keys1.size();

	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null || prod1.getNumberOfFields() < numRelevantFields
			|| prod2.getNumberOfFields() < numRelevantFields) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 3
Source File: GroupCombineProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys) {
	super(groupKeys);

	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	
	this.ordering = new Ordering();
	for (Integer key : this.keyList) {
		this.ordering.appendOrdering(key, null, Order.ANY);
	}

	// and next the additional order fields
	if (additionalOrderKeys != null) {
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}

}
 
Example 4
Source File: GroupReduceProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupReduceProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
	super(groupKeys);
	
	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	if (additionalOrderKeys != null) {
		this.ordering = new Ordering();
		for (Integer key : this.keyList) {
			this.ordering.appendOrdering(key, null, Order.ANY);
		}
	
		// and next the additional order fields
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}
	else {
		this.ordering = null;
	}
	
	this.customPartitioner = customPartitioner;
}
 
Example 5
Source File: GroupReduceWithCombineProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupReduceWithCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
	super(groupKeys);
	
	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	if (additionalOrderKeys != null) {
		this.ordering = new Ordering();
		for (Integer key : this.keyList) {
			this.ordering.appendOrdering(key, null, Order.ANY);
		}
	
		// and next the additional order fields
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	} else {
		this.ordering = null;
	}
	
	this.customPartitioner = customPartitioner;
}
 
Example 6
Source File: OperatorDescriptorDual.java    From flink with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(LocalProperties produced1, LocalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 7
Source File: OperatorDescriptorDual.java    From flink with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(GlobalProperties produced1, GlobalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getPartitioningOrdering();
	Ordering prod2 = produced2.getPartitioningOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 8
Source File: CoGroupRawDescriptor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean areCoFulfilled(RequestedLocalProperties requested1, RequestedLocalProperties requested2,
		LocalProperties produced1, LocalProperties produced2) {
	int numRelevantFields = this.keys1.size();

	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null || prod1.getNumberOfFields() < numRelevantFields
			|| prod2.getNumberOfFields() < numRelevantFields) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 9
Source File: GroupCombineProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys) {
	super(groupKeys);

	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	
	this.ordering = new Ordering();
	for (Integer key : this.keyList) {
		this.ordering.appendOrdering(key, null, Order.ANY);
	}

	// and next the additional order fields
	if (additionalOrderKeys != null) {
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}

}
 
Example 10
Source File: OperatorDescriptorDual.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(GlobalProperties produced1, GlobalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getPartitioningOrdering();
	Ordering prod2 = produced2.getPartitioningOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 11
Source File: GroupReduceWithCombineProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
public GroupReduceWithCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
	super(groupKeys);
	
	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	if (additionalOrderKeys != null) {
		this.ordering = new Ordering();
		for (Integer key : this.keyList) {
			this.ordering.appendOrdering(key, null, Order.ANY);
		}
	
		// and next the additional order fields
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	} else {
		this.ordering = null;
	}
	
	this.customPartitioner = customPartitioner;
}
 
Example 12
Source File: OperatorDescriptorDual.java    From flink with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(LocalProperties produced1, LocalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 13
Source File: OperatorDescriptorDual.java    From flink with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(GlobalProperties produced1, GlobalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getPartitioningOrdering();
	Ordering prod2 = produced2.getPartitioningOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 14
Source File: CoGroupRawDescriptor.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean areCoFulfilled(RequestedLocalProperties requested1, RequestedLocalProperties requested2,
		LocalProperties produced1, LocalProperties produced2) {
	int numRelevantFields = this.keys1.size();

	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null || prod1.getNumberOfFields() < numRelevantFields
			|| prod2.getNumberOfFields() < numRelevantFields) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 15
Source File: GroupCombineProperties.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public GroupCombineProperties(FieldSet groupKeys, Ordering additionalOrderKeys) {
	super(groupKeys);

	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	
	this.ordering = new Ordering();
	for (Integer key : this.keyList) {
		this.ordering.appendOrdering(key, null, Order.ANY);
	}

	// and next the additional order fields
	if (additionalOrderKeys != null) {
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}

}
 
Example 16
Source File: GroupReduceProperties.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public GroupReduceProperties(FieldSet groupKeys, Ordering additionalOrderKeys, Partitioner<?> customPartitioner) {
	super(groupKeys);
	
	// if we have an additional ordering, construct the ordering to have primarily the grouping fields
	if (additionalOrderKeys != null) {
		this.ordering = new Ordering();
		for (Integer key : this.keyList) {
			this.ordering.appendOrdering(key, null, Order.ANY);
		}
	
		// and next the additional order fields
		for (int i = 0; i < additionalOrderKeys.getNumberOfFields(); i++) {
			Integer field = additionalOrderKeys.getFieldNumber(i);
			Order order = additionalOrderKeys.getOrder(i);
			this.ordering.appendOrdering(field, additionalOrderKeys.getType(i), order);
		}
	}
	else {
		this.ordering = null;
	}
	
	this.customPartitioner = customPartitioner;
}
 
Example 17
Source File: OperatorDescriptorDual.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
protected boolean checkSameOrdering(LocalProperties produced1, LocalProperties produced2, int numRelevantFields) {
	Ordering prod1 = produced1.getOrdering();
	Ordering prod2 = produced2.getOrdering();

	if (prod1 == null || prod2 == null) {
		throw new CompilerException("The given properties do not meet this operators requirements.");
	}

	// check that order of fields is equivalent
	if (!checkEquivalentFieldPositionsInKeyFields(
			prod1.getInvolvedIndexes(), prod2.getInvolvedIndexes(), numRelevantFields)) {
		return false;
	}

	// check that both inputs have the same directions of order
	for (int i = 0; i < numRelevantFields; i++) {
		if (prod1.getOrder(i) != prod2.getOrder(i)) {
			return false;
		}
	}
	return true;
}
 
Example 18
Source File: GlobalProperties.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean matchesOrderedPartitioning(Ordering o) {
	if (this.partitioning == PartitioningProperty.RANGE_PARTITIONED) {
		if (this.ordering.getNumberOfFields() > o.getNumberOfFields()) {
			return false;
		}
		
		for (int i = 0; i < this.ordering.getNumberOfFields(); i++) {
			if (!this.ordering.getFieldNumber(i).equals(o.getFieldNumber(i))) {
				return false;
			}
			
			// if this one request no order, everything is good
			final Order oo = o.getOrder(i);
			final Order to = this.ordering.getOrder(i);
			if (oo != Order.NONE) {
				if (oo == Order.ANY) {
					// if any order is requested, any not NONE order is good
					if (to == Order.NONE) {
						return false;
					}
				} else if (oo != to) {
					// the orders must be equal
					return false;
				}
			}
		}
		return true;
	} else {
		return false;
	}
}
 
Example 19
Source File: GlobalProperties.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public boolean matchesOrderedPartitioning(Ordering o) {
	if (this.partitioning == PartitioningProperty.RANGE_PARTITIONED) {
		if (this.ordering.getNumberOfFields() > o.getNumberOfFields()) {
			return false;
		}
		
		for (int i = 0; i < this.ordering.getNumberOfFields(); i++) {
			if (!this.ordering.getFieldNumber(i).equals(o.getFieldNumber(i))) {
				return false;
			}
			
			// if this one request no order, everything is good
			final Order oo = o.getOrder(i);
			final Order to = this.ordering.getOrder(i);
			if (oo != Order.NONE) {
				if (oo == Order.ANY) {
					// if any order is requested, any not NONE order is good
					if (to == Order.NONE) {
						return false;
					}
				} else if (oo != to) {
					// the orders must be equal
					return false;
				}
			}
		}
		return true;
	} else {
		return false;
	}
}
 
Example 20
Source File: GlobalProperties.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean matchesOrderedPartitioning(Ordering o) {
	if (this.partitioning == PartitioningProperty.RANGE_PARTITIONED) {
		if (this.ordering.getNumberOfFields() > o.getNumberOfFields()) {
			return false;
		}
		
		for (int i = 0; i < this.ordering.getNumberOfFields(); i++) {
			if (!this.ordering.getFieldNumber(i).equals(o.getFieldNumber(i))) {
				return false;
			}
			
			// if this one request no order, everything is good
			final Order oo = o.getOrder(i);
			final Order to = this.ordering.getOrder(i);
			if (oo != Order.NONE) {
				if (oo == Order.ANY) {
					// if any order is requested, any not NONE order is good
					if (to == Order.NONE) {
						return false;
					}
				} else if (oo != to) {
					// the orders must be equal
					return false;
				}
			}
		}
		return true;
	} else {
		return false;
	}
}