コード例 #1
0
  @Override
  public DrillTable create(String key) {
    try {

      FileSelection fileSelection = FileSelection.create(fs, config.getLocation(), key);
      if (fileSelection == null) return null;

      if (fileSelection.containsDirectories(fs)) {
        for (FormatMatcher m : dirMatchers) {
          try {
            Object selection = m.isReadable(fileSelection);
            if (selection != null)
              return new DynamicDrillTable(plugin, storageEngineName, selection);
          } catch (IOException e) {
            logger.debug("File read failed.", e);
          }
        }
        fileSelection = fileSelection.minusDirectories(fs);
      }

      for (FormatMatcher m : fileMatchers) {
        Object selection = m.isReadable(fileSelection);
        if (selection != null) return new DynamicDrillTable(plugin, storageEngineName, selection);
      }
      return null;

    } catch (IOException e) {
      logger.debug(
          "Failed to create DrillTable with root {} and name {}", config.getLocation(), key, e);
    }

    return null;
  }
コード例 #2
0
  public WorkspaceSchemaFactory(
      DrillConfig drillConfig,
      PStoreProvider provider,
      FileSystemPlugin plugin,
      String schemaName,
      String storageEngineName,
      DrillFileSystem fileSystem,
      WorkspaceConfig config,
      List<FormatMatcher> formatMatchers)
      throws ExecutionSetupException, IOException {
    this.fs = fileSystem;
    this.plugin = plugin;
    this.drillConfig = drillConfig;
    this.config = config;
    this.mapper = drillConfig.getMapper();
    this.fileMatchers = Lists.newArrayList();
    this.dirMatchers = Lists.newArrayList();
    this.storageEngineName = storageEngineName;
    this.schemaName = schemaName;

    // setup cache
    if (storageEngineName == null) {
      this.knownViews = null;
      //      this.knownPaths = null;
    } else {
      this.knownViews =
          provider.getPStore(
              PStoreConfig //
                  .newJacksonBuilder(drillConfig.getMapper(), String.class) //
                  .name(Joiner.on('.').join("storage.views", storageEngineName, schemaName)) //
                  .build());

      //      this.knownPaths = provider.getPTable(PTableConfig //
      //          .newJacksonBuilder(drillConfig.getMapper(), String.class) //
      //          .name(Joiner.on('.').join("storage.cache", storageEngineName, schemaName)) //
      //          .build());
    }

    for (FormatMatcher m : formatMatchers) {
      if (m.supportDirectoryReads()) {
        dirMatchers.add(m);
      }
      fileMatchers.add(m);
    }
  }