Search in sources :

Example 1 with BasicOptimizer

use of org.apache.drill.exec.opt.BasicOptimizer in project drill by axbaretto.

the class TestOptiqPlans method doLogicalTest.

private SimpleRootExec doLogicalTest(final BootStrapContext context, UserClientConnection connection, String file, ClusterCoordinator coord, DataConnectionCreator com, Controller controller, WorkEventBus workBus) throws Exception {
    new NonStrictExpectations() {

        {
            context.getMetrics();
            result = new MetricRegistry();
            context.getAllocator();
            result = RootAllocatorFactory.newRoot(config);
            context.getConfig();
            result = config;
        }
    };
    final RemoteServiceSet lss = RemoteServiceSet.getLocalServiceSet();
    final DrillbitContext bitContext = new DrillbitContext(DrillbitEndpoint.getDefaultInstance(), context, coord, controller, com, workBus, new LocalPersistentStoreProvider(config));
    final QueryContext qc = new QueryContext(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build(), bitContext, QueryId.getDefaultInstance());
    final PhysicalPlanReader reader = bitContext.getPlanReader();
    final LogicalPlan plan = reader.readLogicalPlan(Files.toString(DrillFileUtils.getResourceAsFile(file), Charsets.UTF_8));
    final PhysicalPlan pp = new BasicOptimizer(qc, connection).optimize(new BasicOptimizer.BasicOptimizationContext(qc), plan);
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
    final FragmentContext fctxt = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(fctxt, (FragmentRoot) pp.getSortedOperators(false).iterator().next()));
    return exec;
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) BasicOptimizer(org.apache.drill.exec.opt.BasicOptimizer) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) FragmentContext(org.apache.drill.exec.ops.FragmentContext) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) MetricRegistry(com.codahale.metrics.MetricRegistry) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) QueryContext(org.apache.drill.exec.ops.QueryContext) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) NonStrictExpectations(mockit.NonStrictExpectations) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Example 2 with BasicOptimizer

use of org.apache.drill.exec.opt.BasicOptimizer in project drill by apache.

the class TestOptiqPlans method doLogicalTest.

private SimpleRootExec doLogicalTest(final BootStrapContext context, UserClientConnection connection, String file, ClusterCoordinator coord, DataConnectionCreator com, Controller controller, WorkEventBus workBus) throws Exception {
    new NonStrictExpectations() {

        {
            context.getMetrics();
            result = new MetricRegistry();
            context.getAllocator();
            result = RootAllocatorFactory.newRoot(config);
            context.getConfig();
            result = config;
        }
    };
    final RemoteServiceSet lss = RemoteServiceSet.getLocalServiceSet();
    final DrillbitContext bitContext = new DrillbitContext(DrillbitEndpoint.getDefaultInstance(), context, coord, controller, com, workBus, new LocalPersistentStoreProvider(config));
    final QueryContext qc = new QueryContext(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build(), bitContext, QueryId.getDefaultInstance());
    final PhysicalPlanReader reader = bitContext.getPlanReader();
    final LogicalPlan plan = reader.readLogicalPlan(Files.toString(FileUtils.getResourceAsFile(file), Charsets.UTF_8));
    final PhysicalPlan pp = new BasicOptimizer(qc, connection).optimize(new BasicOptimizer.BasicOptimizationContext(qc), plan);
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
    final FragmentContext fctxt = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(fctxt, (FragmentRoot) pp.getSortedOperators(false).iterator().next()));
    return exec;
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) BasicOptimizer(org.apache.drill.exec.opt.BasicOptimizer) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) FragmentContext(org.apache.drill.exec.ops.FragmentContext) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) MetricRegistry(com.codahale.metrics.MetricRegistry) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) QueryContext(org.apache.drill.exec.ops.QueryContext) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) LogicalPlan(org.apache.drill.common.logical.LogicalPlan) NonStrictExpectations(mockit.NonStrictExpectations) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)2 NonStrictExpectations (mockit.NonStrictExpectations)2 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)2 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)2 FragmentContext (org.apache.drill.exec.ops.FragmentContext)2 QueryContext (org.apache.drill.exec.ops.QueryContext)2 BasicOptimizer (org.apache.drill.exec.opt.BasicOptimizer)2 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)2 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)2 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)2 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)2 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)2 LocalPersistentStoreProvider (org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider)2