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

The following examples show how to use org.apache.flink.optimizer.util.Utils. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: RequestedLocalProperties.java    License: 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 Project: Flink-CEPplus   Source File: Channel.java    License: 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 Project: flink   Source File: RequestedLocalProperties.java    License: 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 Project: flink   Source File: Channel.java    License: 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 Project: flink   Source File: RequestedLocalProperties.java    License: 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 6
Source Project: flink   Source File: Channel.java    License: 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 7
Source Project: Flink-CEPplus   Source File: Channel.java    License: 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 Project: flink   Source File: Channel.java    License: 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 Project: flink   Source File: Channel.java    License: 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
@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 11
@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 12
@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 13
Source Project: Flink-CEPplus   Source File: GlobalProperties.java    License: 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 14
Source Project: flink   Source File: AbstractSortMergeJoinDescriptor.java    License: 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
@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 16
@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 17
Source Project: flink   Source File: GlobalProperties.java    License: 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 18
Source Project: flink   Source File: AbstractSortMergeJoinDescriptor.java    License: 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 19
@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 20
@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 21
Source Project: flink   Source File: GlobalProperties.java    License: 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);
}