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

The following examples show how to use org.apache.flink.api.common.operators.Ordering#getFieldPositions() . 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: DataSourceNode.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
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();

		// more than one split per source tasks possible.
		// 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();
		}
	}
 
Example 2
Source File: DataSourceNode.java    From flink with Apache License 2.0 4 votes vote down vote up
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();

		// more than one split per source tasks possible.
		// 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();
		}
	}
 
Example 3
Source File: DataSourceNode.java    From flink with Apache License 2.0 4 votes vote down vote up
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();

		// more than one split per source tasks possible.
		// 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();
		}
	}