Class 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 class  BitFileBuffered.BitInBuffered
      Implements a BitIn around a RandomDataInput
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int buffer_size
      how much of this file we will buffer
      protected static int DEFAULT_BUFFER_LENGTH
      how much of a file to buffer by default
      protected long fileSize
      how big the file is, so we know when to stop reading
      protected static org.slf4j.Logger logger
      The 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 size
      BitFileBuffered​(java.io.File _file, int bufSize)
      Constructs an instance of the class for a given filename
      BitFileBuffered​(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 filename
      BitFileBuffered​(RandomDataInput f)
      Constructor for a RandomDataInput object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      BitIn readReset​(long startByteOffset, byte startBitOffset)
      Reads from the file from a specific offset.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 file
        bufSize - 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 file
        bufSize - 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:
        readReset in interface BitInSeekable
        Parameters:
        startByteOffset - the starting byte to read from
        startBitOffset - the bit offset in the starting byte
        endByteOffset - the ending byte
        endBitOffset - 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:
        readReset in interface BitInSeekable
        Parameters:
        startByteOffset - the starting byte to read from
        startBitOffset - the bit offset in the starting byte
        Returns:
        Returns the BitIn object to use to read that data
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable