org.apache.flink.optimizer.util.Utils Java Examples

The following examples show how to use org.apache.flink.optimizer.util.Utils. 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: RequestedLocalProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Parametrizes the local strategy fields of a channel such that the channel produces the desired local properties.
 * 
 * @param channel The channel to parametrize.
 */
public void parameterizeChannel(Channel channel) {
	LocalProperties current = channel.getLocalProperties();
	
	if (isMetBy(current)) {
		// we are met, all is good
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
	else if (this.ordering != null) {
		channel.setLocalStrategy(LocalStrategy.SORT, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
	}
	else if (this.groupedFields != null) {
		boolean[] dirs = new boolean[this.groupedFields.size()];
		Arrays.fill(dirs, true);
		channel.setLocalStrategy(LocalStrategy.SORT, Utils.createOrderedFromSet(this.groupedFields), dirs);
	}
	else {
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
}
 
Example #2
Source File: Channel.java    From flink with Apache License 2.0 6 votes vote down vote up
public LocalProperties getLocalProperties() {
	if (this.localProps == null) {
		computeLocalPropertiesAfterShippingOnly();
		switch (this.localStrategy) {
			case NONE:
				break;
			case SORT:
			case COMBININGSORT:
				this.localProps = LocalProperties.forOrdering(Utils.createOrdering(this.localKeys, this.localSortOrder));
				break;
			default:
				throw new CompilerException("Unsupported local strategy for channel.");
		}
	}
	
	return this.localProps;
}
 
Example #3
Source File: RequestedLocalProperties.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Parametrizes the local strategy fields of a channel such that the channel produces the desired local properties.
 * 
 * @param channel The channel to parametrize.
 */
public void parameterizeChannel(Channel channel) {
	LocalProperties current = channel.getLocalProperties();
	
	if (isMetBy(current)) {
		// we are met, all is good
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
	else if (this.ordering != null) {
		channel.setLocalStrategy(LocalStrategy.SORT, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
	}
	else if (this.groupedFields != null) {
		boolean[] dirs = new boolean[this.groupedFields.size()];
		Arrays.fill(dirs, true);
		channel.setLocalStrategy(LocalStrategy.SORT, Utils.createOrderedFromSet(this.groupedFields), dirs);
	}
	else {
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
}
 
Example #4
Source File: Channel.java    From flink with Apache License 2.0 6 votes vote down vote up
public LocalProperties getLocalProperties() {
	if (this.localProps == null) {
		computeLocalPropertiesAfterShippingOnly();
		switch (this.localStrategy) {
			case NONE:
				break;
			case SORT:
			case COMBININGSORT:
				this.localProps = LocalProperties.forOrdering(Utils.createOrdering(this.localKeys, this.localSortOrder));
				break;
			default:
				throw new CompilerException("Unsupported local strategy for channel.");
		}
	}
	
	return this.localProps;
}
 
Example #5
Source File: Channel.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public LocalProperties getLocalProperties() {
	if (this.localProps == null) {
		computeLocalPropertiesAfterShippingOnly();
		switch (this.localStrategy) {
			case NONE:
				break;
			case SORT:
			case COMBININGSORT:
				this.localProps = LocalProperties.forOrdering(Utils.createOrdering(this.localKeys, this.localSortOrder));
				break;
			default:
				throw new CompilerException("Unsupported local strategy for channel.");
		}
	}
	
	return this.localProps;
}
 
Example #6
Source File: RequestedLocalProperties.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Parametrizes the local strategy fields of a channel such that the channel produces the desired local properties.
 * 
 * @param channel The channel to parametrize.
 */
public void parameterizeChannel(Channel channel) {
	LocalProperties current = channel.getLocalProperties();
	
	if (isMetBy(current)) {
		// we are met, all is good
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
	else if (this.ordering != null) {
		channel.setLocalStrategy(LocalStrategy.SORT, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
	}
	else if (this.groupedFields != null) {
		boolean[] dirs = new boolean[this.groupedFields.size()];
		Arrays.fill(dirs, true);
		channel.setLocalStrategy(LocalStrategy.SORT, Utils.createOrderedFromSet(this.groupedFields), dirs);
	}
	else {
		channel.setLocalStrategy(LocalStrategy.NONE);
	}
}
 
Example #7
Source File: Channel.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public GlobalProperties getGlobalProperties() {
	if (this.globalProps == null) {
		this.globalProps = this.source.getGlobalProperties().clone();
		switch (this.shipStrategy) {
			case BROADCAST:
				this.globalProps.clearUniqueFieldCombinations();
				this.globalProps.setFullyReplicated();
				break;
			case PARTITION_HASH:
				this.globalProps.setHashPartitioned(this.shipKeys);
				break;
			case PARTITION_RANGE:
				this.globalProps.setRangePartitioned(Utils.createOrdering(this.shipKeys, this.shipSortOrder), this.dataDistribution);
				break;
			case FORWARD:
				break;
			case PARTITION_RANDOM:
				this.globalProps.reset();
				break;
			case PARTITION_FORCED_REBALANCE:
				this.globalProps.setForcedRebalanced();
				break;
			case PARTITION_CUSTOM:
				this.globalProps.setCustomPartitioned(this.shipKeys, this.partitioner);
				break;
			case NONE:
				throw new CompilerException("Cannot produce GlobalProperties before ship strategy is set.");
		}
	}
	
	return this.globalProps;
}
 
Example #8
Source File: Channel.java    From flink with Apache License 2.0 5 votes vote down vote up
public GlobalProperties getGlobalProperties() {
	if (this.globalProps == null) {
		this.globalProps = this.source.getGlobalProperties().clone();
		switch (this.shipStrategy) {
			case BROADCAST:
				this.globalProps.clearUniqueFieldCombinations();
				this.globalProps.setFullyReplicated();
				break;
			case PARTITION_HASH:
				this.globalProps.setHashPartitioned(this.shipKeys);
				break;
			case PARTITION_RANGE:
				this.globalProps.setRangePartitioned(Utils.createOrdering(this.shipKeys, this.shipSortOrder), this.dataDistribution);
				break;
			case FORWARD:
				break;
			case PARTITION_RANDOM:
				this.globalProps.reset();
				break;
			case PARTITION_FORCED_REBALANCE:
				this.globalProps.setForcedRebalanced();
				break;
			case PARTITION_CUSTOM:
				this.globalProps.setCustomPartitioned(this.shipKeys, this.partitioner);
				break;
			case NONE:
				throw new CompilerException("Cannot produce GlobalProperties before ship strategy is set.");
		}
	}
	
	return this.globalProps;
}
 
Example #9
Source File: Channel.java    From flink with Apache License 2.0 5 votes vote down vote up
public GlobalProperties getGlobalProperties() {
	if (this.globalProps == null) {
		this.globalProps = this.source.getGlobalProperties().clone();
		switch (this.shipStrategy) {
			case BROADCAST:
				this.globalProps.clearUniqueFieldCombinations();
				this.globalProps.setFullyReplicated();
				break;
			case PARTITION_HASH:
				this.globalProps.setHashPartitioned(this.shipKeys);
				break;
			case PARTITION_RANGE:
				this.globalProps.setRangePartitioned(Utils.createOrdering(this.shipKeys, this.shipSortOrder), this.dataDistribution);
				break;
			case FORWARD:
				break;
			case PARTITION_RANDOM:
				this.globalProps.reset();
				break;
			case PARTITION_FORCED_REBALANCE:
				this.globalProps.setForcedRebalanced();
				break;
			case PARTITION_CUSTOM:
				this.globalProps.setCustomPartitioned(this.shipKeys, this.partitioner);
				break;
			case NONE:
				throw new CompilerException("Cannot produce GlobalProperties before ship strategy is set.");
		}
	}
	
	return this.globalProps;
}
 
Example #10
Source File: GlobalProperties.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public void parameterizeChannel(Channel channel, boolean globalDopChange,
								ExecutionMode exchangeMode, boolean breakPipeline) {

	ShipStrategyType shipType;
	FieldList partitionKeys;
	boolean[] sortDirection;
	Partitioner<?> partitioner;

	switch (this.partitioning) {
		case RANDOM_PARTITIONED:
			shipType = globalDopChange ? ShipStrategyType.PARTITION_RANDOM : ShipStrategyType.FORWARD;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case FULL_REPLICATION:
			shipType = ShipStrategyType.BROADCAST;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case ANY_PARTITIONING:
		case HASH_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_HASH;
			partitionKeys = Utils.createOrderedFromSet(this.partitioningFields);
			sortDirection = null;
			partitioner = null;
			break;

		case RANGE_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_RANGE;
			partitionKeys = this.ordering.getInvolvedIndexes();
			sortDirection = this.ordering.getFieldSortDirections();
			partitioner = null;
			break;

		case FORCED_REBALANCED:
			shipType = ShipStrategyType.PARTITION_RANDOM;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case CUSTOM_PARTITIONING:
			shipType = ShipStrategyType.PARTITION_CUSTOM;
			partitionKeys = this.partitioningFields;
			sortDirection = null;
			partitioner = this.customPartitioner;
			break;

		default:
			throw new CompilerException("Unsupported partitioning strategy");
	}

	channel.setDataDistribution(this.distribution);
	DataExchangeMode exMode = DataExchangeMode.select(exchangeMode, shipType, breakPipeline);
	channel.setShipStrategy(shipType, partitionKeys, sortDirection, partitioner, exMode);
}
 
Example #11
Source File: AbstractSortMergeJoinDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort1 = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties sort2 = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(sort1, sort2));
}
 
Example #12
Source File: CoGroupWithSolutionSetSecondDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties none = new RequestedLocalProperties();
	return Collections.singletonList(new LocalPropertiesPair(sort, none));
}
 
Example #13
Source File: CoGroupWithSolutionSetFirstDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties none = new RequestedLocalProperties();
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(none, sort));
}
 
Example #14
Source File: AbstractSortMergeJoinDescriptor.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort1 = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties sort2 = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(sort1, sort2));
}
 
Example #15
Source File: GlobalProperties.java    From flink with Apache License 2.0 4 votes vote down vote up
public void parameterizeChannel(Channel channel, boolean globalDopChange,
								ExecutionMode exchangeMode, boolean breakPipeline) {

	ShipStrategyType shipType;
	FieldList partitionKeys;
	boolean[] sortDirection;
	Partitioner<?> partitioner;

	switch (this.partitioning) {
		case RANDOM_PARTITIONED:
			shipType = globalDopChange ? ShipStrategyType.PARTITION_RANDOM : ShipStrategyType.FORWARD;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case FULL_REPLICATION:
			shipType = ShipStrategyType.BROADCAST;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case ANY_PARTITIONING:
		case HASH_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_HASH;
			partitionKeys = Utils.createOrderedFromSet(this.partitioningFields);
			sortDirection = null;
			partitioner = null;
			break;

		case RANGE_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_RANGE;
			partitionKeys = this.ordering.getInvolvedIndexes();
			sortDirection = this.ordering.getFieldSortDirections();
			partitioner = null;
			break;

		case FORCED_REBALANCED:
			shipType = ShipStrategyType.PARTITION_RANDOM;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case CUSTOM_PARTITIONING:
			shipType = ShipStrategyType.PARTITION_CUSTOM;
			partitionKeys = this.partitioningFields;
			sortDirection = null;
			partitioner = this.customPartitioner;
			break;

		default:
			throw new CompilerException("Unsupported partitioning strategy");
	}

	channel.setDataDistribution(this.distribution);
	DataExchangeMode exMode = DataExchangeMode.select(exchangeMode, shipType, breakPipeline);
	channel.setShipStrategy(shipType, partitionKeys, sortDirection, partitioner, exMode);
}
 
Example #16
Source File: AbstractSortMergeJoinDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort1 = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties sort2 = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(sort1, sort2));
}
 
Example #17
Source File: CoGroupWithSolutionSetSecondDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties none = new RequestedLocalProperties();
	return Collections.singletonList(new LocalPropertiesPair(sort, none));
}
 
Example #18
Source File: CoGroupWithSolutionSetFirstDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties none = new RequestedLocalProperties();
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(none, sort));
}
 
Example #19
Source File: CoGroupWithSolutionSetFirstDescriptor.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties none = new RequestedLocalProperties();
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys2));
	return Collections.singletonList(new LocalPropertiesPair(none, sort));
}
 
Example #20
Source File: GlobalProperties.java    From flink with Apache License 2.0 4 votes vote down vote up
public void parameterizeChannel(Channel channel, boolean globalDopChange,
								ExecutionMode exchangeMode, boolean breakPipeline) {

	ShipStrategyType shipType;
	FieldList partitionKeys;
	boolean[] sortDirection;
	Partitioner<?> partitioner;

	switch (this.partitioning) {
		case RANDOM_PARTITIONED:
			shipType = globalDopChange ? ShipStrategyType.PARTITION_RANDOM : ShipStrategyType.FORWARD;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case FULL_REPLICATION:
			shipType = ShipStrategyType.BROADCAST;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case ANY_PARTITIONING:
		case HASH_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_HASH;
			partitionKeys = Utils.createOrderedFromSet(this.partitioningFields);
			sortDirection = null;
			partitioner = null;
			break;

		case RANGE_PARTITIONED:
			shipType = ShipStrategyType.PARTITION_RANGE;
			partitionKeys = this.ordering.getInvolvedIndexes();
			sortDirection = this.ordering.getFieldSortDirections();
			partitioner = null;
			break;

		case FORCED_REBALANCED:
			shipType = ShipStrategyType.PARTITION_RANDOM;
			partitionKeys = null;
			sortDirection = null;
			partitioner = null;
			break;

		case CUSTOM_PARTITIONING:
			shipType = ShipStrategyType.PARTITION_CUSTOM;
			partitionKeys = this.partitioningFields;
			sortDirection = null;
			partitioner = this.customPartitioner;
			break;

		default:
			throw new CompilerException("Unsupported partitioning strategy");
	}

	channel.setDataDistribution(this.distribution);
	DataExchangeMode exMode = DataExchangeMode.select(exchangeMode, shipType, breakPipeline);
	channel.setShipStrategy(shipType, partitionKeys, sortDirection, partitioner, exMode);
}
 
Example #21
Source File: CoGroupWithSolutionSetSecondDescriptor.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected List<LocalPropertiesPair> createPossibleLocalProperties() {
	RequestedLocalProperties sort = new RequestedLocalProperties(Utils.createOrdering(this.keys1));
	RequestedLocalProperties none = new RequestedLocalProperties();
	return Collections.singletonList(new LocalPropertiesPair(sort, none));
}