Search in sources :

Example 1 with JobGenContext

use of org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext in project asterixdb by apache.

the class AbstractPhysicalOperator method buildPipelineWithProjection.

private AlgebricksPipeline buildPipelineWithProjection(ILogicalPlan p, IOperatorSchema outerPlanSchema, AbstractOperatorWithNestedPlans npOp, IOperatorSchema opSchema, PlanCompiler pc) throws AlgebricksException {
    if (p.getRoots().size() > 1) {
        throw new NotImplementedException("Nested plans with several roots are not supported.");
    }
    JobSpecification nestedJob = pc.compilePlan(p, outerPlanSchema, null);
    ILogicalOperator topOpInSubplan = p.getRoots().get(0).getValue();
    JobGenContext context = pc.getContext();
    IOperatorSchema topOpInSubplanScm = context.getSchema(topOpInSubplan);
    opSchema.addAllVariables(topOpInSubplanScm);
    Map<OperatorDescriptorId, IOperatorDescriptor> opMap = nestedJob.getOperatorMap();
    if (opMap.size() != 1) {
        throw new AlgebricksException("Attempting to construct a nested plan with " + opMap.size() + " operator descriptors. Currently, nested plans can only consist in linear pipelines of Asterix micro operators.");
    }
    for (Map.Entry<OperatorDescriptorId, IOperatorDescriptor> opEntry : opMap.entrySet()) {
        IOperatorDescriptor opd = opEntry.getValue();
        if (!(opd instanceof AlgebricksMetaOperatorDescriptor)) {
            throw new AlgebricksException("Can only generate Hyracks jobs for pipelinable Asterix nested plans, not for " + opd.getClass().getName());
        }
        AlgebricksMetaOperatorDescriptor amod = (AlgebricksMetaOperatorDescriptor) opd;
        return amod.getPipeline();
    // we suppose that the top operator in the subplan already does the
    // projection for us
    }
    throw new IllegalStateException();
}
Also used : OperatorDescriptorId(org.apache.hyracks.api.dataflow.OperatorDescriptorId) IOperatorSchema(org.apache.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema) NotImplementedException(org.apache.hyracks.algebricks.common.exceptions.NotImplementedException) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) IOperatorDescriptor(org.apache.hyracks.api.dataflow.IOperatorDescriptor) JobSpecification(org.apache.hyracks.api.job.JobSpecification) Map(java.util.Map) JobGenContext(org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext)

Example 2 with JobGenContext

use of org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext 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

JobGenContext (org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext)2 Map (java.util.Map)1 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)1 NotImplementedException (org.apache.hyracks.algebricks.common.exceptions.NotImplementedException)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)1 IOptimizationContext (org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext)1 IMetadataProvider (org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)1 IOperatorSchema (org.apache.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema)1 PlanCompiler (org.apache.hyracks.algebricks.core.jobgen.impl.PlanCompiler)1 HeuristicOptimizer (org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer)1 AlgebricksMetaOperatorDescriptor (org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor)1 IOperatorDescriptor (org.apache.hyracks.api.dataflow.IOperatorDescriptor)1 OperatorDescriptorId (org.apache.hyracks.api.dataflow.OperatorDescriptorId)1 IJobletEventListenerFactory (org.apache.hyracks.api.job.IJobletEventListenerFactory)1 JobSpecification (org.apache.hyracks.api.job.JobSpecification)1