Java Code Examples for org.apache.flink.optimizer.dataproperties.RequestedLocalProperties#parameterizeChannel()

The following examples show how to use org.apache.flink.optimizer.dataproperties.RequestedLocalProperties#parameterizeChannel() . 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: SingleInputNode.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps,
		List<PlanNode> target, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) {
		final Channel in = template.clone();
		ilp.parameterizeChannel(in);
		
		// instantiate a candidate, if the instantiated local properties meet one possible local property set
		outer:
		for (OperatorDescriptorSingle dps: getPossibleProperties()) {
			for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) {
				if (ilps.isMetBy(in.getLocalProperties())) {
					in.setRequiredLocalProps(ilps);
					instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp);
					break outer;
				}
			}
		}
	}
}
 
Example 2
Source File: SingleInputNode.java    From flink with Apache License 2.0 6 votes vote down vote up
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps,
		List<PlanNode> target, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) {
		final Channel in = template.clone();
		ilp.parameterizeChannel(in);
		
		// instantiate a candidate, if the instantiated local properties meet one possible local property set
		outer:
		for (OperatorDescriptorSingle dps: getPossibleProperties()) {
			for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) {
				if (ilps.isMetBy(in.getLocalProperties())) {
					in.setRequiredLocalProps(ilps);
					instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp);
					break outer;
				}
			}
		}
	}
}
 
Example 3
Source File: SingleInputNode.java    From flink with Apache License 2.0 6 votes vote down vote up
protected void addLocalCandidates(Channel template, List<Set<? extends NamedChannel>> broadcastPlanChannels, RequestedGlobalProperties rgps,
		List<PlanNode> target, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp : this.inConn.getInterestingProperties().getLocalProperties()) {
		final Channel in = template.clone();
		ilp.parameterizeChannel(in);
		
		// instantiate a candidate, if the instantiated local properties meet one possible local property set
		outer:
		for (OperatorDescriptorSingle dps: getPossibleProperties()) {
			for (RequestedLocalProperties ilps : dps.getPossibleLocalProperties()) {
				if (ilps.isMetBy(in.getLocalProperties())) {
					in.setRequiredLocalProps(ilps);
					instantiateCandidate(dps, in, broadcastPlanChannels, target, estimator, rgps, ilp);
					break outer;
				}
			}
		}
	}
}
 
Example 4
Source File: DataSinkNode.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public List<PlanNode> getAlternativePlans(CostEstimator estimator) {
	// check if we have a cached version
	if (this.cachedPlans != null) {
		return this.cachedPlans;
	}
	
	// calculate alternative sub-plans for predecessor
	List<? extends PlanNode> subPlans = getPredecessorNode().getAlternativePlans(estimator);
	List<PlanNode> outputPlans = new ArrayList<PlanNode>();
	
	final int parallelism = getParallelism();
	final int inDop = getPredecessorNode().getParallelism();

	final ExecutionMode executionMode = this.input.getDataExchangeMode();
	final boolean dopChange = parallelism != inDop;
	final boolean breakPipeline = this.input.isBreakingPipeline();

	InterestingProperties ips = this.input.getInterestingProperties();
	for (PlanNode p : subPlans) {
		for (RequestedGlobalProperties gp : ips.getGlobalProperties()) {
			for (RequestedLocalProperties lp : ips.getLocalProperties()) {
				Channel c = new Channel(p);
				gp.parameterizeChannel(c, dopChange, executionMode, breakPipeline);
				lp.parameterizeChannel(c);
				c.setRequiredLocalProps(lp);
				c.setRequiredGlobalProps(gp);
				
				// no need to check whether the created properties meet what we need in case
				// of ordering or global ordering, because the only interesting properties we have
				// are what we require
				outputPlans.add(new SinkPlanNode(this, "DataSink ("+this.getOperator().getName()+")" ,c));
			}
		}
	}
	
	// cost and prune the plans
	for (PlanNode node : outputPlans) {
		estimator.costOperator(node);
	}
	prunePlanAlternatives(outputPlans);

	this.cachedPlans = outputPlans;
	return outputPlans;
}
 
Example 5
Source File: TwoInputNode.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
protected void addLocalCandidates(Channel template1, Channel template2, List<Set<? extends NamedChannel>> broadcastPlanChannels, 
		RequestedGlobalProperties rgps1, RequestedGlobalProperties rgps2,
		List<PlanNode> target, LocalPropertiesPair[] validLocalCombinations, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp1 : this.input1.getInterestingProperties().getLocalProperties()) {
		final Channel in1 = template1.clone();
		ilp1.parameterizeChannel(in1);
		
		for (RequestedLocalProperties ilp2 : this.input2.getInterestingProperties().getLocalProperties()) {
			final Channel in2 = template2.clone();
			ilp2.parameterizeChannel(in2);
			
			for (OperatorDescriptorDual dps: getProperties()) {
				for (LocalPropertiesPair lpp : dps.getPossibleLocalProperties()) {
					if (lpp.getProperties1().isMetBy(in1.getLocalProperties()) &&
						lpp.getProperties2().isMetBy(in2.getLocalProperties()) )
					{
						// valid combination
						// for non trivial local properties, we need to check that they are co compatible
						// (such as when some sort order is requested, that both are the same sort order
						if (dps.areCoFulfilled(lpp.getProperties1(), lpp.getProperties2(), 
							in1.getLocalProperties(), in2.getLocalProperties()))
						{
							// copy, because setting required properties and instantiation may
							// change the channels and should not affect prior candidates
							Channel in1Copy = in1.clone();
							in1Copy.setRequiredLocalProps(lpp.getProperties1());
							
							Channel in2Copy = in2.clone();
							in2Copy.setRequiredLocalProps(lpp.getProperties2());
							
							// all right, co compatible
							instantiate(dps, in1Copy, in2Copy, broadcastPlanChannels, target, estimator, rgps1, rgps2, ilp1, ilp2);
							break;
						}
						// else cannot use this pair, fall through the loop and try the next one
					}
				}
			}
		}
	}
}
 
Example 6
Source File: DataSinkNode.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<PlanNode> getAlternativePlans(CostEstimator estimator) {
	// check if we have a cached version
	if (this.cachedPlans != null) {
		return this.cachedPlans;
	}
	
	// calculate alternative sub-plans for predecessor
	List<? extends PlanNode> subPlans = getPredecessorNode().getAlternativePlans(estimator);
	List<PlanNode> outputPlans = new ArrayList<PlanNode>();
	
	final int parallelism = getParallelism();
	final int inDop = getPredecessorNode().getParallelism();

	final ExecutionMode executionMode = this.input.getDataExchangeMode();
	final boolean dopChange = parallelism != inDop;
	final boolean breakPipeline = this.input.isBreakingPipeline();

	InterestingProperties ips = this.input.getInterestingProperties();
	for (PlanNode p : subPlans) {
		for (RequestedGlobalProperties gp : ips.getGlobalProperties()) {
			for (RequestedLocalProperties lp : ips.getLocalProperties()) {
				Channel c = new Channel(p);
				gp.parameterizeChannel(c, dopChange, executionMode, breakPipeline);
				lp.parameterizeChannel(c);
				c.setRequiredLocalProps(lp);
				c.setRequiredGlobalProps(gp);
				
				// no need to check whether the created properties meet what we need in case
				// of ordering or global ordering, because the only interesting properties we have
				// are what we require
				outputPlans.add(new SinkPlanNode(this, "DataSink ("+this.getOperator().getName()+")" ,c));
			}
		}
	}
	
	// cost and prune the plans
	for (PlanNode node : outputPlans) {
		estimator.costOperator(node);
	}
	prunePlanAlternatives(outputPlans);

	this.cachedPlans = outputPlans;
	return outputPlans;
}
 
Example 7
Source File: TwoInputNode.java    From flink with Apache License 2.0 4 votes vote down vote up
protected void addLocalCandidates(Channel template1, Channel template2, List<Set<? extends NamedChannel>> broadcastPlanChannels, 
		RequestedGlobalProperties rgps1, RequestedGlobalProperties rgps2,
		List<PlanNode> target, LocalPropertiesPair[] validLocalCombinations, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp1 : this.input1.getInterestingProperties().getLocalProperties()) {
		final Channel in1 = template1.clone();
		ilp1.parameterizeChannel(in1);
		
		for (RequestedLocalProperties ilp2 : this.input2.getInterestingProperties().getLocalProperties()) {
			final Channel in2 = template2.clone();
			ilp2.parameterizeChannel(in2);
			
			for (OperatorDescriptorDual dps: getProperties()) {
				for (LocalPropertiesPair lpp : dps.getPossibleLocalProperties()) {
					if (lpp.getProperties1().isMetBy(in1.getLocalProperties()) &&
						lpp.getProperties2().isMetBy(in2.getLocalProperties()) )
					{
						// valid combination
						// for non trivial local properties, we need to check that they are co compatible
						// (such as when some sort order is requested, that both are the same sort order
						if (dps.areCoFulfilled(lpp.getProperties1(), lpp.getProperties2(), 
							in1.getLocalProperties(), in2.getLocalProperties()))
						{
							// copy, because setting required properties and instantiation may
							// change the channels and should not affect prior candidates
							Channel in1Copy = in1.clone();
							in1Copy.setRequiredLocalProps(lpp.getProperties1());
							
							Channel in2Copy = in2.clone();
							in2Copy.setRequiredLocalProps(lpp.getProperties2());
							
							// all right, co compatible
							instantiate(dps, in1Copy, in2Copy, broadcastPlanChannels, target, estimator, rgps1, rgps2, ilp1, ilp2);
							break;
						}
						// else cannot use this pair, fall through the loop and try the next one
					}
				}
			}
		}
	}
}
 
Example 8
Source File: DataSinkNode.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<PlanNode> getAlternativePlans(CostEstimator estimator) {
	// check if we have a cached version
	if (this.cachedPlans != null) {
		return this.cachedPlans;
	}
	
	// calculate alternative sub-plans for predecessor
	List<? extends PlanNode> subPlans = getPredecessorNode().getAlternativePlans(estimator);
	List<PlanNode> outputPlans = new ArrayList<PlanNode>();
	
	final int parallelism = getParallelism();
	final int inDop = getPredecessorNode().getParallelism();

	final ExecutionMode executionMode = this.input.getDataExchangeMode();
	final boolean dopChange = parallelism != inDop;
	final boolean breakPipeline = this.input.isBreakingPipeline();

	InterestingProperties ips = this.input.getInterestingProperties();
	for (PlanNode p : subPlans) {
		for (RequestedGlobalProperties gp : ips.getGlobalProperties()) {
			for (RequestedLocalProperties lp : ips.getLocalProperties()) {
				Channel c = new Channel(p);
				gp.parameterizeChannel(c, dopChange, executionMode, breakPipeline);
				lp.parameterizeChannel(c);
				c.setRequiredLocalProps(lp);
				c.setRequiredGlobalProps(gp);
				
				// no need to check whether the created properties meet what we need in case
				// of ordering or global ordering, because the only interesting properties we have
				// are what we require
				outputPlans.add(new SinkPlanNode(this, "DataSink ("+this.getOperator().getName()+")" ,c));
			}
		}
	}
	
	// cost and prune the plans
	for (PlanNode node : outputPlans) {
		estimator.costOperator(node);
	}
	prunePlanAlternatives(outputPlans);

	this.cachedPlans = outputPlans;
	return outputPlans;
}
 
Example 9
Source File: TwoInputNode.java    From flink with Apache License 2.0 4 votes vote down vote up
protected void addLocalCandidates(Channel template1, Channel template2, List<Set<? extends NamedChannel>> broadcastPlanChannels, 
		RequestedGlobalProperties rgps1, RequestedGlobalProperties rgps2,
		List<PlanNode> target, LocalPropertiesPair[] validLocalCombinations, CostEstimator estimator)
{
	for (RequestedLocalProperties ilp1 : this.input1.getInterestingProperties().getLocalProperties()) {
		final Channel in1 = template1.clone();
		ilp1.parameterizeChannel(in1);
		
		for (RequestedLocalProperties ilp2 : this.input2.getInterestingProperties().getLocalProperties()) {
			final Channel in2 = template2.clone();
			ilp2.parameterizeChannel(in2);
			
			for (OperatorDescriptorDual dps: getProperties()) {
				for (LocalPropertiesPair lpp : dps.getPossibleLocalProperties()) {
					if (lpp.getProperties1().isMetBy(in1.getLocalProperties()) &&
						lpp.getProperties2().isMetBy(in2.getLocalProperties()) )
					{
						// valid combination
						// for non trivial local properties, we need to check that they are co compatible
						// (such as when some sort order is requested, that both are the same sort order
						if (dps.areCoFulfilled(lpp.getProperties1(), lpp.getProperties2(), 
							in1.getLocalProperties(), in2.getLocalProperties()))
						{
							// copy, because setting required properties and instantiation may
							// change the channels and should not affect prior candidates
							Channel in1Copy = in1.clone();
							in1Copy.setRequiredLocalProps(lpp.getProperties1());
							
							Channel in2Copy = in2.clone();
							in2Copy.setRequiredLocalProps(lpp.getProperties2());
							
							// all right, co compatible
							instantiate(dps, in1Copy, in2Copy, broadcastPlanChannels, target, estimator, rgps1, rgps2, ilp1, ilp2);
							break;
						}
						// else cannot use this pair, fall through the loop and try the next one
					}
				}
			}
		}
	}
}