Class BlockGunzipper

java.lang.Object
htsjdk.samtools.util.BlockGunzipper

public class BlockGunzipper extends Object
Alternative to GZIPInputStream, for decompressing GZIP blocks that are already loaded into a byte[]. The main advantage is that this object can be used over and over again to decompress many blocks, whereas a new GZIPInputStream and ByteArrayInputStream would otherwise need to be created for each block to be decompressed. This code requires that the GZIP header conform to the GZIP blocks written to BAM files, with a specific subfield and no other optional stuff.
  • Method Details

    • setDefaultInflaterFactory

      public static void setDefaultInflaterFactory(InflaterFactory inflaterFactory)
      Sets the default InflaterFactory that will be used for all instances unless specified otherwise in the constructor. If this method is not called the default is a factory that will create the JDK Inflater.
      Parameters:
      inflaterFactory - non-null default factory.
    • getDefaultInflaterFactory

      public static InflaterFactory getDefaultInflaterFactory()
    • setCheckCrcs

      public void setCheckCrcs(boolean check)
      Allows the caller to decide whether or not to check CRCs on when uncompressing blocks.
    • unzipBlock

      public int unzipBlock(byte[] uncompressedBlock, byte[] compressedBlock, int compressedLength)
      Decompress GZIP-compressed data
      Parameters:
      uncompressedBlock - must be big enough to hold decompressed output.
      compressedBlock - compressed data starting at offset 0
      compressedLength - size of compressed data, possibly less than the size of the buffer.
      Returns:
      the uncompressed data size.
    • unzipBlock

      public int unzipBlock(byte[] uncompressedBlock, int uncompressedBlockOffset, byte[] compressedBlock, int compressedBlockOffset, int compressedLength)
      Decompress GZIP-compressed data
      Parameters:
      uncompressedBlock - must be big enough to hold decompressed output.
      uncompressedBlockOffset - the offset into uncompressedBlock.
      compressedBlock - compressed data starting at offset 0.
      compressedBlock - the offset into the compressed data.
      compressedLength - size of compressed data, possibly less than the size of the buffer.
      Returns:
      the uncompressed data size.