public class PathUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
GLOB_TOKENS |
| Constructor and Description |
|---|
PathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.hadoop.fs.Path |
addExtension(org.apache.hadoop.fs.Path path,
String... extensions)
Suffix all
extensions to path. |
static org.apache.hadoop.fs.Path |
combinePaths(String... paths) |
static boolean |
compareWithoutSchemeAndAuthority(org.apache.hadoop.fs.Path path1,
org.apache.hadoop.fs.Path path2)
Compare two path without shedme and authority (the prefix)
|
static org.apache.hadoop.fs.Path |
deepestNonGlobPath(org.apache.hadoop.fs.Path input)
Finds the deepest ancestor of input that is not a glob.
|
static void |
deleteEmptyParentDirectories(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path limitPath,
org.apache.hadoop.fs.Path startPath)
Deletes empty directories starting with startPath and all ancestors up to but not including limitPath.
|
static org.apache.hadoop.fs.Path |
getPathWithoutSchemeAndAuthority(org.apache.hadoop.fs.Path path)
Removes the Scheme and Authority from a Path.
|
static org.apache.hadoop.fs.Path |
getRootPath(org.apache.hadoop.fs.Path path)
Returns the root path for the specified path.
|
static boolean |
isAbsoluteAndSchemeAuthorityNull(org.apache.hadoop.fs.Path path)
Is an absolute path (ie a slash relative path part)
AND a scheme is null AND authority is null.
|
static boolean |
isAncestor(org.apache.hadoop.fs.Path possibleAncestor,
org.apache.hadoop.fs.Path fullPath)
Checks whether possibleAncestor is an ancestor of fullPath.
|
static boolean |
isGlob(org.apache.hadoop.fs.Path path) |
static org.apache.hadoop.fs.Path |
mergePaths(org.apache.hadoop.fs.Path path1,
org.apache.hadoop.fs.Path path2) |
static org.apache.hadoop.fs.Path |
relativizePath(org.apache.hadoop.fs.Path fullPath,
org.apache.hadoop.fs.Path pathPrefix) |
static org.apache.hadoop.fs.Path |
removeExtension(org.apache.hadoop.fs.Path path,
String... extensions)
Removes all
extensions from path if they exist. |
static org.apache.hadoop.fs.Path |
withoutLeadingSeparator(org.apache.hadoop.fs.Path path)
Removes the leading slash if present.
|
public static final Pattern GLOB_TOKENS
public static org.apache.hadoop.fs.Path mergePaths(org.apache.hadoop.fs.Path path1,
org.apache.hadoop.fs.Path path2)
public static org.apache.hadoop.fs.Path relativizePath(org.apache.hadoop.fs.Path fullPath,
org.apache.hadoop.fs.Path pathPrefix)
public static boolean isAncestor(org.apache.hadoop.fs.Path possibleAncestor,
org.apache.hadoop.fs.Path fullPath)
possibleAncestor - Possible ancestor of fullPath.fullPath - path to check.public static org.apache.hadoop.fs.Path getPathWithoutSchemeAndAuthority(org.apache.hadoop.fs.Path path)
Path,
URIpublic static org.apache.hadoop.fs.Path getRootPath(org.apache.hadoop.fs.Path path)
Pathpublic static org.apache.hadoop.fs.Path withoutLeadingSeparator(org.apache.hadoop.fs.Path path)
public static org.apache.hadoop.fs.Path deepestNonGlobPath(org.apache.hadoop.fs.Path input)
public static boolean isGlob(org.apache.hadoop.fs.Path path)
public static org.apache.hadoop.fs.Path removeExtension(org.apache.hadoop.fs.Path path,
String... extensions)
extensions from path if they exist.
PathUtils.removeExtention("file.txt", ".txt") = file
PathUtils.removeExtention("file.txt.gpg", ".txt", ".gpg") = file
PathUtils.removeExtention("file", ".txt") = file
PathUtils.removeExtention("file.txt", ".tar.gz") = file.txt
PathUtils.removeExtention("file.txt.gpg", ".txt") = file.gpg
PathUtils.removeExtention("file.txt.gpg", ".gpg") = file.txt
path - in which the extensions need to be removedextensions - to be removedPath without extensionspublic static org.apache.hadoop.fs.Path addExtension(org.apache.hadoop.fs.Path path,
String... extensions)
extensions to path.
PathUtils.addExtension("/tmp/data/file", ".txt") = file.txt
PathUtils.addExtension("/tmp/data/file.txt.gpg", ".zip") = file.txt.gpg.zip
PathUtils.addExtension("/tmp/data/file.txt", ".tar", ".gz") = file.txt.tar.gz
PathUtils.addExtension("/tmp/data/file.txt.gpg", ".tar.txt") = file.txt.gpg.tar.txt
path - to which the extensions need to be addedextensions - to be addedPath with extensionspublic static org.apache.hadoop.fs.Path combinePaths(String... paths)
public static boolean isAbsoluteAndSchemeAuthorityNull(org.apache.hadoop.fs.Path path)
public static void deleteEmptyParentDirectories(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path limitPath,
org.apache.hadoop.fs.Path startPath)
throws IOException
fs - FileSystem where paths are located.limitPath - only Paths that are strict descendants of this path will be deleted.startPath - first Path to delete. Afterwards empty ancestors will be deleted.IOExceptionpublic static boolean compareWithoutSchemeAndAuthority(org.apache.hadoop.fs.Path path1,
org.apache.hadoop.fs.Path path2)
path1 - path2 -