Search in sources :

Example 61 with ILogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator 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;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) Triple(org.apache.hyracks.algebricks.common.utils.Triple) Mutable(org.apache.commons.lang3.mutable.Mutable) UnionAllOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 62 with ILogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.

the class LogicalPropertiesVisitor method propagateCardinality.

private LogicalPropertiesVectorImpl propagateCardinality(ILogicalOperator op, IOptimizationContext context) {
    ILogicalOperator op0 = op.getInputs().get(0).getValue();
    ILogicalPropertiesVector v0 = context.getLogicalPropertiesVector(op0);
    if (v0 == null) {
        return null;
    }
    LogicalPropertiesVectorImpl v = new LogicalPropertiesVectorImpl();
    v.setNumberOfTuples(v0.getNumberOfTuples());
    context.putLogicalPropertiesVector(op, v);
    return v;
}
Also used : ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) LogicalPropertiesVectorImpl(org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Example 63 with ILogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitNestedTupleSourceOperator.

@Override
public ILogicalOperator visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg) throws AlgebricksException {
    Mutable<ILogicalOperator> dataSourceReference = arg == null ? op.getDataSourceReference() : new MutableObject<ILogicalOperator>(arg);
    NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(dataSourceReference);
    deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
    return opCopy;
}
Also used : NestedTupleSourceOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Example 64 with ILogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.

the class LogicalPropertiesVisitor method visitAssignment.

private void visitAssignment(AbstractAssignOperator op, IOptimizationContext context) throws AlgebricksException {
    LogicalPropertiesVectorImpl v = propagateCardinality(op, context);
    if (v != null && v.getNumberOfTuples() != null) {
        IVariableEvalSizeEnvironment varSizeEnv = context.getVariableEvalSizeEnvironment();
        IExpressionEvalSizeComputer evalSize = context.getExpressionEvalSizeComputer();
        if (evalSize != null) {
            ILogicalOperator op0 = op.getInputs().get(0).getValue();
            ILogicalPropertiesVector v0 = context.getLogicalPropertiesVector(op0);
            if (v0 != null) {
                long frames0 = v0.getMaxOutputFrames();
                // added per tuple
                long overhead = 0;
                for (Mutable<ILogicalExpression> exprRef : op.getExpressions()) {
                    int sz = evalSize.getEvalSize(exprRef.getValue(), varSizeEnv);
                    if (sz == -1) {
                        return;
                    }
                    overhead += sz;
                }
                int frameSize = context.getPhysicalOptimizationConfig().getFrameSize();
                if (frameSize > 0) {
                    long sz = frames0 * frameSize + overhead * v.getNumberOfTuples();
                    int frames1 = (int) (sz / frameSize);
                    if (sz % frameSize > 0) {
                        frames1++;
                    }
                    v.setMaxOutputFrames(frames1);
                }
            }
        }
    }
}
Also used : IVariableEvalSizeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment) ILogicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.ILogicalPropertiesVector) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) LogicalPropertiesVectorImpl(org.apache.hyracks.algebricks.core.algebra.properties.LogicalPropertiesVectorImpl) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) IExpressionEvalSizeComputer(org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer)

Example 65 with ILogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator in project asterixdb by apache.

the class IsomorphismVariableMappingVisitor method visitNestedTupleSourceOperator.

@Override
public Void visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg) throws AlgebricksException {
    ILogicalOperator inputToCreator1 = op.getSourceOperator();
    NestedTupleSourceOperator nts = (NestedTupleSourceOperator) arg;
    ILogicalOperator inputToCreator2 = nts.getSourceOperator();
    inputToCreator1.accept(this, inputToCreator2);
    return null;
}
Also used : NestedTupleSourceOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Aggregations

ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)355 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)196 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)130 Mutable (org.apache.commons.lang3.mutable.Mutable)125 ArrayList (java.util.ArrayList)119 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)117 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)86 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)73 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)57 Pair (org.apache.hyracks.algebricks.common.utils.Pair)53 MutableObject (org.apache.commons.lang3.mutable.MutableObject)51 HashSet (java.util.HashSet)46 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)43 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)36 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)36 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)33 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)29 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)28 SubplanOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator)26 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)25