org.apache.hadoop.fs.Path.isAbsolute()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.hadoop.fs.Path.isAbsolute()方法的一些代码示例,展示了Path.isAbsolute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.isAbsolute()方法的具体详情如下:
包路径:org.apache.hadoop.fs.Path
类名称:Path
方法名:isAbsolute

Path.isAbsolute介绍

[英]There is some ambiguity here. An absolute path is a slash relative name without a scheme or an authority. So either this method was incorrectly named or its implementation is incorrect. This method returns true even if there is a scheme and authority.
[中]这里有一些模棱两可的地方。绝对路径是没有方案或权限的斜杠相对名称。因此,要么这个方法的名称不正确,要么它的实现不正确。即使存在方案和权限,此方法也会返回true。

代码示例

代码示例来源:origin: Alluxio/alluxio

@Override
public void setWorkingDirectory(Path path) {
 LOG.debug("setWorkingDirectory({})", path);
 if (path.isAbsolute()) {
  mWorkingDir = path;
 } else {
  mWorkingDir = new Path(mWorkingDir, path);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private Path makeAbsolute(Path f) {
 if (f.isAbsolute()) {
  return f;
 } else {
  return new Path(workingDir, f);
 }
}

代码示例来源:origin: prestodb/presto

public static String keyFromPath(Path path)
{
  checkArgument(path.isAbsolute(), "Path is not absolute: %s", path);
  String key = nullToEmpty(path.toUri().getPath());
  if (key.startsWith(PATH_SEPARATOR)) {
    key = key.substring(PATH_SEPARATOR.length());
  }
  if (key.endsWith(PATH_SEPARATOR)) {
    key = key.substring(0, key.length() - PATH_SEPARATOR.length());
  }
  return key;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Resolve against given working directory.
 *
 * @param workDir
 * @param path
 * @return absolute path
 */
private Path makeAbsolute(Path workDir, Path path) {
 if (path.isAbsolute()) {
  return path;
 }
 return new Path(workDir, path);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Resolve against given working directory. *
 * 
 * @param workDir
 * @param path
 * @return
 */
private Path makeAbsolute(Path workDir, Path path) {
 if (path.isAbsolute()) {
  return path;
 }
 return new Path(workDir, path);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public void setWorkingDirectory(final Path new_dir) {
 workingDir = new_dir.isAbsolute() ? new_dir : new Path(workingDir, new_dir);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private Path makeAbsolute(final Path f) {
 return f.isAbsolute() ? f : new Path(workingDir, f);
}

代码示例来源:origin: apache/flink

private String pathToObjectName(final Path path) {
  org.apache.hadoop.fs.Path hadoopPath = HadoopFileSystem.toHadoopPath(path);
  if (!hadoopPath.isAbsolute()) {
    hadoopPath = new org.apache.hadoop.fs.Path(fs.getWorkingDirectory(), hadoopPath);
  }
  return hadoopPath.toUri().getScheme() != null && hadoopPath.toUri().getPath().isEmpty()
      ? ""
      : hadoopPath.toUri().getPath().substring(1);
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Is an absolute path (ie a slash relative path part)
 *  AND  a scheme is null AND  authority is null.
 */
public static boolean isAbsoluteAndSchemeAuthorityNull(Path path) {
 return (path.isAbsolute() &&
   path.toUri().getScheme() == null && path.toUri().getAuthority() == null);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public Path makeQualified(Path path) {
 // make sure that we just get the 
 // path component 
 Path fsPath = path;
 if (!path.isAbsolute()) {
  fsPath = new Path(archivePath, path);
 }
 URI tmpURI = fsPath.toUri();
 //change this to Har uri 
 return new Path(uri.getScheme(), harAuth, tmpURI.getPath());
}

代码示例来源:origin: apache/hive

public static Path makeAbsolute(FileSystem fileSystem, Path path) throws IOException {
 if (path.isAbsolute()) {
  return path;
 } else {
  return new Path(fileSystem.getWorkingDirectory(), path);
 }
}

代码示例来源:origin: apache/hive

@Override
public boolean isPathEncrypted(Path path) throws IOException {
 Path fullPath;
 if (path.isAbsolute()) {
  fullPath = path;
 } else {
  fullPath = path.getFileSystem(conf).makeQualified(path);
 }
 if(!"hdfs".equalsIgnoreCase(path.toUri().getScheme())) {
  return false;
 }
 return (getEncryptionZoneForPath(fullPath) != null);
}

代码示例来源:origin: apache/hive

public static String addUserHomeDirectoryIfApplicable(String origPathStr, String user)
 throws IOException, URISyntaxException {
 if(origPathStr == null || origPathStr.isEmpty()) {
  return "/user/" + user;
 }
 Path p = new Path(origPathStr);
 if(p.isAbsolute()) {
  return origPathStr;
 }
 if(p.toUri().getPath().isEmpty()) {
  //origPathStr="hdfs://host:99" for example
  return new Path(p.toUri().getScheme(), p.toUri().getAuthority(), "/user/" + user).toString();
 }
 //can't have relative path if there is scheme/authority
 return "/user/" + user + "/" + origPathStr;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

void checkNotRelative() {
 if (!isAbsolute() && toUri().getScheme() == null) {
  throw new HadoopIllegalArgumentException("Path is relative");
 }
}

代码示例来源:origin: apache/ignite

/**
 * Converts Hadoop path to local path.
 *
 * @param path Hadoop path.
 * @return Local path.
 */
File convert(Path path) {
  checkPath(path);
  if (path.isAbsolute())
    return new File(path.toUri().getPath());
  return new File(getWorkingDirectory().toUri().getPath(), path.toUri().getPath());
}

代码示例来源:origin: apache/ignite

/**
 * Convert Hadoop path into IGFS path.
 *
 * @param path Hadoop path.
 * @return IGFS path.
 */
@Nullable private IgfsPath convert(Path path) {
  if (path == null)
    return null;
  return path.isAbsolute() ? new IgfsPath(path.toUri().getPath()) :
    new IgfsPath(workingDir, path.toUri().getPath());
}

代码示例来源: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: apache/flink

@VisibleForTesting
  static org.apache.hadoop.fs.Path generateStagingTempFilePath(
      org.apache.hadoop.fs.FileSystem fs,
      org.apache.hadoop.fs.Path targetFile) throws IOException {

    checkArgument(targetFile.isAbsolute(), "targetFile must be absolute");

    final org.apache.hadoop.fs.Path parent = targetFile.getParent();
    final String name = targetFile.getName();

    checkArgument(parent != null, "targetFile must not be the root directory");

    while (true) {
      org.apache.hadoop.fs.Path candidate = new org.apache.hadoop.fs.Path(
          parent, "." + name + ".inprogress." + UUID.randomUUID().toString());
      if (!fs.exists(candidate)) {
        return candidate;
      }
    }
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Convert a path to a File. */
public File pathToFile(Path path) {
 checkPath(path);
 if (!path.isAbsolute()) {
  path = new Path(getWorkingDirectory(), path);
 }
 return new File(path.toUri().getPath());
}

代码示例来源:origin: apache/ignite

/**
 * Convert Hadoop path into IGFS path.
 *
 * @param path Hadoop path.
 * @return IGFS path.
 */
@Nullable private IgfsPath convert(@Nullable Path path) {
  if (path == null)
    return null;
  return path.isAbsolute() ? new IgfsPath(path.toUri().getPath()) :
    new IgfsPath(convert(workingDir), path.toUri().getPath());
}

相关文章