Class ZstdCompressor

java.lang.Object
org.opensearch.compress.ZstdCompressor
All Implemented Interfaces:
org.opensearch.core.compress.Compressor

public class ZstdCompressor extends Object implements org.opensearch.core.compress.Compressor
Compressor implementation based on the ZSTD compression algorithm.
Opensearch.api:
- registered name requires BWC support
Opensearch.experimental:
- class methods might change
  • Field Details

    • NAME

      @PublicApi(since="2.10.0") public static final String NAME
      The name to register the compressor by
      See Also:
      Opensearch.api:
      - requires BWC support
  • Constructor Details

    • ZstdCompressor

      public ZstdCompressor()
  • Method Details

    • isCompressed

      public boolean isCompressed(org.opensearch.core.common.bytes.BytesReference bytes)
      Compares the given bytes with the HEADER of a compressed stream
      Specified by:
      isCompressed in interface org.opensearch.core.compress.Compressor
      Parameters:
      bytes - the bytes to compare to (HEADER)
      Returns:
      true if the bytes are the HEADER, false otherwise
    • headerLength

      public int headerLength()
      Returns the length of the HEADER
      Specified by:
      headerLength in interface org.opensearch.core.compress.Compressor
      Returns:
      the HEADER length
    • threadLocalInputStream

      public InputStream threadLocalInputStream(InputStream in) throws IOException
      Returns a new ZstdInputStreamNoFinalizer from the given compressed InputStream
      Specified by:
      threadLocalInputStream in interface org.opensearch.core.compress.Compressor
      Parameters:
      in - the compressed InputStream
      Returns:
      a new ZstdInputStreamNoFinalizer from the given compressed InputStream
      Throws:
      IOException - if an I/O error occurs
      IllegalArgumentException - if the input stream is not compressed with ZSTD
    • threadLocalOutputStream

      public OutputStream threadLocalOutputStream(OutputStream out) throws IOException
      Returns a new ZstdOutputStreamNoFinalizer from the given OutputStream
      Specified by:
      threadLocalOutputStream in interface org.opensearch.core.compress.Compressor
      Parameters:
      out - the OutputStream
      Returns:
      a new ZstdOutputStreamNoFinalizer from the given OutputStream
      Throws:
      IOException - if an I/O error occurs
    • uncompress

      public org.opensearch.core.common.bytes.BytesReference uncompress(org.opensearch.core.common.bytes.BytesReference bytesReference) throws IOException
      Always throws an UnsupportedOperationException as ZSTD compression is supported only for snapshotting
      Specified by:
      uncompress in interface org.opensearch.core.compress.Compressor
      Parameters:
      bytesReference - a reference to the bytes to uncompress
      Returns:
      always throws an exception
      Throws:
      UnsupportedOperationException - if the method is called
      IOException - is never thrown
    • compress

      public org.opensearch.core.common.bytes.BytesReference compress(org.opensearch.core.common.bytes.BytesReference bytesReference) throws IOException
      Always throws an UnsupportedOperationException as ZSTD compression is supported only for snapshotting
      Specified by:
      compress in interface org.opensearch.core.compress.Compressor
      Parameters:
      bytesReference - a reference to the bytes to compress
      Returns:
      always throws an exception
      Throws:
      UnsupportedOperationException - if the method is called
      IOException