/** * Creates a new input stream that decompresses streams compressed * using the LZ4 frame format. * @param in the InputStream from which to read the compressed data * @param decompressConcatenated if true, decompress until the end * of the input; if false, stop after the first LZ4 frame * and leave the input position to point to the next byte * after the frame stream * @throws IOException if reading fails */ public FramedLZ4CompressorInputStream(InputStream in, boolean decompressConcatenated) throws IOException { this.in = new CountingInputStream(in); this.decompressConcatenated = decompressConcatenated; init(true); }
private void nextBlock() throws IOException { maybeFinishCurrentBlock(); long len = ByteUtils.fromLittleEndian(supplier, 4); boolean uncompressed = (len & UNCOMPRESSED_FLAG_MASK) != 0; int realLen = (int) (len & (~UNCOMPRESSED_FLAG_MASK)); if (realLen == 0) { verifyContentChecksum(); if (!decompressConcatenated) { endReached = true; } else { init(false); } return; } InputStream capped = new BoundedInputStream(in, realLen); if (expectBlockChecksum) { capped = new ChecksumCalculatingInputStream(blockHash, capped); } if (uncompressed) { inUncompressed = true; currentBlock = capped; } else { inUncompressed = false; BlockLZ4CompressorInputStream s = new BlockLZ4CompressorInputStream(capped); if (expectBlockDependency) { s.prefill(blockDependencyBuffer); } currentBlock = s; } }
/** * Creates a new input stream that decompresses streams compressed * using the LZ4 frame format. * @param in the InputStream from which to read the compressed data * @param decompressConcatenated if true, decompress until the end * of the input; if false, stop after the first LZ4 frame * and leave the input position to point to the next byte * after the frame stream * @throws IOException if reading fails */ public FramedLZ4CompressorInputStream(InputStream in, boolean decompressConcatenated) throws IOException { this.in = in; this.decompressConcatenated = decompressConcatenated; init(true); }
private void nextBlock() throws IOException { maybeFinishCurrentBlock(); long len = ByteUtils.fromLittleEndian(supplier, 4); boolean uncompressed = (len & UNCOMPRESSED_FLAG_MASK) != 0; int realLen = (int) (len & (~UNCOMPRESSED_FLAG_MASK)); if (realLen == 0) { verifyContentChecksum(); if (!decompressConcatenated) { endReached = true; } else { init(false); } return; } InputStream capped = new BoundedInputStream(in, realLen); if (expectBlockChecksum) { capped = new ChecksumCalculatingInputStream(blockHash, capped); } if (uncompressed) { inUncompressed = true; currentBlock = capped; } else { inUncompressed = false; BlockLZ4CompressorInputStream s = new BlockLZ4CompressorInputStream(capped); if (expectBlockDependency) { s.prefill(blockDependencyBuffer); } currentBlock = s; } }