Java Code Examples for org.apache.flink.optimizer.dataproperties.LocalProperties#forGrouping()

The following examples show how to use org.apache.flink.optimizer.dataproperties.LocalProperties#forGrouping() . 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: CrossStreamOuterFirstDescriptor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in1.getGroupedFields() == null || in1.getGroupedFields().size() == 0) &&
			in1.getUniqueFields() != null && in1.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in1.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in1.clearUniqueFieldSets();
	}
}
 
Example 2
Source File: CrossStreamOuterSecondDescriptor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in2.getGroupedFields() == null || in2.getGroupedFields().size() == 0) &&
			in2.getUniqueFields() != null && in2.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in2.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in2.clearUniqueFieldSets();
	}
}
 
Example 3
Source File: CrossStreamOuterFirstDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in1.getGroupedFields() == null || in1.getGroupedFields().size() == 0) &&
			in1.getUniqueFields() != null && in1.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in1.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in1.clearUniqueFieldSets();
	}
}
 
Example 4
Source File: CrossStreamOuterSecondDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in2.getGroupedFields() == null || in2.getGroupedFields().size() == 0) &&
			in2.getUniqueFields() != null && in2.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in2.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in2.clearUniqueFieldSets();
	}
}
 
Example 5
Source File: CrossStreamOuterFirstDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in1.getGroupedFields() == null || in1.getGroupedFields().size() == 0) &&
			in1.getUniqueFields() != null && in1.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in1.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in1.clearUniqueFieldSets();
	}
}
 
Example 6
Source File: CrossStreamOuterSecondDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public LocalProperties computeLocalProperties(LocalProperties in1, LocalProperties in2) {
	// uniqueness becomes grouping with streamed nested loops
	if ((in2.getGroupedFields() == null || in2.getGroupedFields().size() == 0) &&
			in2.getUniqueFields() != null && in2.getUniqueFields().size() > 0)
	{
		return LocalProperties.forGrouping(in2.getUniqueFields().iterator().next().toFieldList());
	} else {
		return in2.clearUniqueFieldSets();
	}
}
 
Example 7
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 8
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 9
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();
		}
	}