Interface IndexWriter

    • Method Detail

      • newInvertedList

        long newInvertedList()
                      throws IOException
        Starts a new inverted list. The previous inverted list, if any, is actually written to the underlying bit stream.
        Returns:
        the position (in bits) of the underlying bit stream where the new inverted list starts.
        Throws:
        IllegalStateException - if too few records were written for the previous inverted list.
        IOException
      • writeFrequency

        void writeFrequency​(long frequency)
                     throws IOException
        Writes the frequency.
        Parameters:
        frequency - the (positive) number of document records that this inverted list will contain.
        Throws:
        IOException
      • writeDocumentPointer

        void writeDocumentPointer​(OutputBitStream out,
                                  long pointer)
                           throws IOException
        Writes a document pointer.

        This method must be called immediately after newDocumentRecord().

        Parameters:
        out - the output bit stream where the pointer will be written.
        pointer - the document pointer.
        Throws:
        IOException
      • writePositionCount

        void writePositionCount​(OutputBitStream out,
                                int count)
                         throws IOException
        Writes the count of the occurrences of the current term in the current document to the given OutputBitStream.
        Parameters:
        out - the output stream where the occurrences should be written.
        count - the count.
        Throws:
        IOException
      • writeDocumentPositions

        void writeDocumentPositions​(OutputBitStream out,
                                    int[] position,
                                    int offset,
                                    int count,
                                    int docSize)
                             throws IOException
        Writes the positions of the occurrences of the current term in the current document to the given OutputBitStream.
        Parameters:
        out - the output stream where the occurrences should be written.
        position - the position vector (a sequence of strictly increasing natural numbers).
        offset - the first valid entry in position.
        count - the number of valid entries in position starting from offset.
        docSize - the size of the current document (only for Golomb and interpolative coding; you can safely pass -1 otherwise).
        Throws:
        IllegalStateException - if there is no current inverted list.
        IOException
      • writtenBits

        long writtenBits()
        Returns the overall number of bits written onto the underlying stream(s).
        Returns:
        the number of bits written, according to the variables keeping statistical records.
      • close

        void close()
            throws IOException
        Closes this index writer, completing the index creation process and releasing all resources.
        Throws:
        IllegalStateException - if too few records were written for the last inverted list.
        IOException
      • printStats

        void printStats​(PrintStream stats)
        Writes to the given print stream statistical information about the index just built. This method must be called after close().
        Parameters:
        stats - a print stream where statistical information will be written.