Class LocatedFileStatus

java.lang.Object
org.apache.hadoop.fs.FileStatus
org.apache.hadoop.fs.LocatedFileStatus
All Implemented Interfaces:
ObjectInputValidation, Serializable, Comparable<Object>, Writable

@Public @Evolving public class LocatedFileStatus extends FileStatus
This class defines a FileStatus that includes a file's block locations.
See Also:
  • Constructor Details

    • LocatedFileStatus

      public LocatedFileStatus()
    • LocatedFileStatus

      public LocatedFileStatus(FileStatus stat, BlockLocation[] locations)
      Constructor
      Parameters:
      stat - a file status
      locations - a file's block locations
    • LocatedFileStatus

      @Deprecated public LocatedFileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path, BlockLocation[] locations)
      Deprecated.
      Constructor
      Parameters:
      length - a file's length
      isdir - if the path is a directory
      block_replication - the file's replication factor
      blocksize - a file's block size
      modification_time - a file's modification time
      access_time - a file's access time
      permission - a file's permission
      owner - a file's owner
      group - a file's group
      symlink - symlink if the path is a symbolic link
      path - the path's qualified name
      locations - a file's block locations
    • LocatedFileStatus

      public LocatedFileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path, boolean hasAcl, boolean isEncrypted, boolean isErasureCoded, BlockLocation[] locations)
      Constructor.
      Parameters:
      length - a file's length
      isdir - if the path is a directory
      block_replication - the file's replication factor
      blocksize - a file's block size
      modification_time - a file's modification time
      access_time - a file's access time
      permission - a file's permission
      owner - a file's owner
      group - a file's group
      symlink - symlink if the path is a symbolic link
      path - the path's qualified name
      hasAcl - entity has associated ACLs
      isEncrypted - entity is encrypted
      isErasureCoded - entity is erasure coded
      locations - a file's block locations
    • LocatedFileStatus

      public LocatedFileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path, Set<FileStatus.AttrFlags> attr, BlockLocation[] locations)
      Constructor.
      Parameters:
      length - a file's length
      isdir - if the path is a directory
      block_replication - the file's replication factor
      blocksize - a file's block size
      modification_time - a file's modification time
      access_time - a file's access time
      permission - a file's permission
      owner - a file's owner
      group - a file's group
      symlink - symlink if the path is a symbolic link
      path - the path's qualified name
      attr - Attribute flags (See FileStatus.AttrFlags).
      locations - a file's block locations
  • Method Details

    • getBlockLocations

      public BlockLocation[] getBlockLocations()
      Get the file's block locations In HDFS, the returned BlockLocation will have different formats for replicated and erasure coded file. Please refer to FileSystem.getFileBlockLocations(FileStatus, long, long) for more details.
      Returns:
      the file's block locations
    • setBlockLocations

      protected void setBlockLocations(BlockLocation[] locations)
      Hook for subclasses to lazily set block locations. The locations field should be null before this is called.
      Parameters:
      locations - Block locations for this instance.
    • compareTo

      public int compareTo(FileStatus o)
      Compare this FileStatus to another FileStatus
      Overrides:
      compareTo in class FileStatus
      Parameters:
      o - the FileStatus to be compared.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • equals

      public boolean equals(Object o)
      Compare if this object is equal to another object
      Overrides:
      equals in class FileStatus
      Parameters:
      o - the object to be compared.
      Returns:
      true if two file status has the same path name; false if not.
    • hashCode

      public int hashCode()
      Returns a hash code value for the object, which is defined as the hash code of the path name.
      Overrides:
      hashCode in class FileStatus
      Returns:
      a hash code value for the path name.