Package org.apache.solr.common.util

## Class ZLibCompressor

- java.lang.Object
- - org.apache.solr.common.util.ZLibCompressor

All Implemented Interfaces:
  `Compressor`

    public class ZLibCompressor
    extends Object
    implements Compressor

### Constructor Summary

Constructors
`ZLibCompressor()`

### Method Summary

All Methods Instance Methods Concrete Methods
`byte[]` `compressBytes​(byte[] data)` Compresses bytes into compressed bytes using the compression implementation
`byte[]` `compressBytes​(byte[] data, int initialBufferCapacity)` Compresses bytes into compressed bytes using the compression implementation
`byte[]` `decompressBytes​(byte[] data)` Decompresses compressed bytes, returning the uncompressed data as a byte[]
`boolean` `isCompressedBytes​(byte[] data)` Check to determine if the data is compressed in the expected compression implementation

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

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

### Constructor Detail

#### ZLibCompressor

    public ZLibCompressor()

### Method Detail

#### isCompressedBytes

    public boolean isCompressedBytes​(byte[] data)

Check to determine if the data is compressed in the expected compression implementation

Uses the hex magic number for zlib compression '78 01' to check if the bytes are compressed

Specified by:
  `isCompressedBytes` in interface `Compressor`
Parameters:
  `data` - - the bytes to check for compression
Returns:
  true if the data is compressed in the expected compression implementation

#### decompressBytes

    public byte[] decompressBytes​(byte[] data)
                           throws Exception

Description copied from interface: `Compressor`
Decompresses compressed bytes, returning the uncompressed data as a byte[]

Specified by:
  `decompressBytes` in interface `Compressor`
Parameters:
  `data` - the input compressed data to decompress
Returns:
  the decompressed bytes
Throws:
  `Exception` - - The data is not compressed or the data is not compressed in the correct format

#### compressBytes

    public byte[] compressBytes​(byte[] data)

Description copied from interface: `Compressor`
Compresses bytes into compressed bytes using the compression implementation

Specified by:
  `compressBytes` in interface `Compressor`
Parameters:
  `data` - the input uncompressed data to be compressed
Returns:
  compressed bytes

#### compressBytes

    public byte[] compressBytes​(byte[] data,
                                int initialBufferCapacity)

Description copied from interface: `Compressor`
Compresses bytes into compressed bytes using the compression implementation

Specified by:
  `compressBytes` in interface `Compressor`
Parameters:
  `data` - the input uncompressed data to be compressed
  `initialBufferCapacity` - the initial capacity of the buffer storing the compressed data. It depends on the data type and the caller may know the expected average compression factor. If this initial capacity is smaller than 16, the buffer capacity will be 16 anyway.
Returns:
  compressed bytes