@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;
  }
Ejemplo n.º 2
0
 @Test
 public void testCreateReturnsNullWhenArgumentsAreIllegal() {
   for (final Object statuses : new Object[] {null, EMPTY_STATUSES}) {
     for (final Object files : new Object[] {null, EMPTY_FILES}) {
       for (final Object root : new Object[] {null, EMPTY_ROOT}) {
         final FileSelection selection =
             FileSelection.create(
                 (List<FileStatus>) statuses, (List<String>) files, (String) root);
         assertNull(selection);
       }
     }
   }
 }
 @Override
 public GroupScan createNewGroupScan(List<String> newFiles) throws IOException {
   final FileSelection newSelection = FileSelection.create(null, newFiles, getBaseTableLocation());
   final FileGroupScan newScan = ((FileGroupScan) scanRel.getGroupScan()).clone(newSelection);
   return newScan;
 }