Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.LocatedFileStatus


            public RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f)
                    throws IOException
            {
                ImmutableList.Builder<LocatedFileStatus> list = ImmutableList.builder();
                for (FileStatus status : paths.get(f.toString())) {
                    list.add(new LocatedFileStatus(status, new BlockLocation[0]));
                }
                return remoteIterator(list.build().iterator());
            }

            @Override
View Full Code Here


      for (int i = 0; i < files.length; i++) {
        Path p = files[i];
        FileSystem fs = p.getFileSystem(job);
        FileStatus stat = fs.getFileStatus(p);
        if (stat.isDir()) {
          results[i] = new LocatedFileStatus(stat, null);
        } else {
          results[i] = new LocatedFileStatus(stat,
              fs.getFileBlockLocations(stat, 0, stat.getLen()));
        }
      }
      return results;
    }
View Full Code Here

        FileStatus stat = fs.getFileStatus(dir);
        if (stat.isDir()) {
          System.out.println("Directory " + dir);
          FileStatus[] files = fs.listStatus(dir);
          for (FileStatus file: files) {
            results.add(new LocatedFileStatus(file, getFileBlockLocations(fs, file)));
          }
        } else {
          results.add(new LocatedFileStatus(stat, getFileBlockLocations(fs, stat)));
        }
      }
      return results.toArray(new LocatedFileStatus[results.size()]);
    }
View Full Code Here

    private void doWalk(Path path, FileStatusCallback callback, AtomicLong taskCount, SettableFuture<Void> future)
    {
        try {
            RemoteIterator<LocatedFileStatus> iterator = listLocatedStatus(fileSystem, path);
            while (iterator.hasNext()) {
                LocatedFileStatus status = iterator.next();
                // ignore hidden files. Hive ignores files starting with _ and . as well.
                String fileName = status.getPath().getName();
                if (fileName.startsWith("_") || fileName.startsWith(".")) {
                    continue;
                }
                if (isDirectory(status)) {
                    recursiveWalk(status.getPath(), callback, taskCount, future);
                }
                else {
                    callback.process(status, status.getBlockLocations());
                }
                if (future.isDone()) {
                    return;
                }
            }
View Full Code Here

    private LocatedFileStatus createLocatedFileStatus(FileStatus status)
    {
        try {
            BlockLocation[] fakeLocation = getFileBlockLocations(status, 0, status.getLen());
            return new LocatedFileStatus(status, fakeLocation);
        }
        catch (IOException e) {
            throw propagate(e);
        }
    }
View Full Code Here

    private LocatedFileStatus createLocatedFileStatus(FileStatus status)
    {
        try {
            BlockLocation[] fakeLocation = getFileBlockLocations(status, 0, status.getLen());
            return new LocatedFileStatus(status, fakeLocation);
        }
        catch (IOException e) {
            throw propagate(e);
        }
    }
View Full Code Here

                throws IOException
        {
            ImmutableList.Builder<DirectoryEntry> list = ImmutableList.builder();
            RemoteIterator<LocatedFileStatus> iter = fileSystem.listLocatedStatus(path);
            while (iter.hasNext()) {
                LocatedFileStatus status = iter.next();
                if (isDirectory(status)) {
                    list.add(entryForDirectory(status));
                }
                else {
                    list.add(entryForFile(status, status.getBlockLocations()));
                }
            }
            return list.build();
        }
View Full Code Here

            public RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f)
                    throws IOException
            {
                ImmutableList.Builder<LocatedFileStatus> list = ImmutableList.builder();
                for (FileStatus status : paths.get(f.toString())) {
                    list.add(new LocatedFileStatus(status, new BlockLocation[0]));
                }
                return remoteIterator(list.build().iterator());
            }

            @Override
View Full Code Here

      if (fileStatus.isDirectory()) {
        RemoteIterator<LocatedFileStatus> iter = fs
            .listLocatedStatus(fileStatus.getPath());
        while (iter.hasNext()) {
          LocatedFileStatus stat = iter.next();
          if (inputFilter.accept(stat.getPath())) {
            if (recursive && stat.isDirectory()) {
              result.dirsNeedingRecursiveCalls.add(stat);
            } else {
              result.locatedFileStatuses.add(stat);
            }
          }
View Full Code Here

  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);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.fs.LocatedFileStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.