Class ZStandardDecompressor

java.lang.Object
org.apache.hadoop.io.compress.zstd.ZStandardDecompressor
All Implemented Interfaces:
Decompressor
Direct Known Subclasses:
ZStandardDecompressor.ZStandardDirectDecompressor

public class ZStandardDecompressor extends Object implements Decompressor
A Decompressor based on the zStandard compression algorithm. https://github.com/facebook/zstd
  • Constructor Details

    • ZStandardDecompressor

      public ZStandardDecompressor()
    • ZStandardDecompressor

      public ZStandardDecompressor(int bufferSize)
      Creates a new decompressor.
      Parameters:
      bufferSize - bufferSize.
  • Method Details

    • isNativeCodeLoaded

      public static boolean isNativeCodeLoaded()
    • getRecommendedBufferSize

      public static int getRecommendedBufferSize()
    • setInput

      public void setInput(byte[] b, int off, int len)
      Description copied from interface: Decompressor
      Sets input data for decompression. This should be called if and only if Decompressor.needsInput() returns true indicating that more input data is required. (Both native and non-native versions of various Decompressors require that the data passed in via b[] remain unmodified until the caller is explicitly notified--via Decompressor.needsInput()--that the buffer may be safely modified. With this requirement, an extra buffer-copy can be avoided.)
      Specified by:
      setInput in interface Decompressor
      Parameters:
      b - Input data
      off - Start offset
      len - Length
    • setDictionary

      public void setDictionary(byte[] b, int off, int len)
      Description copied from interface: Decompressor
      Sets preset dictionary for compression. A preset dictionary is used when the history buffer can be predetermined.
      Specified by:
      setDictionary in interface Decompressor
      Parameters:
      b - Dictionary data bytes
      off - Start offset
      len - Length
    • needsInput

      public boolean needsInput()
      Description copied from interface: Decompressor
      Returns true if the input data buffer is empty and Decompressor.setInput(byte[], int, int) should be called to provide more input.
      Specified by:
      needsInput in interface Decompressor
      Returns:
      true if the input data buffer is empty and Decompressor.setInput(byte[], int, int) should be called in order to provide more input.
    • needsDictionary

      public boolean needsDictionary()
      Description copied from interface: Decompressor
      Returns true if a preset dictionary is needed for decompression.
      Specified by:
      needsDictionary in interface Decompressor
      Returns:
      true if a preset dictionary is needed for decompression
    • finished

      public boolean finished()
      Description copied from interface: Decompressor
      Returns true if the end of the decompressed data output stream has been reached. Indicates a concatenated data stream when finished() returns true and Decompressor.getRemaining() returns a positive value. finished() will be reset with the Decompressor.reset() method.
      Specified by:
      finished in interface Decompressor
      Returns:
      true if the end of the decompressed data output stream has been reached.
    • decompress

      public int decompress(byte[] b, int off, int len) throws IOException
      Description copied from interface: Decompressor
      Fills specified buffer with uncompressed data. Returns actual number of bytes of uncompressed data. A return value of 0 indicates that Decompressor.needsInput() should be called in order to determine if more input data is required.
      Specified by:
      decompress in interface Decompressor
      Parameters:
      b - Buffer for the uncompressed data
      off - Start offset of the data
      len - Size of the buffer
      Returns:
      The actual number of bytes of uncompressed data.
      Throws:
      IOException - raised on errors performing I/O.
    • getRemaining

      public int getRemaining()

      Returns the number of bytes remaining in the input buffers; normally called when finished() is true to determine amount of post-stream data.

      Specified by:
      getRemaining in interface Decompressor
      Returns:
      the total (non-negative) number of unprocessed bytes in input
    • reset

      public void reset()
      Resets everything including the input buffers (user and direct).
      Specified by:
      reset in interface Decompressor
    • end

      public void end()
      Description copied from interface: Decompressor
      Closes the decompressor and discards any unprocessed input.
      Specified by:
      end in interface Decompressor
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object