/** * Compare path component of the Path URI; e.g. if hdfs://a/b/c and /a/b/c, it will compare the * '/a/b/c' part. Does not consider schema; i.e. if schemas different but path or subpath matches, * the two will equate. * @param pathToSearch Path we will be trying to match against. * @param pathTail what to match * @return True if <code>pathTail</code> is tail on the path of <code>pathToSearch</code> */ public static boolean isMatchingTail(final Path pathToSearch, String pathTail) { return isMatchingTail(pathToSearch, new Path(pathTail)); }
/** * Test path compare and prefix checking. */ @Test public void testMatchingTail() throws IOException { Path rootdir = htu.getDataTestDir(); final FileSystem fs = rootdir.getFileSystem(conf); assertTrue(rootdir.depth() > 1); Path partPath = new Path("a", "b"); Path fullPath = new Path(rootdir, partPath); Path fullyQualifiedPath = fs.makeQualified(fullPath); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath)); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(fullyQualifiedPath, fullPath.toString())); assertFalse(CommonFSUtils.isStartingWithPath(rootdir, partPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullyQualifiedPath, partPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath.toString())); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fs.makeQualified(fullPath))); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullyQualifiedPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullPath, new Path("x"))); assertFalse(CommonFSUtils.isMatchingTail(new Path("x"), fullPath)); }
/** * Compare path component of the Path URI; e.g. if hdfs://a/b/c and /a/b/c, it will compare the * '/a/b/c' part. Does not consider schema; i.e. if schemas different but path or subpath matches, * the two will equate. * @param pathToSearch Path we will be trying to match against. * @param pathTail what to match * @return True if <code>pathTail</code> is tail on the path of <code>pathToSearch</code> */ public static boolean isMatchingTail(final Path pathToSearch, String pathTail) { return isMatchingTail(pathToSearch, new Path(pathTail)); }
/** * Compare path component of the Path URI; e.g. if hdfs://a/b/c and /a/b/c, it will compare the * '/a/b/c' part. Does not consider schema; i.e. if schemas different but path or subpath matches, * the two will equate. * @param pathToSearch Path we will be trying to match against. * @param pathTail what to match * @return True if <code>pathTail</code> is tail on the path of <code>pathToSearch</code> */ public static boolean isMatchingTail(final Path pathToSearch, String pathTail) { return isMatchingTail(pathToSearch, new Path(pathTail)); }
/** * Test path compare and prefix checking. */ @Test public void testMatchingTail() throws IOException { Path rootdir = htu.getDataTestDir(); final FileSystem fs = rootdir.getFileSystem(conf); assertTrue(rootdir.depth() > 1); Path partPath = new Path("a", "b"); Path fullPath = new Path(rootdir, partPath); Path fullyQualifiedPath = fs.makeQualified(fullPath); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath)); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(fullyQualifiedPath, fullPath.toString())); assertFalse(CommonFSUtils.isStartingWithPath(rootdir, partPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullyQualifiedPath, partPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath.toString())); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fs.makeQualified(fullPath))); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullyQualifiedPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullPath, new Path("x"))); assertFalse(CommonFSUtils.isMatchingTail(new Path("x"), fullPath)); }
/** * Test path compare and prefix checking. */ @Test public void testMatchingTail() throws IOException { Path rootdir = htu.getDataTestDir(); final FileSystem fs = rootdir.getFileSystem(conf); assertTrue(rootdir.depth() > 1); Path partPath = new Path("a", "b"); Path fullPath = new Path(rootdir, partPath); Path fullyQualifiedPath = fs.makeQualified(fullPath); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath)); assertFalse(CommonFSUtils.isMatchingTail(fullPath, partPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullPath.toString())); assertTrue(CommonFSUtils.isStartingWithPath(fullyQualifiedPath, fullPath.toString())); assertFalse(CommonFSUtils.isStartingWithPath(rootdir, partPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullyQualifiedPath, partPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath)); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fullPath.toString())); assertTrue(CommonFSUtils.isMatchingTail(fullyQualifiedPath, fs.makeQualified(fullPath))); assertTrue(CommonFSUtils.isStartingWithPath(rootdir, fullyQualifiedPath.toString())); assertFalse(CommonFSUtils.isMatchingTail(fullPath, new Path("x"))); assertFalse(CommonFSUtils.isMatchingTail(new Path("x"), fullPath)); }