Class ICompressor.GZIPCompressor

    • Constructor Detail

      • GZIPCompressor

        public GZIPCompressor()
    • Method Detail

      • compress

        public byte[] compress​(byte[] data)
                        throws java.io.IOException
        Specified by:
        compress in interface ICompressor
        Throws:
        java.io.IOException
      • compress

        public byte[] compress​(byte[] data,
                               int offset,
                               int length)
                        throws java.io.IOException
        Description copied from interface: ICompressor
        abstract method of compress. this method has an important overhead due to the fact that it needs to allocate a byte array to compress into, and then needs to resize this buffer to the actual compressed length.
        Specified by:
        compress in interface ICompressor
        Returns:
        byte array of compressed data.
        Throws:
        java.io.IOException
      • compress

        public int compress​(byte[] data,
                            int offset,
                            int length,
                            byte[] compressed)
                     throws java.io.IOException
        Description copied from interface: ICompressor
        abstract method of compress.
        Specified by:
        compress in interface ICompressor
        Returns:
        byte length of compressed data.
        Throws:
        GZIPCompressOverflowException - if compressed byte array is too small.
        java.io.IOException
      • compress

        public int compress​(java.nio.ByteBuffer data,
                            java.nio.ByteBuffer compressed)
                     throws java.io.IOException
        Description copied from interface: ICompressor
        If the data is large, this function is better than byte[].
        Specified by:
        compress in interface ICompressor
        Parameters:
        data - MUST be DirectByteBuffer for Snappy.
        compressed - MUST be DirectByteBuffer for Snappy.
        Returns:
        byte length of compressed data.
        Throws:
        GZIPCompressOverflowException - if compressed ByteBuffer is too small.
        java.io.IOException
      • getMaxBytesForCompression

        public int getMaxBytesForCompression​(int uncompressedDataSize)
        Description copied from interface: ICompressor
        Get the maximum byte size needed for compressing data of the given byte size. For GZIP, this method is insecure and may cause GZIPCompressOverflowException
        Specified by:
        getMaxBytesForCompression in interface ICompressor
        Parameters:
        uncompressedDataSize - byte size of the data to compress
        Returns:
        maximum byte size of the compressed data