Class AbstractCompressionCodec

java.lang.Object
org.apache.arrow.vector.compression.AbstractCompressionCodec
All Implemented Interfaces:
CompressionCodec
Direct Known Subclasses:
Lz4CompressionCodec, ZstdCompressionCodec

public abstract class AbstractCompressionCodec extends Object implements CompressionCodec
The base class for concrete compression codecs, providing common logic for all compression codecs.
  • Constructor Details

    • AbstractCompressionCodec

      public AbstractCompressionCodec()
  • Method Details

    • compress

      public ArrowBuf compress(BufferAllocator allocator, ArrowBuf uncompressedBuffer)
      Description copied from interface: CompressionCodec
      Compress a buffer.
      Specified by:
      compress in interface CompressionCodec
      Parameters:
      allocator - the allocator for allocating memory for compressed buffer.
      uncompressedBuffer - the buffer to compress. Implementation of this method should take care of releasing this buffer.
      Returns:
      the compressed buffer
    • decompress

      public ArrowBuf decompress(BufferAllocator allocator, ArrowBuf compressedBuffer)
      Description copied from interface: CompressionCodec
      Decompress a buffer.
      Specified by:
      decompress in interface CompressionCodec
      Parameters:
      allocator - the allocator for allocating memory for decompressed buffer.
      compressedBuffer - the buffer to be decompressed. Implementation of this method should take care of releasing this buffer.
      Returns:
      the decompressed buffer.
    • writeUncompressedLength

      protected void writeUncompressedLength(ArrowBuf compressedBuffer, long uncompressedLength)
    • readUncompressedLength

      protected long readUncompressedLength(ArrowBuf compressedBuffer)
    • doCompress

      protected abstract ArrowBuf doCompress(BufferAllocator allocator, ArrowBuf uncompressedBuffer)
      The method that actually performs the data compression. The layout of the returned compressed buffer is the compressed data, plus 8 bytes reserved at the beginning of the buffer for the uncompressed data size.

      Please note that this method is not responsible for releasing the uncompressed buffer.

    • doDecompress

      protected abstract ArrowBuf doDecompress(BufferAllocator allocator, ArrowBuf compressedBuffer)
      The method that actually performs the data decompression. The layout of the compressed buffer is the compressed data, plus 8 bytes at the beginning of the buffer storing the uncompressed data size.

      Please note that this method is not responsible for releasing the compressed buffer.