Package org.terrier.compression.bit
Class BitFileBuffered
- java.lang.Object
-
- org.terrier.compression.bit.BitFileBuffered
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BitInSeekable
- Direct Known Subclasses:
BitFileChannel,ConcurrentBitFileBuffered
public class BitFileBuffered extends java.lang.Object implements BitInSeekable
Implementation of BitInSeekable/BitIn interfaces similar to BitFile. However this class buffers only a small area of the posting list, to minimise large memory allocations during retrieval. In contrast to BitFile, this class is read-only.- Author:
- Patrice Lacour, Craig Macdonald
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classBitFileBuffered.BitInBufferedImplements a BitIn around a RandomDataInput
-
Field Summary
Fields Modifier and Type Field Description protected intbuffer_sizehow much of this file we will bufferprotected static intDEFAULT_BUFFER_LENGTHhow much of a file to buffer by defaultprotected longfileSizehow big the file is, so we know when to stop readingprotected static org.slf4j.LoggerloggerThe logger used
-
Constructor Summary
Constructors Constructor Description BitFileBuffered(java.io.File _file)Constructs an instance of the class for a given filename, using the default buffer sizeBitFileBuffered(java.io.File _file, int bufSize)Constructs an instance of the class for a given filenameBitFileBuffered(java.lang.String filename)Constructs an instance of the class for a given filename.BitFileBuffered(java.lang.String filename, int bufSize)Constructs an instance of the class for a given filenameBitFileBuffered(RandomDataInput f)Constructor for a RandomDataInput object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()BitInreadReset(long startByteOffset, byte startBitOffset)Reads from the file from a specific offset.BitInreadReset(long startByteOffset, byte startBitOffset, long endByteOffset, byte endBitOffset)Reads from the file a specific number of bytes and after this call, a sequence of read calls may follow.
-
-
-
Field Detail
-
DEFAULT_BUFFER_LENGTH
protected static final int DEFAULT_BUFFER_LENGTH
how much of a file to buffer by default- See Also:
- Constant Field Values
-
logger
protected static final org.slf4j.Logger logger
The logger used
-
buffer_size
protected final int buffer_size
how much of this file we will buffer
-
fileSize
protected long fileSize
how big the file is, so we know when to stop reading
-
-
Constructor Detail
-
BitFileBuffered
public BitFileBuffered(RandomDataInput f)
Constructor for a RandomDataInput object
-
BitFileBuffered
public BitFileBuffered(java.io.File _file)
Constructs an instance of the class for a given filename, using the default buffer size- Parameters:
_file- the underlying file
-
BitFileBuffered
public BitFileBuffered(java.lang.String filename)
Constructs an instance of the class for a given filename. Default buffer size- Parameters:
filename- java.lang.String the name of the underlying file
-
BitFileBuffered
public BitFileBuffered(java.io.File _file, int bufSize)Constructs an instance of the class for a given filename- Parameters:
_file- the underlying filebufSize- how much of the file to buffer
-
BitFileBuffered
public BitFileBuffered(java.lang.String filename, int bufSize)Constructs an instance of the class for a given filename- Parameters:
filename- java.lang.String the name of the underlying filebufSize- how much of the file to buffer
-
-
Method Detail
-
readReset
public BitIn readReset(long startByteOffset, byte startBitOffset, long endByteOffset, byte endBitOffset)
Reads from the file a specific number of bytes and after this call, a sequence of read calls may follow. The offsets given as arguments are inclusive. For example, if we call this method with arguments 0, 2, 1, 7, it will read in a buffer the contents of the underlying file from the third bit of the first byte to the last bit of the second byte.- Specified by:
readResetin interfaceBitInSeekable- Parameters:
startByteOffset- the starting byte to read fromstartBitOffset- the bit offset in the starting byteendByteOffset- the ending byteendBitOffset- the bit offset in the ending byte. This bit is the last bit of this entry.- Returns:
- Returns the BitIn object to use to read that data
-
readReset
public BitIn readReset(long startByteOffset, byte startBitOffset)
Reads from the file from a specific offset. After this call, a sequence of read calls may follow.- Specified by:
readResetin interfaceBitInSeekable- Parameters:
startByteOffset- the starting byte to read fromstartBitOffset- the bit offset in the starting byte- Returns:
- Returns the BitIn object to use to read that data
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-