Class ByteArrayPostingList

    • Field Detail

      • buffer

        public byte[] buffer
        The internal buffer.
      • occurrency

        public long occurrency
        The current occurrency.
      • sumMaxPos

        public long sumMaxPos
        The current sum of maximum positions.
      • posNumBits

        public long posNumBits
        The number of bits used for positions.
      • maxCount

        public int maxCount
        The maximum count ever seen.
      • outOfMemoryError

        public boolean outOfMemoryError
        If true, this list experienced an OutOfMemoryError during some buffer reallocation.
    • Constructor Detail

      • ByteArrayPostingList

        public ByteArrayPostingList​(byte[] a,
                                    boolean differential,
                                    Scan.Completeness completeness)
        Creates a new posting list wrapping a given byte array.
        Parameters:
        a - the byte array to wrap.
        differential - whether this stream should be differential (e.g., whether it should store document pointers as gaps).
        completeness -
    • Method Detail

      • align

        public int align()
        Flushes the internal bit buffer to the byte buffer.
        Returns:
        the number of bits written.
      • writeLong

        public int writeLong​(long x,
                             int len)
        Writes a fixed number of bits from a long.
        Parameters:
        x - a long.
        len - a bit length; this many lower bits of the first argument will be written (the most significant bit first).
        Returns:
        the number of bits written (len).
      • flush

        public void flush()
        Flushes the positions cached internally.
        Specified by:
        flush in interface Flushable
      • setDocumentPointer

        public void setDocumentPointer​(long pointer)
        Sets the current document pointer.

        If the document pointer is changed since the last call, the positions currently stored are flushed and the new pointer is written to the stream.

        Parameters:
        pointer - a document pointer.
      • addPosition

        public void addPosition​(int pos)
        Adds a new position for the current document pointer.

        It is mandatory that successive calls to this method for the same document pointer have increasing arguments.

        Parameters:
        pos - a position.
      • writtenBits

        public long writtenBits()
        Returns the number of bits written by this posting list.
        Returns:
        the number of bits written by this posting list.
      • stripPointers

        public void stripPointers​(OutputBitStream obs,
                                  long bitLength)
                           throws IOException
        Writes the given number of bits of the internal buffer to the provided output bit stream, stripping all document pointers.

        This method is a horrible kluge solving the problem of terms appearing in all documents: BitStreamIndexWriter would not write pointers in this case, but we do not know whether we will need pointers or not while we are filling the internal buffer. Thus, for those (hopefully few) terms appearing in all documents this method can be used to dump the internal buffer stripping all pointers.

        Note that the valid number of bits should be retrieved using writtenBits() after a flush(). Then, a call to align() will dump to the buffer the bits still floating in the bit buffer; at that point this method can be called safely.

        Parameters:
        obs - an output bit stream.
        bitLength - the number of bits to be scanned.
        Throws:
        IOException
      • close

        public void close()
        Calls flush() and then releases resources allocated by this byte-array posting list, keeping just the internal buffer.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable