Search in sources :

Example 1 with LocalPersistentStoreProvider

use of org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider in project drill by apache.

the class CodeCompilerTestFactory method getTestCompiler.

public static CodeCompiler getTestCompiler(DrillConfig c) throws Exception {
    DrillConfig config = checkNotNull(c);
    LogicalPlanPersistence persistence = new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config));
    LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
    SystemOptionManager systemOptionManager = new SystemOptionManager(persistence, provider);
    return new CodeCompiler(config, systemOptionManager.init());
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence)

Example 2 with LocalPersistentStoreProvider

use of org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider in project drill by apache.

the class ReplaceMethodInvoke method main.

// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ReplaceMethodInvoke.class);
public static void main(String[] args) throws Exception {
    final String k2 = "org/apache/drill/Pickle.class";
    final URL url = Resources.getResource(k2);
    final byte[] clazz = Resources.toByteArray(url);
    final ClassReader cr = new ClassReader(clazz);
    final ClassWriter cw = writer();
    final TraceClassVisitor visitor = new TraceClassVisitor(cw, new Textifier(), new PrintWriter(System.out));
    final ValueHolderReplacementVisitor v2 = new ValueHolderReplacementVisitor(visitor, true);
    //| ClassReader.SKIP_DEBUG);
    cr.accept(v2, ClassReader.EXPAND_FRAMES);
    final byte[] output = cw.toByteArray();
    Files.write(output, new File("/src/scratch/bytes/S.class"));
    check(output);
    final DrillConfig c = DrillConfig.forClient();
    final SystemOptionManager m = new SystemOptionManager(PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c), new LocalPersistentStoreProvider(c));
    m.init();
    try (QueryClassLoader ql = new QueryClassLoader(DrillConfig.create(), m)) {
        ql.injectByteCode("org.apache.drill.Pickle$OutgoingBatch", output);
        Class<?> clz = ql.loadClass("org.apache.drill.Pickle$OutgoingBatch");
        clz.getMethod("x").invoke(null);
    }
}
Also used : LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) Textifier(org.objectweb.asm.util.Textifier) URL(java.net.URL) ClassWriter(org.objectweb.asm.ClassWriter) QueryClassLoader(org.apache.drill.exec.compile.QueryClassLoader) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) DrillConfig(org.apache.drill.common.config.DrillConfig) ClassReader(org.objectweb.asm.ClassReader) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 3 with LocalPersistentStoreProvider

use of org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider in project drill by apache.

the class PlanningBase method testSqlPlan.

protected void testSqlPlan(String sqlCommands) throws Exception {
    final String[] sqlStrings = sqlCommands.split(";");
    final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
    provider.start();
    final ScanResult scanResult = ClassPathScanner.fromPrescan(config);
    final LogicalPlanPersistence logicalPlanPersistence = new LogicalPlanPersistence(config, scanResult);
    final SystemOptionManager systemOptions = new SystemOptionManager(logicalPlanPersistence, provider);
    systemOptions.init();
    @SuppressWarnings("resource") final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
    final SessionOptionManager sessionOptions = (SessionOptionManager) userSession.getOptions();
    final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions);
    final ExecutionControls executionControls = new ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
    new NonStrictExpectations() {

        {
            dbContext.getMetrics();
            result = new MetricRegistry();
            dbContext.getAllocator();
            result = allocator;
            dbContext.getConfig();
            result = config;
            dbContext.getOptionManager();
            result = systemOptions;
            dbContext.getStoreProvider();
            result = provider;
            dbContext.getClasspathScan();
            result = scanResult;
            dbContext.getLpPersistence();
            result = logicalPlanPersistence;
        }
    };
    final StoragePluginRegistry registry = new StoragePluginRegistryImpl(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry = new FunctionImplementationRegistry(config);
    final DrillOperatorTable table = new DrillOperatorTable(functionRegistry, systemOptions);
    final SchemaPlus root = SimpleCalciteSchema.createRootSchema(false);
    registry.getSchemaFactory().registerSchemas(SchemaConfig.newBuilder("foo", context).build(), root);
    new NonStrictExpectations() {

        {
            context.getNewDefaultSchema();
            result = root;
            context.getLpPersistence();
            result = new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config));
            context.getStorage();
            result = registry;
            context.getFunctionRegistry();
            result = functionRegistry;
            context.getSession();
            result = UserSession.Builder.newBuilder().setSupportComplexTypes(true).build();
            context.getCurrentEndpoint();
            result = DrillbitEndpoint.getDefaultInstance();
            context.getActiveEndpoints();
            result = ImmutableList.of(DrillbitEndpoint.getDefaultInstance());
            context.getPlannerSettings();
            result = new PlannerSettings(queryOptions, functionRegistry);
            context.getOptions();
            result = queryOptions;
            context.getConfig();
            result = config;
            context.getDrillOperatorTable();
            result = table;
            context.getAllocator();
            result = allocator;
            context.getExecutionControls();
            result = executionControls;
            dbContext.getLpPersistence();
            result = logicalPlanPersistence;
        }
    };
    for (final String sql : sqlStrings) {
        if (sql.trim().isEmpty()) {
            continue;
        }
        @SuppressWarnings("unused") final PhysicalPlan p = DrillSqlWorker.getPlan(context, sql);
    }
}
Also used : SessionOptionManager(org.apache.drill.exec.server.options.SessionOptionManager) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) QueryOptionManager(org.apache.drill.exec.server.options.QueryOptionManager) MetricRegistry(com.codahale.metrics.MetricRegistry) SchemaPlus(org.apache.calcite.schema.SchemaPlus) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) ExecutionControls(org.apache.drill.exec.testing.ExecutionControls) UserSession(org.apache.drill.exec.rpc.user.UserSession) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) NonStrictExpectations(mockit.NonStrictExpectations) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) DrillOperatorTable(org.apache.drill.exec.planner.sql.DrillOperatorTable)

Example 4 with LocalPersistentStoreProvider

use of org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider in project drill by apache.

the class ExecTest method setupOptionManager.

@BeforeClass
public static void setupOptionManager() throws Exception {
    final LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(c);
    provider.start();
    optionManager = new SystemOptionManager(PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c), provider);
    optionManager.init();
}
Also used : LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) BeforeClass(org.junit.BeforeClass)

Example 5 with LocalPersistentStoreProvider

use of org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider 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

LocalPersistentStoreProvider (org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider)5 SystemOptionManager (org.apache.drill.exec.server.options.SystemOptionManager)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 NonStrictExpectations (mockit.NonStrictExpectations)2 DrillConfig (org.apache.drill.common.config.DrillConfig)2 LogicalPlanPersistence (org.apache.drill.common.config.LogicalPlanPersistence)2 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)2 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)2 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 URL (java.net.URL)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)1 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)1 QueryClassLoader (org.apache.drill.exec.compile.QueryClassLoader)1 FragmentContext (org.apache.drill.exec.ops.FragmentContext)1 QueryContext (org.apache.drill.exec.ops.QueryContext)1 BasicOptimizer (org.apache.drill.exec.opt.BasicOptimizer)1 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)1 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)1