You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pr...@apache.org on 2016/12/12 04:46:11 UTC
hive git commit: HIVE-15405: Improve FileUtils.isPathWithinSubtree
(Rajesh Balamohan reviewed by Sergey Shelukhin)
Repository: hive
Updated Branches:
refs/heads/master 9a524ada2 -> 0ae24756e
HIVE-15405: Improve FileUtils.isPathWithinSubtree (Rajesh Balamohan reviewed by Sergey Shelukhin)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0ae24756
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0ae24756
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0ae24756
Branch: refs/heads/master
Commit: 0ae24756e67845f2940fafa7768789ebb1cb5796
Parents: 9a524ad
Author: Prasanth Jayachandran <pr...@apache.org>
Authored: Sun Dec 11 20:45:56 2016 -0800
Committer: Prasanth Jayachandran <pr...@apache.org>
Committed: Sun Dec 11 20:45:56 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/hadoop/hive/common/FileUtils.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/0ae24756/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
index 00fbc3b..a8ed8af 100644
--- a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
+++ b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
@@ -900,11 +900,18 @@ public final class FileUtils {
* @return
*/
public static boolean isPathWithinSubtree(Path path, Path subtree) {
- while(path!=null){
+ return isPathWithinSubtree(path, subtree, subtree.depth());
+ }
+
+ private static boolean isPathWithinSubtree(Path path, Path subtree, int subtreeDepth) {
+ while(path != null){
+ if (subtreeDepth > path.depth()) {
+ return false;
+ }
if(subtree.equals(path)){
return true;
}
- path=path.getParent();
+ path = path.getParent();
}
return false;
}