use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class ProducedVariableVisitor method visitUnnestNonMapOperator.
private Void visitUnnestNonMapOperator(AbstractUnnestNonMapOperator op) {
producedVariables.addAll(op.getVariables());
LogicalVariable positionalVariable = op.getPositionalVariable();
if (positionalVariable != null) {
if (!producedVariables.contains(positionalVariable)) {
producedVariables.add(positionalVariable);
}
}
return null;
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class SchemaVariableVisitor method visitDistinctOperator.
@Override
public Void visitDistinctOperator(DistinctOperator op, Void arg) throws AlgebricksException {
List<LogicalVariable> allLiveVars = new ArrayList<LogicalVariable>();
for (Mutable<ILogicalOperator> c : op.getInputs()) {
VariableUtilities.getLiveVariables(c.getValue(), allLiveVars);
}
VariableUtilities.getProducedVariables(op, allLiveVars);
/** put distinct vars first */
schemaVariables.addAll(op.getDistinctByVarList());
/** then other live vars */
for (LogicalVariable var : allLiveVars) {
if (!schemaVariables.contains(var)) {
schemaVariables.add(var);
}
}
return null;
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitUnionOperator.
@Override
public ILogicalOperator visitUnionOperator(UnionAllOperator op, ILogicalOperator arg) throws AlgebricksException {
List<Mutable<ILogicalOperator>> copiedInputs = new ArrayList<>();
for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
copiedInputs.add(deepCopyOperatorReference(childRef, null));
}
List<List<LogicalVariable>> liveVarsInInputs = new ArrayList<>();
for (Mutable<ILogicalOperator> inputOpRef : copiedInputs) {
List<LogicalVariable> liveVars = new ArrayList<>();
VariableUtilities.getLiveVariables(inputOpRef.getValue(), liveVars);
liveVarsInInputs.add(liveVars);
}
List<LogicalVariable> liveVarsInLeftInput = liveVarsInInputs.get(0);
List<LogicalVariable> liveVarsInRightInput = liveVarsInInputs.get(1);
List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> copiedTriples = new ArrayList<>();
int index = 0;
for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple : op.getVariableMappings()) {
LogicalVariable producedVar = deepCopyVariable(triple.third);
Triple<LogicalVariable, LogicalVariable, LogicalVariable> copiedTriple = new Triple<>(liveVarsInLeftInput.get(index), liveVarsInRightInput.get(index), producedVar);
copiedTriples.add(copiedTriple);
++index;
}
UnionAllOperator opCopy = new UnionAllOperator(copiedTriples);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
return opCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class OperatorDeepCopyVisitor method visitTokenizeOperator.
@Override
public ILogicalOperator visitTokenizeOperator(TokenizeOperator op, Void arg) throws AlgebricksException {
List<Mutable<ILogicalExpression>> newPrimaryKeyExpressions = new ArrayList<>();
deepCopyExpressionRefs(newPrimaryKeyExpressions, op.getPrimaryKeyExpressions());
List<Mutable<ILogicalExpression>> newSecondaryKeyExpressions = new ArrayList<>();
deepCopyExpressionRefs(newSecondaryKeyExpressions, op.getSecondaryKeyExpressions());
List<LogicalVariable> newTokenizeVars = new ArrayList<>();
deepCopyVars(newTokenizeVars, op.getTokenizeVars());
Mutable<ILogicalExpression> newFilterExpression = new MutableObject<>(((AbstractLogicalExpression) op.getFilterExpression()).cloneExpression());
List<Object> newTokenizeVarTypes = new ArrayList<>();
deepCopyObjects(newTokenizeVarTypes, op.getTokenizeVarTypes());
TokenizeOperator tokenizeOp = new TokenizeOperator(op.getDataSourceIndex(), newPrimaryKeyExpressions, newSecondaryKeyExpressions, newTokenizeVars, newFilterExpression, op.getOperation(), op.isBulkload(), op.isPartitioned(), newTokenizeVarTypes);
return tokenizeOp;
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method deepCopyVariable.
private LogicalVariable deepCopyVariable(LogicalVariable var) {
if (var == null) {
return null;
}
LogicalVariable givenVarReplacement = outputVarToInputVarMapping.get(var);
if (givenVarReplacement != null) {
inputVarToOutputVarMapping.put(var, givenVarReplacement);
return givenVarReplacement;
}
LogicalVariable varCopy = inputVarToOutputVarMapping.get(var);
if (varCopy == null) {
varCopy = varContext.newVar();
inputVarToOutputVarMapping.put(var, varCopy);
}
return varCopy;
}
Aggregations