Module datarush.commons
Class BZip2CompressorInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.compressors.CompressorInputStream
com.pervasive.datarush.io.compression.bzip2.BZip2CompressorInputStream
- All Implemented Interfaces:
BZip2Constants,Closeable,AutoCloseable
public class BZip2CompressorInputStream
extends org.apache.commons.compress.compressors.CompressorInputStream
implements BZip2Constants
An input stream that decompresses from the BZip2 format to be read as any
other stream.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface com.pervasive.datarush.io.compression.bzip2.BZip2Constants
BASEBLOCKSIZE, G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, N_GROUPS, N_ITERS, NUM_OVERSHOOT_BYTES, RUNA, RUNB -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longGet the current byte position with the raw input data stream.booleanInitialize the next compression block.static booleanmatches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.intread()intread(byte[] dest, int offs, int len) booleanskipToBlock(long startOffset, long endOffset) Skip from the current raw input stream position to the start of the split boundary defined by the given start offset and end offset.Methods inherited from class org.apache.commons.compress.compressors.CompressorInputStream
count, count, getBytesRead, getCount, getUncompressedCount, pushedBackBytesMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
BZip2CompressorInputStream
Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. This doesn't suppprt decompressing concatenated .bz2 files.- Throws:
IOException- if the stream content is malformed or an I/O error occurs.NullPointerException- ifin == null
-
BZip2CompressorInputStream
public BZip2CompressorInputStream(InputStream in, BZip2CompressorInputStream.ReadMode readMode) throws IOException Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.- Parameters:
in- the InputStream from which this object should be createddecompressConcatenated- if true, decompress until the end of the input; if false, stop after the first .bz2 stream and leave the input position to point to the next byte after the .bz2 stream- Throws:
IOException- if the stream content is malformed or an I/O error occurs.NullPointerException- ifin == null
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
initBlock
Initialize the next compression block. If at end of stream (the EOS marker) then determine if a concatenated bzip2 stream follows.- Returns:
- true if at beginning of next block; false if EOS encountered
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
matches
public static boolean matches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.- Parameters:
signature- the bytes to checklength- the number of bytes to check- Returns:
- true, if this stream is a bzip2 compressed stream, false otherwise
- Since:
- 1.1
-
skipToBlock
Skip from the current raw input stream position to the start of the split boundary defined by the given start offset and end offset. Once positioned at the start of the split, search for the magic marker that indicates the start of a compression block. Once found, cache the data read from the raw input stream into a byte buffer for processing.- Parameters:
startOffset- start byte offset of the data splitendOffset- end byte offset of the data split- Throws:
IOException- thrown if any I/O errors occur
-
getPosition
public long getPosition()Get the current byte position with the raw input data stream. This position can be used to determine if the raw stream has crossed a split boundary or not.- Returns:
- byte position with the raw data stream
-