本文整理了Java中org.apache.hadoop.fs.Path.isRoot()
方法的一些代码示例,展示了Path.isRoot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.isRoot()
方法的具体详情如下:
包路径:org.apache.hadoop.fs.Path
类名称:Path
方法名:isRoot
暂无
代码示例来源:origin: apache/hbase
private boolean isRootFolder(String targetBackupDir) {
Path p = new Path(targetBackupDir);
return p.isRoot();
}
代码示例来源:origin: prestodb/presto
private static boolean isChildDirectory(Path parentDirectory, Path childDirectory)
{
if (parentDirectory.equals(childDirectory)) {
return true;
}
if (childDirectory.isRoot()) {
return false;
}
return isChildDirectory(parentDirectory, childDirectory.getParent());
}
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Returns the root path for the specified path.
*
* @see Path
*/
public static Path getRootPath(Path path) {
if (path.isRoot()) {
return path;
}
return getRootPath(path.getParent());
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
*
* @param path
* @return return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath());
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/** Returns true if the target is an ancestor of the source. */
private boolean isAncestor(PathData source, PathData target) {
for (Path parent = source.path; (parent != null) && !parent.isRoot();
parent = parent.getParent()) {
if (parent.equals(target.path)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* @param path
* @return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return path.isAbsolute() ?
new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath()) :
new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* Strip out the root from the path.
* @param p - fully qualified path p
* @return - the remaining path without the beginning /
* @throws IOException if the p is not prefixed with root
*/
String stripOutRoot(final Path p) throws IOException {
try {
checkPath(p);
} catch (IllegalArgumentException e) {
throw new IOException("Internal Error - path " + p +
" should have been with URI: " + myUri);
}
String pathPart = p.toUri().getPath();
return (pathPart.length() == chRootPathPartString.length()) ? "" : pathPart
.substring(chRootPathPartString.length() + (chRootPathPart.isRoot() ? 0 : 1));
}
代码示例来源:origin: apache/incubator-gobblin
/**
* org.apache.hadoop.fs.Path assumes that there separator in file system naming and "/" is the separator.
* When org.apache.hadoop.fs.Path sees "/" in path String, it splits into parent and name. As fileID is a random
* String determined by Google and it can contain "/" itself, this method check if parent and name is separated and
* restore "/" back to file ID.
*
* @param p
* @return
*/
public static String toFileId(Path p) {
if (p.isRoot()) {
return "";
}
final String format = "%s" + Path.SEPARATOR + "%s";
if (p.getParent() != null && StringUtils.isEmpty(p.getParent().getName())) {
return p.getName();
}
return String.format(format, toFileId(p.getParent()), p.getName());
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
*
* Strip out the root from the path.
*
* @param p - fully qualified path p
* @return - the remaining path without the beginning /
*/
public String stripOutRoot(final Path p) {
try {
checkPath(p);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Internal Error - path " + p +
" should have been with URI" + myUri);
}
String pathPart = p.toUri().getPath();
return (pathPart.length() == chRootPathPartString.length()) ?
"" : pathPart.substring(chRootPathPartString.length() +
(chRootPathPart.isRoot() ? 0 : 1));
}
代码示例来源:origin: apache/hbase
/**
* Create the output folder and optionally set ownership.
*/
private void createOutputPath(final Path path) throws IOException {
if (filesUser == null && filesGroup == null) {
outputFs.mkdirs(path);
} else {
Path parent = path.getParent();
if (!outputFs.exists(parent) && !parent.isRoot()) {
createOutputPath(parent);
}
outputFs.mkdirs(path);
if (filesUser != null || filesGroup != null) {
// override the owner when non-null user/group is specified
outputFs.setOwner(path, filesUser, filesGroup);
}
if (filesMode > 0) {
outputFs.setPermission(path, new FsPermission(filesMode));
}
}
}
代码示例来源:origin: apache/hbase
if (wlPath.isRoot()) {
return(true);
代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-core
/**
* Validate that the file status cache contains all and only entries for a
* given set of paths up to a common parent.
*
* @param statCache the cache
* @param top the common parent at which to stop digging
* @param paths the paths to compare against the cache
*/
private void checkCacheEntries(Map<URI, FileStatus> statCache, Path top,
Path... paths) {
Set<URI> expected = new HashSet<>();
for (Path path : paths) {
Path p = fs.makeQualified(path);
while (!p.isRoot() && !p.equals(top)) {
expected.add(p.toUri());
p = p.getParent();
}
expected.add(p.toUri());
}
Set<URI> uris = statCache.keySet();
Set<URI> missing = new HashSet<>(uris);
Set<URI> extra = new HashSet<>(expected);
missing.removeAll(expected);
extra.removeAll(uris);
assertTrue("File status cache does not contain an entries for " + missing,
missing.isEmpty());
assertTrue("File status cache contains extra extries: " + extra,
extra.isEmpty());
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
*
* @param path
* @return return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath());
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/** Returns true if the target is an ancestor of the source. */
private boolean isAncestor(PathData source, PathData target) {
for (Path parent = source.path; (parent != null) && !parent.isRoot();
parent = parent.getParent()) {
if (parent.equals(target.path)) {
return true;
}
}
return false;
}
代码示例来源:origin: io.hops/hadoop-common
/** Returns true if the target is an ancestor of the source. */
private boolean isAncestor(PathData source, PathData target) {
for (Path parent = source.path; (parent != null) && !parent.isRoot();
parent = parent.getParent()) {
if (parent.equals(target.path)) {
return true;
}
}
return false;
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
*
* @param path
* @return return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath());
}
代码示例来源:origin: io.hops/hadoop-common
/**
* @param path
* @return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return path.isAbsolute() ?
new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath()) :
new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* @param path
* @return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return path.isAbsolute() ?
new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath()) :
new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* @param path
* @return full path including the chroot
*/
protected Path fullPath(final Path path) {
super.checkPath(path);
return path.isAbsolute() ?
new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString)
+ path.toUri().getPath()) :
new Path(chRootPathPartString + workingDir.toUri().getPath(), path);
}
代码示例来源:origin: org.apache.hadoop/hadoop-azure
/**
* Recursive discovery of path depth
* @param path path to measure.
* @return depth, where "/" == 0.
*/
int depth(Path path) {
if (path.isRoot()) {
return 0;
} else {
return 1 + depth(path.getParent());
}
}
内容来源于网络,如有侵权,请联系作者删除!