Interface ICompressor

    • Method Detail

      • getCompressor

        static ICompressor getCompressor​(java.lang.String name)
      • getCompressor

        static ICompressor getCompressor​(CompressionType name)
        get Compressor according to CompressionType.
        Parameters:
        name - CompressionType
        Returns:
        the Compressor of specified CompressionType
      • compress

        byte[] compress​(byte[] data)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        byte[] compress​(byte[] data,
                        int offset,
                        int length)
                 throws java.io.IOException
        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.
        Returns:
        byte array of compressed data.
        Throws:
        java.io.IOException
      • compress

        int compress​(byte[] data,
                     int offset,
                     int length,
                     byte[] compressed)
              throws java.io.IOException
        abstract method of compress.
        Returns:
        byte length of compressed data.
        Throws:
        java.io.IOException
      • compress

        int compress​(java.nio.ByteBuffer data,
                     java.nio.ByteBuffer compressed)
              throws java.io.IOException
        If the data is large, this function is better than byte[].
        Parameters:
        data - MUST be DirectByteBuffer for Snappy.
        compressed - MUST be DirectByteBuffer for Snappy.
        Returns:
        byte length of compressed data.
        Throws:
        java.io.IOException
      • getMaxBytesForCompression

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