use of org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator in project asterixdb by apache.
the class MoveFreeVariableOperatorOutOfSubplanRule method producedVariablesCanbePropagated.
// Checks whether there is a variable killing operator in the nested pipeline
private boolean producedVariablesCanbePropagated(ILogicalOperator operator) throws AlgebricksException {
ILogicalOperator currentOperator = operator;
// Makes sure the produced variables by operator are not killed in the nested pipeline below it.
while (!currentOperator.getInputs().isEmpty()) {
LogicalOperatorTag operatorTag = currentOperator.getOperatorTag();
if (operatorTag == LogicalOperatorTag.AGGREGATE || operatorTag == LogicalOperatorTag.RUNNINGAGGREGATE || operatorTag == LogicalOperatorTag.GROUP) {
return false;
}
if (operatorTag == LogicalOperatorTag.PROJECT) {
Set<LogicalVariable> producedVars = new HashSet<>();
VariableUtilities.getProducedVariables(currentOperator, producedVars);
ProjectOperator projectOperator = (ProjectOperator) currentOperator;
if (!projectOperator.getVariables().containsAll(producedVars)) {
return false;
}
}
currentOperator = currentOperator.getInputs().get(0).getValue();
}
return true;
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator in project asterixdb by apache.
the class PushProjectDownRule method pushAllProjectionsOnTopOf.
// It does not try to push above another Projection.
private static boolean pushAllProjectionsOnTopOf(Collection<LogicalVariable> toPush, Mutable<ILogicalOperator> opRef, IOptimizationContext context, ILogicalOperator initialOp) throws AlgebricksException {
if (toPush.isEmpty()) {
return false;
}
AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
if (context.checkAndAddToAlreadyCompared(initialOp, op)) {
return false;
}
if (op.getOperatorTag() == LogicalOperatorTag.PROJECT) {
return false;
}
ProjectOperator pi2 = new ProjectOperator(new ArrayList<LogicalVariable>(toPush));
pi2.getInputs().add(new MutableObject<ILogicalOperator>(op));
opRef.setValue(pi2);
pi2.setExecutionMode(op.getExecutionMode());
context.computeAndSetTypeEnvironmentForOperator(pi2);
return true;
}
Aggregations