Class BlockData

java.lang.Object
org.apache.hadoop.fs.impl.prefetch.BlockData

public final class BlockData extends Object
Holds information about blocks of data in a file.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockData(long fileSize, int blockSize)
    Constructs an instance of BlockData.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getBlockNumber(long offset)
    Gets the id of the block that contains the given absolute offset.
    int
    Gets the size of each block.
    long
    Gets the size of the associated file.
    int
    Gets the number of blocks in the associated file.
    int
    getRelativeOffset(int blockNumber, long offset)
    Gets the relative offset corresponding to the given block and the absolute offset.
    int
    getSize(int blockNumber)
    Gets the size of the given block.
    long
    getStartOffset(int blockNumber)
    Gets the start offset of the given block.
    org.apache.hadoop.fs.impl.prefetch.BlockData.State
    getState(int blockNumber)
    Gets the state of the given block.
     
    boolean
    isLastBlock(int blockNumber)
    Indicates whether the given block is the last block in the associated file.
    boolean
    isValidOffset(long offset)
    Indicates whether the given absolute offset is valid.
    void
    setState(int blockNumber, org.apache.hadoop.fs.impl.prefetch.BlockData.State blockState)
    Sets the state of the given block to the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getBlockSize

      public int getBlockSize()
      Gets the size of each block.
      Returns:
      the size of each block.
    • getFileSize

      public long getFileSize()
      Gets the size of the associated file.
      Returns:
      the size of the associated file.
    • getNumBlocks

      public int getNumBlocks()
      Gets the number of blocks in the associated file.
      Returns:
      the number of blocks in the associated file.
    • isLastBlock

      public boolean isLastBlock(int blockNumber)
      Indicates whether the given block is the last block in the associated file.
      Parameters:
      blockNumber - the id of the desired block.
      Returns:
      true if the given block is the last block in the associated file, false otherwise.
      Throws:
      IllegalArgumentException - if blockNumber is invalid.
    • getBlockNumber

      public int getBlockNumber(long offset)
      Gets the id of the block that contains the given absolute offset.
      Parameters:
      offset - the absolute offset to check.
      Returns:
      the id of the block that contains the given absolute offset.
      Throws:
      IllegalArgumentException - if offset is invalid.
    • getSize

      public int getSize(int blockNumber)
      Gets the size of the given block.
      Parameters:
      blockNumber - the id of the desired block.
      Returns:
      the size of the given block.
    • isValidOffset

      public boolean isValidOffset(long offset)
      Indicates whether the given absolute offset is valid.
      Parameters:
      offset - absolute offset in the file..
      Returns:
      true if the given absolute offset is valid, false otherwise.
    • getStartOffset

      public long getStartOffset(int blockNumber)
      Gets the start offset of the given block.
      Parameters:
      blockNumber - the id of the given block.
      Returns:
      the start offset of the given block.
      Throws:
      IllegalArgumentException - if blockNumber is invalid.
    • getRelativeOffset

      public int getRelativeOffset(int blockNumber, long offset)
      Gets the relative offset corresponding to the given block and the absolute offset.
      Parameters:
      blockNumber - the id of the given block.
      offset - absolute offset in the file.
      Returns:
      the relative offset corresponding to the given block and the absolute offset.
      Throws:
      IllegalArgumentException - if either blockNumber or offset is invalid.
    • getState

      public org.apache.hadoop.fs.impl.prefetch.BlockData.State getState(int blockNumber)
      Gets the state of the given block.
      Parameters:
      blockNumber - the id of the given block.
      Returns:
      the state of the given block.
      Throws:
      IllegalArgumentException - if blockNumber is invalid.
    • setState

      public void setState(int blockNumber, org.apache.hadoop.fs.impl.prefetch.BlockData.State blockState)
      Sets the state of the given block to the given value.
      Parameters:
      blockNumber - the id of the given block.
      blockState - the target state.
      Throws:
      IllegalArgumentException - if blockNumber is invalid.
    • getStateString

      public String getStateString()