java.lang.Object
java.io.InputStream
java.io.FilterInputStream
kala.compress.archivers.dump.TapeInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Filter stream that mimics a physical tape drive capable of compressing the data stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private intprivate longprivate intprivate booleanprivate intprivate static final intFields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Close the input stream.longGets number of bytes read.byte[]peek()Peek at the next record from the input stream and return the data.intread()intread(byte[] b, int off, int len) private voidreadBlock(boolean decompress) Read next block.private voidreadFully(byte[] b, int off, int len) Read bufferprivate byte[]readRange(int len) byte[]Read a record from the input stream and return the data.voidresetBlockSize(int recsPerBlock, boolean isCompressed) Sets the DumpArchive Buffer's block size.longskip(long len) Skip bytes.Methods inherited from class java.io.FilterInputStream
mark, markSupported, read, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
RECORD_SIZE
private static final int RECORD_SIZE- See Also:
-
blockBuffer
private byte[] blockBuffer -
currBlkIdx
private int currBlkIdx -
blockSize
private int blockSize -
readOffset
private int readOffset -
isCompressed
private boolean isCompressed -
bytesRead
private long bytesRead
-
-
Constructor Details
-
TapeInputStream
TapeInputStream(InputStream in) Constructs a new instance.- Parameters:
in- the underlying input stream.
-
-
Method Details
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException- See Also:
-
close
Close the input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException- on error
-
getBytesRead
public long getBytesRead()Gets number of bytes read.- Returns:
- number of bytes read.
-
peek
Peek at the next record from the input stream and return the data.- Returns:
- The record data.
- Throws:
IOException- on error
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException- See Also:
-
read
reads the full given length unless EOF is reached.
- Overrides:
readin classFilterInputStream- Parameters:
len- length to read, must be a multiple of the stream's record size- Throws:
IOException
-
readBlock
Read next block. All decompression is handled here.- Parameters:
decompress- if false the buffer will not be decompressed. This is an optimization for longer seeks.- Throws:
IOException
-
readFully
Read buffer- Throws:
IOException
-
readRange
- Throws:
IOException
-
readRecord
Read a record from the input stream and return the data.- Returns:
- The record data.
- Throws:
IOException- on error
-
resetBlockSize
Sets the DumpArchive Buffer's block size. We need to sync the block size with the dump archive's actual block size since compression is handled at the block level.- Parameters:
recsPerBlock- records per blockisCompressed- true if the archive is compressed- Throws:
IOException- more than one block has been readIOException- there was an error reading additional blocks.IOException- recsPerBlock is smaller than 1
-
skip
Skip bytes. Same as read but without the arraycopy.skips the full given length unless EOF is reached.
- Overrides:
skipin classFilterInputStream- Parameters:
len- length to read, must be a multiple of the stream's record size- Throws:
IOException
-