drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adeneche <...@git.apache.org>
Subject [GitHub] drill pull request: DRILL-2618: handle queries over empty folders ...
Date Thu, 19 Nov 2015 23:43:03 GMT
Github user adeneche commented on a diff in the pull request:

    https://github.com/apache/drill/pull/270#discussion_r45418223
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
---
    @@ -190,22 +136,40 @@ private static String commonPath(FileStatus... paths) {
             break;
           }
         }
    -    URI oneURI = paths[0].getPath().toUri();
    +    URI oneURI = statuses.get(0).getPath().toUri();
         return new Path(oneURI.getScheme(), oneURI.getAuthority(), commonPath).toString();
       }
     
    -  public static FileSelection create(DrillFileSystem fs, String parent, String path)
throws IOException {
    -    Path p = new Path(parent,removeLeadingSlash(path));
    -    FileStatus[] status = fs.globStatus(p);
    -    if (status == null || status.length == 0) {
    +  public static FileSelection create(final DrillFileSystem fs, final String parent, final
String path) throws IOException {
    +    final Path combined = new Path(parent, removeLeadingSlash(path));
    +    final FileStatus[] statuses = fs.globStatus(combined);
    +    if (statuses == null) {
           return null;
         }
    -    if (status.length == 1) {
    -      URI oneURI = status[0].getPath().toUri();
    -      String selectionRoot = new Path(oneURI.getScheme(), oneURI.getAuthority(), p.toUri().getPath()).toString();
    -      return new FileSelection(Collections.singletonList(status[0]), selectionRoot);
    +    return create(Lists.newArrayList(statuses), null, combined.toUri().toString());
    +  }
    +
    +  /**
    +   * Creates a {@link FileSelection selection} with the given file statuses/files and
selection root.
    +   *
    +   * @param statuses  list of file statuses
    +   * @param files  list of files
    +   * @param root  root path for selections
    +   *
    +   * @return  null if creation of {@link FileSelection} fails with an {@link IllegalArgumentException}
    +   *          otherwise a new selection.
    +   *
    +   * @see FileSelection#FileSelection(List, List, String)
    +   */
    +  public static FileSelection create(final List<FileStatus> statuses, final List<String>
files, final String root) {
    +    try {
    +      final String selectionRoot = Strings.isNullOrEmpty(root) ? commonPath(statuses)
: root;
    --- End diff --
    
    `FormatSelection` C'tor calls this method passing `statuses` and `root` as null. this
will call `commonPath()` passing null as a parameter, which will cause a NPE


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message