Search in sources :

Example 81 with ILogicalPlan

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

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method deepCopyPlan.

private ILogicalPlan deepCopyPlan(ILogicalPlan plan, ILogicalOperator arg) throws AlgebricksException {
    List<Mutable<ILogicalOperator>> rootsCopy = deepCopyOperatorReferenceList(plan.getRoots(), arg);
    ILogicalPlan planCopy = new ALogicalPlanImpl(rootsCopy);
    return planCopy;
}
Also used : Mutable(org.apache.commons.lang3.mutable.Mutable) ALogicalPlanImpl(org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)

Example 82 with ILogicalPlan

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

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitGroupByOperator.

@Override
public ILogicalOperator visitGroupByOperator(GroupByOperator op, ILogicalOperator arg) throws AlgebricksException {
    List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> groupByListCopy = deepCopyVariableExpressionReferencePairList(op.getGroupByList());
    List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorListCopy = deepCopyVariableExpressionReferencePairList(op.getDecorList());
    List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
    GroupByOperator opCopy = new GroupByOperator(groupByListCopy, decorListCopy, nestedPlansCopy, op.isGroupAll());
    deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
    deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
    return opCopy;
}
Also used : ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) GroupByOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator) ArrayList(java.util.ArrayList) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 83 with ILogicalPlan

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

the class GroupByOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    int n = 0;
    for (ILogicalPlan p : nestedPlans) {
        n += p.getRoots().size();
    }
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n];
    int i = 0;
    for (ILogicalPlan p : nestedPlans) {
        for (Mutable<ILogicalOperator> r : p.getRoots()) {
            envPointers[i] = new OpRefTypeEnvPointer(r, ctx);
            i++;
        }
    }
    IVariableTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
    ILogicalOperator child = inputs.get(0).getValue();
    IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(child);
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getGroupByList()) {
        ILogicalExpression expr = p.second.getValue();
        if (p.first != null) {
            env.setVarType(p.first, env2.getType(expr));
            if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
                LogicalVariable v1 = ((VariableReferenceExpression) expr).getVariableReference();
                env.setVarType(v1, env2.getVarType(v1));
            }
        } else {
            VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = vre.getVariableReference();
            env.setVarType(v2, env2.getVarType(v2));
        }
    }
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getDecorList()) {
        ILogicalExpression expr = p.second.getValue();
        if (p.first != null) {
            env.setVarType(p.first, env2.getType(expr));
        } else {
            VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = vre.getVariableReference();
            env.setVarType(v2, env2.getVarType(v2));
        }
    }
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Example 84 with ILogicalPlan

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

the class SubplanOperator method setRootOp.

public void setRootOp(Mutable<ILogicalOperator> opRef) {
    ILogicalPlan p = new ALogicalPlanImpl(opRef);
    nestedPlans.add(p);
}
Also used : ALogicalPlanImpl(org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)

Example 85 with ILogicalPlan

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

the class HeuristicCompilerFactoryBuilder method create.

@Override
public ICompilerFactory create() {
    return new ICompilerFactory() {

        @Override
        public ICompiler createCompiler(final ILogicalPlan plan, final IMetadataProvider<?, ?> metadata, int varCounter) {
            final IOptimizationContext oc = optCtxFactory.createOptimizationContext(varCounter, expressionEvalSizeComputer, mergeAggregationExpressionFactory, expressionTypeComputer, missableTypeComputer, conflictingTypeResolver, physicalOptimizationConfig, clusterLocations);
            oc.setMetadataDeclarations(metadata);
            final HeuristicOptimizer opt = new HeuristicOptimizer(plan, logicalRewrites, physicalRewrites, oc);
            return new ICompiler() {

                @Override
                public void optimize() throws AlgebricksException {
                    opt.optimize();
                }

                @Override
                public JobSpecification createJob(Object appContext, IJobletEventListenerFactory jobEventListenerFactory) throws AlgebricksException {
                    AlgebricksConfig.ALGEBRICKS_LOGGER.fine("Starting Job Generation.\n");
                    JobGenContext context = new JobGenContext(null, metadata, appContext, serializerDeserializerProvider, hashFunctionFactoryProvider, hashFunctionFamilyProvider, comparatorFactoryProvider, typeTraitProvider, binaryBooleanInspectorFactory, binaryIntegerInspectorFactory, printerProvider, missingWriterFactory, normalizedKeyComputerFactoryProvider, expressionRuntimeProvider, expressionTypeComputer, oc, expressionEvalSizeComputer, partialAggregationTypeComputer, predEvaluatorFactoryProvider, physicalOptimizationConfig.getFrameSize(), clusterLocations);
                    PlanCompiler pc = new PlanCompiler(context);
                    return pc.compilePlan(plan, null, jobEventListenerFactory);
                }
            };
        }
    };
}
Also used : PlanCompiler(org.apache.hyracks.algebricks.core.jobgen.impl.PlanCompiler) IOptimizationContext(org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) IMetadataProvider(org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider) HeuristicOptimizer(org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer) IJobletEventListenerFactory(org.apache.hyracks.api.job.IJobletEventListenerFactory) JobGenContext(org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext)

Aggregations

ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)89 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)73 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)53 Mutable (org.apache.commons.lang3.mutable.Mutable)44 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)44 ArrayList (java.util.ArrayList)36 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)35 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)27 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)24 AbstractOperatorWithNestedPlans (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans)23 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)21 HashSet (java.util.HashSet)19 SubplanOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator)19 MutableObject (org.apache.commons.lang3.mutable.MutableObject)17 Pair (org.apache.hyracks.algebricks.common.utils.Pair)16 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)13 NestedTupleSourceOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator)13 ALogicalPlanImpl (org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl)13 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)10 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)9