private LocatedFileStatus createLocatedFileStatus(FileStatus status) { try { BlockLocation[] fakeLocation = getFileBlockLocations(status, 0, status.getLen()); return new LocatedFileStatus(status, fakeLocation); } catch (IOException e) { throw new UncheckedIOException(e); } }
private static LocatedFileStatus locatedFileStatusWithNoBlocks(Path path) { return new LocatedFileStatus( 0L, false, 0, 0L, 0L, 0L, null, null, null, null, path, new BlockLocation[] {}); }
@Override public LocatedFileStatus next() throws IOException { if (!hasNext()) { throw new NoSuchElementException("No more entries in " + f); } FileStatus result = stats[i++]; // for files, use getBlockLocations(FileStatus, int, int) to avoid // calling getFileStatus(Path) to load the FileStatus again BlockLocation[] locs = result.isFile() ? getFileBlockLocations(result, 0, result.getLen()) : null; return new LocatedFileStatus(result, locs); } };
@Override public LocatedFileStatus next() throws IOException { if (!hasNext()) { throw new NoSuchElementException("No more entry in " + f); } FileStatus result = itor.next(); BlockLocation[] locs = null; if (result.isFile()) { locs = getFileBlockLocations( result.getPath(), 0, result.getLen()); } return new LocatedFileStatus(result, locs); } };
private LocatedFileStatus createLocatedDirectory(Path dir) throws IOException { FileStatus fileStatus = createDirectory(dir); return new LocatedFileStatus(fileStatus, getFileBlockLocationsImpl(fileStatus, 0, fileStatus.getLen(), false)); }
private LocatedFileStatus createLocatedStatus(MockFile file) throws IOException { FileStatus fileStatus = createStatus(file); return new LocatedFileStatus(fileStatus, getFileBlockLocationsImpl(fileStatus, 0, fileStatus.getLen(), false)); }
private LocatedFileStatus createLocatedStatus(MockFile file) throws IOException { FileStatus fileStatus = createStatus(file); return new LocatedFileStatus(fileStatus, getFileBlockLocationsImpl(fileStatus, 0, fileStatus.getLen(), false)); }
private LocatedFileStatus createLocatedDirectory(Path dir) throws IOException { FileStatus fileStatus = createDirectory(dir); return new LocatedFileStatus(fileStatus, getFileBlockLocationsImpl(fileStatus, 0, fileStatus.getLen(), false)); }
private static LocatedFileStatus locatedFileStatus(Path path) { return new LocatedFileStatus( 0L, false, 0, 0L, 0L, 0L, null, null, null, null, path, new BlockLocation[] {new BlockLocation()}); }
/** * Build a {@link LocatedFileStatus} from a {@link FileStatus} instance. * @param status file status * @return a located status with block locations set up from this FS * @throws IOException IO Problems */ LocatedFileStatus toLocatedFileStatus(FileStatus status) throws IOException { return new LocatedFileStatus(status, null); }
private LocatedFileStatus createLocatedFileStatus(FileStatus status) { try { BlockLocation[] fakeLocation = getFileBlockLocations(status, 0, status.getLen()); return new LocatedFileStatus(status, fakeLocation); } catch (IOException e) { throw Throwables.propagate(e); } }
@Override public LocatedFileStatus next() throws IOException { FileStatus file = iterator.next(); BlockLocation[] blocks = null; if (!file.isDir()) { blocks = fs.getFileBlockLocations(file, 0, file.getLen()); } return new LocatedFileStatus(file, blocks); } };
@Override public LocatedFileStatus next() throws IOException { if (!hasNext()) { throw new NoSuchElementException("No more entry in " + src); } FileStatus result = stats[i++]; BlockLocation[] locs = result.isDir() ? null : getBlockLocations( result.getPath().toUri().getPath(), 0, result.getLen()); return new LocatedFileStatus(result, locs); } };
@Override public LocatedFileStatus next() throws IOException { if (hasNext()) { LocatedFileStatus s = new LocatedFileStatus(fileStatus, fileStatus.isFile() ? locations : null); hasNext = false; return s; } else { throw new NoSuchElementException(); } } };
@Override public LocatedFileStatus next() throws IOException { if (hasNext()) { FileStatus status = batchIterator.next(); BlockLocation[] locations = fs.getFileBlockLocations(status, 0, status.getLen()); return new LocatedFileStatus( status, status.isFile() ? locations : null); } else { throw new NoSuchElementException(); } }
@Override public LocatedFileStatus next() throws IOException { if (!hasNext()) { throw new NoSuchElementException("No more entry in " + f); } FileStatus result = stats[i++]; BlockLocation[] locs = result.isDir() ? null : getFileBlockLocations(result, 0, result.getLen()); return new LocatedFileStatus(result, locs); } };
public final LocatedFileStatus makeQualifiedLocated(URI defaultUri, Path path) { return new LocatedFileStatus(getLen(), isDir(), getReplication(), getBlockSize(), getModificationTime(), getAccessTime(), getPermission(), getOwner(), getGroup(), isSymlink() ? new Path(getSymlink()) : null, (getFullPath(path)).makeQualified( defaultUri, null), // fully-qualify path DFSUtil.locatedBlocks2Locations(getBlockLocations())); } }
public final LocatedFileStatus makeQualifiedLocated(URI defaultUri, Path path) { return new LocatedFileStatus(getLen(), isDir(), getReplication(), getBlockSize(), getModificationTime(), getAccessTime(), getPermission(), getOwner(), getGroup(), isSymlink() ? new Path(getSymlink()) : null, (getFullPath(path)).makeQualified( defaultUri, null), // fully-qualify path DFSUtil.locatedBlocks2Locations(getBlockLocations())); } }
@Override public RemoteIterator<LocatedFileStatus> listFiles(Path f, boolean recursive) throws FileNotFoundException, IOException { final String container = getContainerName(f); return RemoteIterators.transform( getFileSystemForPath(f).fs().listFiles(pathWithoutContainer(f), recursive), t -> new LocatedFileStatus(ContainerFileSystem.transform(t, container), t.getBlockLocations()) ); }
@Override protected RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f, final PathFilter filter) throws FileNotFoundException, IOException { final String container = getContainerName(f); final PathFilter alteredFilter = (path) -> { return filter.accept(transform(path, container)); }; return RemoteIterators.transform( ListAccessor.listLocatedFileStatus(getFileSystemForPath(f).fs(), pathWithoutContainer(f), alteredFilter), t -> new LocatedFileStatus(ContainerFileSystem.transform(t, container), t.getBlockLocations()) ); }