FileRange (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.fs, interface: FileRange

Package org.apache.hadoop.fs

# Interface FileRange

All Known Implementing Classes:
  `CombinedFileRange`, `FileRangeImpl`

public interface FileRange
A byte range of a file. This is used for the asynchronous gather read API of `PositionedReadable.readVectored(java.util.List<? extends org.apache.hadoop.fs.FileRange>, java.util.function.IntFunction<java.nio.ByteBuffer>)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static FileRange`
  `createFileRange(long offset, int length)`
  Factory method to create a FileRange object.
  `static FileRange`
  `createFileRange(long offset, int length, Object reference)`
  Factory method to create a FileRange object.
  `CompletableFuture<ByteBuffer>`
  `getData()`
  Get the future data for this range.
  `int`
  `getLength()`
  Get the length of the range.
  `long`
  `getOffset()`
  Get the starting offset of the range.
  `Object`
  `getReference()`
  Get any reference passed in to the file range constructor.
  `void`
  `setData(CompletableFuture<ByteBuffer> data)`
  Set a future for this range's data.

- ## Method Details

  - ### getOffset

    long getOffset()
    Get the starting offset of the range.
    Returns:
      the byte offset of the start

  - ### getLength

    int getLength()
    Get the length of the range.
    Returns:
      the number of bytes in the range.

  - ### getData

    CompletableFuture<ByteBuffer> getData()
    Get the future data for this range.
    Returns:
      the future for the `ByteBuffer` that contains the data

  - ### setData

    void setData(CompletableFuture<ByteBuffer> data)
    Set a future for this range's data. This method is called by `PositionedReadable.readVectored(java.util.List<? extends org.apache.hadoop.fs.FileRange>, java.util.function.IntFunction<java.nio.ByteBuffer>)` to store the data for the user to pick up later via `getData()`.
    Parameters:
      `data` - the future of the ByteBuffer that will have the data

  - ### getReference

    Object getReference()
    Get any reference passed in to the file range constructor. This is not used by any implementation code; it is to help bind this API to libraries retrieving multiple stripes of data in parallel.
    Returns:
      a reference or null.

  - ### createFileRange

    static FileRange createFileRange(long offset, int length)
    Factory method to create a FileRange object.
    Parameters:
      `offset` - starting offset of the range.
      `length` - length of the range.
    Returns:
      a new instance of FileRangeImpl.

  - ### createFileRange

    static FileRange createFileRange(long offset, int length, Object reference)
    Factory method to create a FileRange object.
    Parameters:
      `offset` - starting offset of the range.
      `length` - length of the range.
      `reference` - nullable reference to store in the range.
    Returns:
      a new instance of FileRangeImpl.