Package org.terrier.compression.bit
Class BitInputStream
- java.lang.Object
-
- org.terrier.compression.bit.BitInBase
-
- org.terrier.compression.bit.BitInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BitIn
public class BitInputStream extends BitInBase
This class reads from a file or an InputStream integers that can be coded with different encoding algorithms. It does not use any internal buffering, and operates with bytes.- Author:
- Roi Blanco
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.DataInputdisThe private input stream used internaly.-
Fields inherited from interface org.terrier.compression.bit.BitIn
USUAL_EXTENSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBitInputStream()Do nothing constructor used by child classes which override all methods, eg OldBitInputStreamBitInputStream(java.io.DataInput in)Constructs an instance of the class for a given streamBitInputStream(java.io.File file)Constructs an instance of the class for a given fileBitInputStream(java.io.InputStream is)Constructs an instance of the class for a given streamBitInputStream(java.lang.String filename)Constructs an instance of the class for a given filename
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the stream.protected voidincrByte()Move forward one byte.protected voidincrByte(int i)Move forward i bytes.voidskipBytes(long len)Skip a number of bytes while reading the bit file.-
Methods inherited from class org.terrier.compression.bit.BitInBase
align, getBitOffset, getByteOffset, readBinary, readDelta, readGamma, readGolomb, readIn, readInterpolativeCoding, readMinimalBinary, readMinimalBinaryZero, readSkewedGolomb, readUnary, skipBits
-
-
-
-
Constructor Detail
-
BitInputStream
protected BitInputStream()
Do nothing constructor used by child classes which override all methods, eg OldBitInputStream
-
BitInputStream
public BitInputStream(java.io.DataInput in) throws java.io.IOExceptionConstructs an instance of the class for a given stream- Parameters:
in- java.io.DataInput the underlying input stream- Throws:
java.io.IOException- if an I/O error occurs
-
BitInputStream
public BitInputStream(java.io.InputStream is) throws java.io.IOExceptionConstructs an instance of the class for a given stream- Parameters:
is- java.io.InputStream the underlying input stream- Throws:
java.io.IOException- if an I/O error occurs
-
BitInputStream
public BitInputStream(java.lang.String filename) throws java.io.IOExceptionConstructs an instance of the class for a given filename- Parameters:
filename- java.lang.String the name of the undelying file- Throws:
java.io.IOException- if an I/O error occurs
-
BitInputStream
public BitInputStream(java.io.File file) throws java.io.IOExceptionConstructs an instance of the class for a given file- Parameters:
file- java.io.File the underlying file- Throws:
java.io.IOException- if an I/O error occurs
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionCloses the stream.- Throws:
java.io.IOException- if an I/O error occurs
-
skipBytes
public void skipBytes(long len) throws java.io.IOExceptionSkip a number of bytes while reading the bit file. After this opteration, getBitOffset() == 0, so use skipBits(int) to get getBitOffset() to desired value.- Parameters:
len- The number of bytes to skip- Throws:
java.io.IOException- if an I/O error occurs
-
incrByte
protected void incrByte() throws java.io.IOExceptionDescription copied from class:BitInBaseMove forward one byte. The newly read byte should appear in the byteRead variable.
-
-