@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; }
@Override public FormatSelection isReadable(DrillFileSystem fs, FileSelection selection) throws IOException { // TODO: we only check the first file for directory reading. This is because if (selection.containsDirectories(fs)) { if (isDirReadable(fs, selection.getFirstPath(fs))) { return new FormatSelection(plugin.getConfig(), expandSelection(fs, selection)); } } return super.isReadable(fs, selection); }