LocatedBlocks (Apache Hadoop HDFS Client 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.protocol, class: LocatedBlocks

Package org.apache.hadoop.hdfs.protocol

# Class LocatedBlocks

java.lang.Object
org.apache.hadoop.hdfs.protocol.LocatedBlocks

@Private @Evolving public class LocatedBlocks extends Object
Collection of blocks with their locations and the file length.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LocatedBlocks()`
  `LocatedBlocks(long flength, boolean isUnderConstuction, List<LocatedBlock> blks, LocatedBlock lastBlock, boolean isLastBlockCompleted, org.apache.hadoop.fs.FileEncryptionInfo feInfo, ErasureCodingPolicy ecPolicy)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `findBlock(long offset)`
  Find block containing specified offset.
  `LocatedBlock`
  `get(int index)`
  Get located block.
  `ErasureCodingPolicy`
  `getErasureCodingPolicy()`
  `org.apache.hadoop.fs.FileEncryptionInfo`
  `getFileEncryptionInfo()`
  `long`
  `getFileLength()`
  `static int`
  `getInsertIndex(int binSearchResult)`
  `LocatedBlock`
  `getLastLocatedBlock()`
  Get the last located block.
  `List<LocatedBlock>`
  `getLocatedBlocks()`
  Get located blocks.
  `void`
  `insertRange(int blockIdx, List<LocatedBlock> newBlocks)`
  `boolean`
  `isLastBlockComplete()`
  Is the last block completed?
  `boolean`
  `isUnderConstruction()`
  Return true if file was under construction when this LocatedBlocks was constructed, false otherwise.
  `int`
  `locatedBlockCount()`
  Get number of located blocks.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### LocatedBlocks

    public LocatedBlocks()

  - ### LocatedBlocks

    public LocatedBlocks(long flength, boolean isUnderConstuction, List<LocatedBlock> blks, LocatedBlock lastBlock, boolean isLastBlockCompleted, org.apache.hadoop.fs.FileEncryptionInfo feInfo, ErasureCodingPolicy ecPolicy)

- ## Method Details

  - ### getLocatedBlocks

    public List<LocatedBlock> getLocatedBlocks()
    Get located blocks.

  - ### getLastLocatedBlock

    public LocatedBlock getLastLocatedBlock()
    Get the last located block.

  - ### isLastBlockComplete

    public boolean isLastBlockComplete()
    Is the last block completed?

  - ### get

    public LocatedBlock get(int index)
    Get located block.

  - ### locatedBlockCount

    public int locatedBlockCount()
    Get number of located blocks.

  - ### getFileLength

    public long getFileLength()

  - ### isUnderConstruction

    public boolean isUnderConstruction()
    Return true if file was under construction when this LocatedBlocks was constructed, false otherwise.

  - ### getFileEncryptionInfo

    public org.apache.hadoop.fs.FileEncryptionInfo getFileEncryptionInfo()
    Returns:
      the FileEncryptionInfo for the LocatedBlocks

  - ### getErasureCodingPolicy

    public ErasureCodingPolicy getErasureCodingPolicy()
    Returns:
      The ECPolicy for ErasureCoded file, null otherwise.

  - ### findBlock

    public int findBlock(long offset)
    Find block containing specified offset.
    Returns:
      block if found, or null otherwise.

  - ### insertRange

    public void insertRange(int blockIdx, List<LocatedBlock> newBlocks)

  - ### getInsertIndex

    public static int getInsertIndex(int binSearchResult)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`