當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSystem.listLocatedStatus方法代碼示例

本文整理匯總了Java中org.apache.hadoop.fs.FileSystem.listLocatedStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java FileSystem.listLocatedStatus方法的具體用法?Java FileSystem.listLocatedStatus怎麽用?Java FileSystem.listLocatedStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.fs.FileSystem的用法示例。


在下文中一共展示了FileSystem.listLocatedStatus方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addInputPathRecursively

import org.apache.hadoop.fs.FileSystem; //導入方法依賴的package包/類
/**
 * Add files in the input path recursively into the results.
 * @param result
 *          The List to store all files.
 * @param fs
 *          The FileSystem.
 * @param path
 *          The input path.
 * @param inputFilter
 *          The input filter that can be used to filter files/dirs. 
 * @throws IOException
 */
protected void addInputPathRecursively(List<FileStatus> result,
    FileSystem fs, Path path, PathFilter inputFilter) 
    throws IOException {
  RemoteIterator<LocatedFileStatus> iter = fs.listLocatedStatus(path);
  while (iter.hasNext()) {
    LocatedFileStatus stat = iter.next();
    if (inputFilter.accept(stat.getPath())) {
      if (stat.isDirectory()) {
        addInputPathRecursively(result, fs, stat.getPath(), inputFilter);
      } else {
        result.add(stat);
      }
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:FileInputFormat.java

示例2: testListLocatedFileStatus

import org.apache.hadoop.fs.FileSystem; //導入方法依賴的package包/類
@Test
public void testListLocatedFileStatus() throws IOException {
  final Path mockMount = new Path("mockfs://foo/user");
  final Path mockPath = new Path("/usermock");
  final Configuration conf = new Configuration();
  conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
  ConfigUtil.addLink(conf, mockPath.toString(), mockMount.toUri());
  FileSystem vfs = FileSystem.get(URI.create("viewfs:///"), conf);
  vfs.listLocatedStatus(mockPath);
  final FileSystem mockFs = ((MockFileSystem)mockMount.getFileSystem(conf))
      .getRawFileSystem();
  verify(mockFs).listLocatedStatus(new Path(mockMount.toUri().getPath()));
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:14,代碼來源:TestChRootedFileSystem.java

示例3: singleThreadedListStatus

import org.apache.hadoop.fs.FileSystem; //導入方法依賴的package包/類
private List<FileStatus> singleThreadedListStatus(JobConf job, Path[] dirs,
    PathFilter inputFilter, boolean recursive) throws IOException {
  List<FileStatus> result = new ArrayList<FileStatus>();
  List<IOException> errors = new ArrayList<IOException>();
  for (Path p: dirs) {
    FileSystem fs = p.getFileSystem(job); 
    FileStatus[] matches = fs.globStatus(p, inputFilter);
    if (matches == null) {
      errors.add(new IOException("Input path does not exist: " + p));
    } else if (matches.length == 0) {
      errors.add(new IOException("Input Pattern " + p + " matches 0 files"));
    } else {
      for (FileStatus globStat: matches) {
        if (globStat.isDirectory()) {
          RemoteIterator<LocatedFileStatus> iter =
              fs.listLocatedStatus(globStat.getPath());
          while (iter.hasNext()) {
            LocatedFileStatus stat = iter.next();
            if (inputFilter.accept(stat.getPath())) {
              if (recursive && stat.isDirectory()) {
                addInputPathRecursively(result, fs, stat.getPath(),
                    inputFilter);
              } else {
                result.add(stat);
              }
            }
          }
        } else {
          result.add(globStat);
        }
      }
    }
  }
  if (!errors.isEmpty()) {
    throw new InvalidInputException(errors);
  }
  return result;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:39,代碼來源:FileInputFormat.java

示例4: singleThreadedListStatus

import org.apache.hadoop.fs.FileSystem; //導入方法依賴的package包/類
private List<FileStatus> singleThreadedListStatus(JobContext job, Path[] dirs,
    PathFilter inputFilter, boolean recursive) throws IOException {
  List<FileStatus> result = new ArrayList<FileStatus>();
  List<IOException> errors = new ArrayList<IOException>();
  for (int i=0; i < dirs.length; ++i) {
    Path p = dirs[i];
    FileSystem fs = p.getFileSystem(job.getConfiguration()); 
    FileStatus[] matches = fs.globStatus(p, inputFilter);
    if (matches == null) {
      errors.add(new IOException("Input path does not exist: " + p));
    } else if (matches.length == 0) {
      errors.add(new IOException("Input Pattern " + p + " matches 0 files"));
    } else {
      for (FileStatus globStat: matches) {
        if (globStat.isDirectory()) {
          RemoteIterator<LocatedFileStatus> iter =
              fs.listLocatedStatus(globStat.getPath());
          while (iter.hasNext()) {
            LocatedFileStatus stat = iter.next();
            if (inputFilter.accept(stat.getPath())) {
              if (recursive && stat.isDirectory()) {
                addInputPathRecursively(result, fs, stat.getPath(),
                    inputFilter);
              } else {
                result.add(stat);
              }
            }
          }
        } else {
          result.add(globStat);
        }
      }
    }
  }

  if (!errors.isEmpty()) {
    throw new InvalidInputException(errors);
  }
  return result;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:41,代碼來源:FileInputFormat.java


注:本文中的org.apache.hadoop.fs.FileSystem.listLocatedStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。