hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [10/21] hadoop git commit: Fix false prefix match of isAncestor()
Date Fri, 08 Jul 2016 21:30:17 GMT
Fix false prefix match of isAncestor()

- Change semantics slightly, isAncestor(p, p) is now false.
- Add unit test for case, which was failing, now passing.
- Update unit tests for new semantics.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f39f5b3d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f39f5b3d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f39f5b3d

Branch: refs/heads/s3_create
Commit: f39f5b3d4b92aa998d5bbc5e334be81a978a2385
Parents: aff9d7e
Author: Aaron Fabbri <fabbri@cloudera.com>
Authored: Thu Jun 30 16:29:16 2016 -0700
Committer: Aaron Fabbri <fabbri@cloudera.com>
Committed: Thu Jun 30 16:29:16 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java    | 4 ++--
 .../org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java     | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f39f5b3d/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java
index 0ae5a8d..6fc4571 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/LocalMetadataStore.java
@@ -147,10 +147,10 @@ public class LocalMetadataStore implements MetadataStore {
 
   /**
    * @return true iff 'ancestor' is ancestor dir in path 'f'.
-   * Since all paths here are absolute, this is a prefix match.
+   * All paths here are absolute.  Dir does not count as its own ancestor.
    */
   private static boolean isAncestorOf(Path ancestor, Path f) {
-    String aStr = ancestor.toString();
+    String aStr = ancestor.toString() + "/";
     String fStr = f.toString();
     return (fStr.indexOf(aStr) == 0);
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f39f5b3d/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java
index e4b2ef4..f30166d 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/TestLocalMetadataStore.java
@@ -183,10 +183,14 @@ public class TestLocalMetadataStore extends Assert {
       testMap.put(new Path(pathStr), "blah");
     }
     LocalMetadataStore.clearHashByPrefix(new Path("/a1/b1"), testMap);
-    assertEquals("Three were deleted", paths.size()-3, testMap.size());
-    assertNull("b1 deleted", testMap.get("/a1/b1"));
+    assertEquals("Two were deleted", paths.size()-2, testMap.size());
     assertNull("c1 deleted", testMap.get("/a1/b1/c1"));
     assertNull("e1 deleted", testMap.get("/a1/b1/c1/d1/e1"));
+
+    /* Make sure false prefix match doesn't work. */
+    LocalMetadataStore.clearHashByPrefix(new Path("/a"), testMap);
+    assertEquals("Partial prefix dir doesn't match", paths.size()-2,
+      testMap.size());
   }
 
   private void setupListStatus() throws IOException {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message