コード例 #1
0
  @Test
  public void test(final DrillbitContext bitContext) throws Exception {
    final DrillConfig c = DrillConfig.create();

    new NonStrictExpectations() {
      {
        bitContext.getMetrics();
        result = new MetricRegistry();
        bitContext.getAllocator();
        result = new TopLevelAllocator();
        bitContext.getConfig();
        result = c;
        bitContext.getCache();
        result = new LocalCache();
      }
    };

    bitContext.getCache().run();

    StoragePluginRegistry r = new StoragePluginRegistry(bitContext);
    SchemaPlus plus = Frameworks.createRootSchema();
    r.init();
    r.getSchemaFactory().registerSchemas(null, plus);

    printSchema(plus, 0);
  }
コード例 #2
0
ファイル: Frameworks.java プロジェクト: josephwinston/optiq
 /**
  * Initializes a container then calls user-specified code with a planner.
  *
  * @param action Callback containing user-specified code
  * @return Return value from action
  */
 public static <R> R withPlanner(final PlannerAction<R> action) {
   FrameworkConfig config =
       newConfigBuilder() //
           .defaultSchema(Frameworks.createRootSchema(true))
           .build();
   return withPlanner(action, config);
 }
コード例 #3
0
  protected void testSqlPlan(String sqlCommands) throws Exception {
    String[] sqlStrings = sqlCommands.split(";");

    final DistributedCache cache = new LocalCache();
    cache.run();

    final SystemOptionManager opt = new SystemOptionManager(cache);
    opt.init();
    final OptionManager sess = new SessionOptionManager(opt);

    new NonStrictExpectations() {
      {
        dbContext.getMetrics();
        result = new MetricRegistry();
        dbContext.getAllocator();
        result = new TopLevelAllocator();
        dbContext.getConfig();
        result = config;
        dbContext.getOptionManager();
        result = opt;
        dbContext.getCache();
        result = cache;
      }
    };

    final StoragePluginRegistry registry = new StoragePluginRegistry(dbContext);
    registry.init();
    final FunctionImplementationRegistry functionRegistry =
        new FunctionImplementationRegistry(config);
    final SchemaPlus root = Frameworks.createRootSchema(false);
    registry.getSchemaFactory().registerSchemas(new UserSession(null, null, null), root);

    new NonStrictExpectations() {
      {
        context.getNewDefaultSchema();
        result = root;
        context.getStorage();
        result = registry;
        context.getFunctionRegistry();
        result = functionRegistry;
        context.getSession();
        result = new UserSession(null, null, null);
        context.getCurrentEndpoint();
        result = DrillbitEndpoint.getDefaultInstance();
        context.getActiveEndpoints();
        result = ImmutableList.of(DrillbitEndpoint.getDefaultInstance());
        context.getPlannerSettings();
        result = new PlannerSettings(sess);
        context.getOptions();
        result = sess;
        context.getConfig();
        result = config;
        context.getCache();
        result = cache;
      }
    };

    for (String sql : sqlStrings) {
      if (sql.trim().isEmpty()) continue;
      DrillSqlWorker worker = new DrillSqlWorker(context);
      PhysicalPlan p = worker.getPlan(sql);
    }
  }
コード例 #4
0
ファイル: Frameworks.java プロジェクト: josephwinston/optiq
 public PrepareAction() {
   this.config =
       newConfigBuilder() //
           .defaultSchema(Frameworks.createRootSchema(true))
           .build();
 }