Class BufferedIOStatisticsInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.apache.hadoop.fs.statistics.BufferedIOStatisticsInputStream
All Implemented Interfaces:
Closeable, AutoCloseable, IOStatisticsSource, StreamCapabilities

public class BufferedIOStatisticsInputStream extends BufferedInputStream implements IOStatisticsSource, StreamCapabilities
An extension of BufferedInputStream which implements IOStatisticsSource and forwards requests for the IOStatistics to the wrapped stream. This should be used when any input stream needs buffering while allowing the inner stream to be a source of statistics. It also implements StreamCapabilities and forwards the probe to the inner stream, if possible.
  • Constructor Details

    • BufferedIOStatisticsInputStream

      public BufferedIOStatisticsInputStream(InputStream in)
      Buffer an input stream with the default buffer size of 8k.
      Parameters:
      in - input stream
    • BufferedIOStatisticsInputStream

      public BufferedIOStatisticsInputStream(InputStream in, int size)
      Buffer an input stream with the chosen buffer size.
      Parameters:
      in - input stream
      size - buffer size
  • Method Details

    • getIOStatistics

      public IOStatistics getIOStatistics()
      Return any IOStatistics offered by the inner stream.
      Specified by:
      getIOStatistics in interface IOStatisticsSource
      Returns:
      inner IOStatistics or null
    • hasCapability

      public boolean hasCapability(String capability)
      If the inner stream supports StreamCapabilities, forward the probe to it. Otherwise: return false.
      Specified by:
      hasCapability in interface StreamCapabilities
      Parameters:
      capability - string to query the stream support for.
      Returns:
      true if a capability is known to be supported.