コード例 #1
0
 @Override
 public AbstractGroupScan getPhysicalScan(JSONOptions selection) throws IOException {
   FormatSelection formatSelection = selection.getWith(context.getConfig(), FormatSelection.class);
   FormatPlugin plugin;
   if (formatSelection.getFormat() instanceof NamedFormatPluginConfig) {
     plugin = formatsByName.get(((NamedFormatPluginConfig) formatSelection.getFormat()).name);
   } else {
     plugin = formatPluginsByConfig.get(formatSelection.getFormat());
   }
   if (plugin == null)
     throw new IOException(
         String.format(
             "Failure getting requested format plugin named '%s'.  It was not one of the format plugins registered.",
             formatSelection.getFormat()));
   return plugin.getGroupScan(formatSelection.getSelection());
 }
コード例 #2
0
  public FileSystemPlugin(FileSystemConfig config, DrillbitContext context, String name)
      throws ExecutionSetupException {
    try {
      this.config = config;
      this.context = context;

      Configuration fsConf = new Configuration();
      fsConf.set(FileSystem.FS_DEFAULT_NAME_KEY, config.connection);
      fsConf.set("fs.classpath.impl", ClassPathFileSystem.class.getName());
      fsConf.set("fs.drill-local.impl", LocalSyncableFileSystem.class.getName());
      this.fs = FileSystemCreator.getFileSystem(context.getConfig(), fsConf);
      this.formatsByName = FormatCreator.getFormatPlugins(context, fs, config);
      List<FormatMatcher> matchers = Lists.newArrayList();
      formatPluginsByConfig = Maps.newHashMap();
      for (FormatPlugin p : formatsByName.values()) {
        matchers.add(p.getMatcher());
        formatPluginsByConfig.put(p.getConfig(), p);
      }

      List<WorkspaceSchemaFactory> factories = null;
      if (config.workspaces == null || config.workspaces.isEmpty()) {
        factories =
            Collections.singletonList(
                new WorkspaceSchemaFactory(this, "default", name, fs, "/", matchers));
      } else {
        factories = Lists.newArrayList();
        for (Map.Entry<String, String> space : config.workspaces.entrySet()) {
          factories.add(
              new WorkspaceSchemaFactory(
                  this, space.getKey(), name, fs, space.getValue(), matchers));
        }
      }
      this.schemaFactory = new FileSystemSchemaFactory(name, factories);
    } catch (IOException e) {
      throw new ExecutionSetupException("Failure setting up file system plugin.", e);
    }
  }
コード例 #3
0
 @Override
 public InfoSchemaGroupScan getPhysicalScan(JSONOptions selection) throws IOException {
   SelectedTable table = selection.getWith(context.getConfig(), SelectedTable.class);
   return new InfoSchemaGroupScan(table);
 }
コード例 #4
0
ファイル: QueryContext.java プロジェクト: laurentgo/drill
 public DrillConfig getConfig() {
   return drillbitContext.getConfig();
 }