DRILL-3099: FileSelection's selectionRoot does not include the scheme and authority
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/36ff2590 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/36ff2590 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/36ff2590 Branch: refs/heads/master Commit: 36ff259078f3fa9ebc2fb552eaedc8ce14298636 Parents: 984ee01 Author: Aditya Kishore <[email protected]> Authored: Thu May 14 21:56:13 2015 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Thu May 14 22:18:03 2015 -0700 ---------------------------------------------------------------------- .../drill/exec/store/dfs/FileSelection.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/36ff2590/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java index be9784e..e7f7b28 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java @@ -18,6 +18,7 @@ package org.apache.drill.exec.store.dfs; import java.io.IOException; +import java.net.URI; import java.util.Collections; import java.util.List; @@ -127,29 +128,30 @@ public class FileSelection { return statuses; } - public static String commonPath(FileStatus... paths){ + private static String commonPath(FileStatus... paths) { String commonPath = ""; String[][] folders = new String[paths.length][]; - for(int i = 0; i < paths.length; i++){ + for (int i = 0; i < paths.length; i++) { folders[i] = Path.getPathWithoutSchemeAndAuthority(paths[i].getPath()).toString().split("/"); } - for(int j = 0; j < folders[0].length; j++){ + for (int j = 0; j < folders[0].length; j++) { String thisFolder = folders[0][j]; boolean allMatched = true; - for(int i = 1; i < folders.length && allMatched; i++){ - if(folders[i].length < j){ + for (int i = 1; i < folders.length && allMatched; i++) { + if (folders[i].length < j) { allMatched = false; break; } allMatched &= folders[i][j].equals(thisFolder); } - if(allMatched){ + if (allMatched) { commonPath += thisFolder + "/"; - }else{ + } else { break; } } - return commonPath; + URI oneURI = paths[0].getPath().toUri(); + return new Path(oneURI.getScheme(), oneURI.getAuthority(), commonPath).toString(); } public static FileSelection create(DrillFileSystem fs, String parent, String path) throws IOException {
