use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractAssignOperator in project asterixdb by apache.
the class FeedScanCollectionToUnnest method findVarOriginExpression.
private ILogicalExpression findVarOriginExpression(LogicalVariable v, ILogicalOperator op) throws AlgebricksException {
boolean searchInputs = false;
if (!(op instanceof AbstractAssignOperator)) {
searchInputs = true;
} else {
AbstractAssignOperator aao = (AbstractAssignOperator) op;
List<LogicalVariable> producedVars = new ArrayList<>();
VariableUtilities.getProducedVariables(op, producedVars);
int exprIndex = producedVars.indexOf(v);
if (exprIndex == -1) {
searchInputs = true;
} else {
ILogicalExpression originalCandidate = aao.getExpressions().get(exprIndex).getValue();
if (originalCandidate.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
searchInputs = true;
} else {
return originalCandidate;
}
}
}
if (searchInputs) {
for (Mutable<ILogicalOperator> childOp : op.getInputs()) {
ILogicalExpression ret = findVarOriginExpression(v, childOp.getValue());
if (ret != null) {
return ret;
}
}
}
throw new IllegalStateException("Unable to find the original expression that produced variable " + v);
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractAssignOperator in project asterixdb by apache.
the class IntroduceEnforcedListTypeRule method rewritePost.
@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
if (context.checkIfInDontApplySet(this, opRef.getValue()))
return false;
AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
context.addToDontApplySet(this, opRef.getValue());
/**
* rewrite list constructor types for list constructor functions
*/
List<Mutable<ILogicalExpression>> expressions;
switch(op.getOperatorTag()) {
case ASSIGN:
AbstractAssignOperator assignOp = (AbstractAssignOperator) op;
expressions = assignOp.getExpressions();
break;
case UNNEST:
AbstractUnnestOperator unnestOp = (AbstractUnnestOperator) op;
expressions = Collections.singletonList(unnestOp.getExpressionRef());
break;
default:
return false;
}
IVariableTypeEnvironment env = op.computeOutputTypeEnvironment(context);
return rewriteExpressions(expressions, env);
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractAssignOperator in project asterixdb by apache.
the class IsomorphismVariableMappingVisitor method mapVariablesForAbstractAssign.
private void mapVariablesForAbstractAssign(ILogicalOperator left, ILogicalOperator right) throws AlgebricksException {
if (left.getOperatorTag() != right.getOperatorTag()) {
return;
}
AbstractAssignOperator leftOp = (AbstractAssignOperator) left;
AbstractAssignOperator rightOp = (AbstractAssignOperator) right;
List<LogicalVariable> producedVarLeft = new ArrayList<LogicalVariable>();
List<LogicalVariable> producedVarRight = new ArrayList<LogicalVariable>();
VariableUtilities.getProducedVariables(left, producedVarLeft);
VariableUtilities.getProducedVariables(right, producedVarRight);
mapVariablesForAbstractAssign(producedVarLeft, leftOp.getExpressions(), producedVarRight, rightOp.getExpressions());
}
Aggregations