Search in sources :

Example 1 with ILogicalOperator

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

the class CommitPOperator method contributeRuntimeOperator.

@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
    MetadataProvider metadataProvider = (MetadataProvider) context.getMetadataProvider();
    RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context);
    int[] primaryKeyFields = JobGenHelper.variablesToFieldIndexes(primaryKeyLogicalVars, inputSchemas[0]);
    //get dataset splits
    IPushRuntimeFactory runtime = dataset.getCommitRuntimeFactory(metadataProvider, jobId, primaryKeyFields, isSink);
    builder.contributeMicroOperator(op, runtime, recDesc);
    ILogicalOperator src = op.getInputs().get(0).getValue();
    builder.contributeGraphEdge(src, 0, op, 0);
}
Also used : MetadataProvider(org.apache.asterix.metadata.declared.MetadataProvider) RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) IPushRuntimeFactory(org.apache.hyracks.algebricks.runtime.base.IPushRuntimeFactory)

Example 2 with ILogicalOperator

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

the class CancelUnnestWithNestedListifyRule method applyRuleDown.

private boolean applyRuleDown(Mutable<ILogicalOperator> opRef, Set<LogicalVariable> varSet, IOptimizationContext context) throws AlgebricksException {
    boolean changed = applies(opRef, varSet, context);
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    VariableUtilities.getUsedVariables(op, varSet);
    if (op.hasNestedPlans()) {
        AbstractOperatorWithNestedPlans aonp = (AbstractOperatorWithNestedPlans) op;
        for (ILogicalPlan p : aonp.getNestedPlans()) {
            for (Mutable<ILogicalOperator> r : p.getRoots()) {
                if (applyRuleDown(r, varSet, context)) {
                    changed = true;
                }
                context.addToDontApplySet(this, r.getValue());
            }
        }
    }
    for (Mutable<ILogicalOperator> i : op.getInputs()) {
        if (applyRuleDown(i, varSet, context)) {
            changed = true;
        }
        context.addToDontApplySet(this, i.getValue());
    }
    return changed;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) AbstractOperatorWithNestedPlans(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans)

Example 3 with ILogicalOperator

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

the class OperatorPropertiesUtil method collectUsedAndProducedVariablesInPath.

/**
     * @param op
     *            , the start operator.
     * @param dest
     *            , the destination operator (a direct/indirect input operator).
     * @param usedVars
     *            , the collection of used variables.
     * @param producedVars
     *            , the collection of produced variables.
     * @return if the current operator is on the path from the original start operator to the destination operator.
     * @throws AlgebricksException
     */
private static boolean collectUsedAndProducedVariablesInPath(ILogicalOperator op, ILogicalOperator dest, Set<LogicalVariable> usedVars, Set<LogicalVariable> producedVars) throws AlgebricksException {
    if (op == dest) {
        return true;
    }
    if (((AbstractLogicalOperator) op).hasNestedPlans()) {
        AbstractOperatorWithNestedPlans a = (AbstractOperatorWithNestedPlans) op;
        for (ILogicalPlan p : a.getNestedPlans()) {
            for (Mutable<ILogicalOperator> r : p.getRoots()) {
                if (collectUsedAndProducedVariablesInPath(r.getValue(), dest, usedVars, producedVars)) {
                    VariableUtilities.getUsedVariables(r.getValue(), usedVars);
                    VariableUtilities.getProducedVariables(r.getValue(), producedVars);
                    return true;
                }
            }
        }
    }
    for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
        if (collectUsedAndProducedVariablesInPath(childRef.getValue(), dest, usedVars, producedVars)) {
            VariableUtilities.getUsedVariables(op, usedVars);
            VariableUtilities.getProducedVariables(op, producedVars);
            return true;
        }
    }
    return false;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) AbstractOperatorWithNestedPlans(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans)

Example 4 with ILogicalOperator

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

the class OperatorPropertiesUtil method checkUnpartitionedAndGetPropertiesVector.

/**
     * Checks whether a binary input operator in consideration needs to
     * run in a single partition mode. If it does, returns an empty properties vector.
     * Otherwise, returns the proposed partitioned properties vector.
     *
     * @param op,                          the binary input operator in consideration.
     * @param partitionedPropertiesVector, the proposed partitioned properties vector.
     * @return either an empty properties vector or the proposed partitioned properties vector.
     */
public static StructuralPropertiesVector checkUnpartitionedAndGetPropertiesVector(ILogicalOperator op, StructuralPropertiesVector partitionedPropertiesVector) {
    ILogicalOperator leftChild = op.getInputs().get(0).getValue();
    ILogicalOperator rightChild = op.getInputs().get(1).getValue();
    boolean unPartitioned = leftChild.getExecutionMode().equals(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) && rightChild.getExecutionMode().equals(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED);
    return unPartitioned ? StructuralPropertiesVector.EMPTY_PROPERTIES_VECTOR : partitionedPropertiesVector;
}
Also used : ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Example 5 with ILogicalOperator

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

the class JobBuilder method addMicroOpToMetaRuntimeOp.

private void addMicroOpToMetaRuntimeOp(ILogicalOperator aop) {
    Integer k = algebraicOpBelongingToMetaAsterixOp.get(aop);
    if (k == null) {
        k = createNewMetaOpInfo(aop);
    }
    ArrayList<ILogicalOperator> destList = outEdges.get(aop);
    if (destList == null || destList.size() != 1) {
        // for now, we only support linear plans inside meta-ops.
        return;
    }
    ILogicalOperator dest = destList.get(0);
    Integer j = algebraicOpBelongingToMetaAsterixOp.get(dest);
    if (j == null && microOps.get(dest) != null) {
        algebraicOpBelongingToMetaAsterixOp.put(dest, k);
        List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent1 = metaAsterixOpSkeletons.get(k);
        aodContent1.add(microOps.get(dest));
    } else if (j != null && j.intValue() != k.intValue()) {
        // merge the j component into the k component
        List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent1 = metaAsterixOpSkeletons.get(k);
        List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent2 = metaAsterixOpSkeletons.get(j);
        aodContent1.addAll(aodContent2);
        metaAsterixOpSkeletons.remove(j);
        for (ILogicalOperator m : algebraicOpBelongingToMetaAsterixOp.keySet()) {
            Integer g = algebraicOpBelongingToMetaAsterixOp.get(m);
            if (g.intValue() == j.intValue()) {
                algebraicOpBelongingToMetaAsterixOp.put(m, k);
            }
        }
    }
}
Also used : RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) List(java.util.List) IPushRuntimeFactory(org.apache.hyracks.algebricks.runtime.base.IPushRuntimeFactory) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

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