ReadaheadPool (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io, class: ReadaheadPool

Package org.apache.hadoop.io

# Class ReadaheadPool

java.lang.Object
org.apache.hadoop.io.ReadaheadPool

@Private @Evolving public class ReadaheadPool extends Object
Manages a pool of threads which can issue readahead requests on file descriptors.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `ReadaheadPool.ReadaheadRequest`
  An outstanding readahead request that has been submitted to the pool.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ReadaheadPool`
  `getInstance()`
  `ReadaheadPool.ReadaheadRequest`
  `readaheadStream(String identifier, FileDescriptor fd, long curPos, long readaheadLength, long maxOffsetToRead, ReadaheadPool.ReadaheadRequest lastReadahead)`
  Issue a request to readahead on the given file descriptor.
  `static void`
  `resetInstance()`
  `ReadaheadPool.ReadaheadRequest`
  `submitReadahead(String identifier, FileDescriptor fd, long off, long len)`
  Submit a request to readahead on the given file descriptor.

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

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

- ## Method Details

  - ### getInstance

    public static ReadaheadPool getInstance()
    Returns:
      Return the singleton instance for the current process.

  - ### resetInstance

    @VisibleForTesting public static void resetInstance()

  - ### readaheadStream

    public ReadaheadPool.ReadaheadRequest readaheadStream(String identifier, FileDescriptor fd, long curPos, long readaheadLength, long maxOffsetToRead, ReadaheadPool.ReadaheadRequest lastReadahead)
    Issue a request to readahead on the given file descriptor.
    Parameters:
      `identifier` - a textual identifier that will be used in error messages (e.g. the file name)
      `fd` - the file descriptor to read ahead
      `curPos` - the current offset at which reads are being issued
      `readaheadLength` - the configured length to read ahead
      `maxOffsetToRead` - the maximum offset that will be readahead (useful if, for example, only some segment of the file is requested by the user). Pass `Long.MAX_VALUE` to allow readahead to the end of the file.
      `lastReadahead` - the result returned by the previous invocation of this function on this file descriptor, or null if this is the first call
    Returns:
      an object representing this outstanding request, or null if no readahead was performed

  - ### submitReadahead

    public ReadaheadPool.ReadaheadRequest submitReadahead(String identifier, FileDescriptor fd, long off, long len)
    Submit a request to readahead on the given file descriptor.
    Parameters:
      `identifier` - a textual identifier used in error messages, etc.
      `fd` - the file descriptor to readahead
      `off` - the offset at which to start the readahead
      `len` - the number of bytes to read
    Returns:
      an object representing this pending request