Class BlockReader

    • Method Detail

      • seekCeil

        public TermsEnum.SeekStatus seekCeil​(BytesRef searchedTerm)
                                      throws java.io.IOException
        Description copied from class: TermsEnum
        Seeks to the specified term, if it exists, or to the next (ceiling) term. Returns SeekStatus to indicate whether exact term was found, a different term was found, or EOF was hit. The target term may be before or after the current term. If this returns SeekStatus.END, the enum is unpositioned.
        Specified by:
        seekCeil in class TermsEnum
        Throws:
        java.io.IOException
      • seekExact

        public boolean seekExact​(BytesRef searchedTerm)
                          throws java.io.IOException
        Description copied from class: TermsEnum
        Attempts to seek to the exact term, returning true if the term is found. If this returns false, the enum is unpositioned. For some codecs, seekExact may be substantially faster than TermsEnum.seekCeil(org.apache.lucene.util.BytesRef).
        Overrides:
        seekExact in class BaseTermsEnum
        Returns:
        true if the term is found; return false if the enum is unpositioned.
        Throws:
        java.io.IOException
      • isCurrentTerm

        protected boolean isCurrentTerm​(BytesRef searchedTerm)
      • isBeyondLastTerm

        protected boolean isBeyondLastTerm​(BytesRef searchedTerm,
                                           long blockStartFP)
        Indicates whether the searched term is beyond the last term of the field.
        Parameters:
        blockStartFP - The current block start file pointer.
      • seekInBlock

        protected TermsEnum.SeekStatus seekInBlock​(BytesRef searchedTerm,
                                                   long blockStartFP)
                                            throws java.io.IOException
        Seeks to the provided term in the block starting at the provided file pointer. Does not exceed the block.
        Throws:
        java.io.IOException
      • seekInBlock

        protected TermsEnum.SeekStatus seekInBlock​(BytesRef searchedTerm)
                                            throws java.io.IOException
        Seeks to the provided term in this block.

        Does not exceed this block; TermsEnum.SeekStatus.END is returned if it follows the block.

        Compares the line terms with the searchedTerm, taking advantage of the incremental encoding properties.

        Scans linearly the terms. Updates the current block line with the current term.

        Throws:
        java.io.IOException
      • compareToMiddleAndJump

        protected int compareToMiddleAndJump​(BytesRef searchedTerm)
                                      throws java.io.IOException
        Compares the searched term to the middle term of the block. If the searched term is lexicographically equal or after the middle term then jumps to the second half of the block directly.
        Returns:
        The comparison between the searched term and the middle term.
        Throws:
        java.io.IOException
      • readLineInBlock

        protected BlockLine readLineInBlock()
                                     throws java.io.IOException
        Reads the current block line. Sets blockLine and increments lineIndexInBlock.
        Returns:
        The BlockLine; or null if there no more line in the block.
        Throws:
        java.io.IOException
      • seekExact

        public void seekExact​(long ord)
        Not supported.
        Specified by:
        seekExact in class TermsEnum
      • next

        public BytesRef next()
                      throws java.io.IOException
        Description copied from interface: BytesRefIterator
        Increments the iteration to the next BytesRef in the iterator. Returns the resulting BytesRef or null if the end of the iterator is reached. The returned BytesRef may be re-used across calls to next. After this method returns null, do not call it again: the results are undefined.
        Specified by:
        next in interface BytesRefIterator
        Returns:
        the next BytesRef in the iterator or null if the end of the iterator is reached.
        Throws:
        java.io.IOException - If there is a low-level I/O error.
      • nextTerm

        protected BytesRef nextTerm()
                             throws java.io.IOException
        Moves to the next term line and reads it, it may be in the next block. The term details are not read yet. They will be read only when needed with readTermStateIfNotRead().
        Returns:
        The read term bytes; or null if there is no more term for the field.
        Throws:
        java.io.IOException
      • initializeHeader

        protected void initializeHeader​(BytesRef searchedTerm,
                                        long targetBlockStartFP)
                                 throws java.io.IOException
        Reads and sets blockHeader. Sets null if there is no block for the field anymore.
        Parameters:
        searchedTerm - The searched term; or null if none.
        targetBlockStartFP - The file pointer of the block to read.
        Throws:
        java.io.IOException
      • initializeBlockReadLazily

        protected void initializeBlockReadLazily()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readHeader

        protected BlockHeader readHeader()
                                  throws java.io.IOException
        Reads the block header. Sets blockHeader.
        Returns:
        The block header; or null if there is no block for the field anymore.
        Throws:
        java.io.IOException
      • decodeBlockBytesIfNeeded

        protected BytesRef decodeBlockBytesIfNeeded​(int numBlockBytes)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readTermStateIfNotRead

        protected BlockTermState readTermStateIfNotRead()
                                                 throws java.io.IOException
        Reads the BlockTermState if it is not already set. Sets termState.
        Throws:
        java.io.IOException
      • term

        public BytesRef term()
        Description copied from class: TermsEnum
        Returns current term. Do not call this when the enum is unpositioned.
        Specified by:
        term in class TermsEnum
      • ord

        public long ord()
        Description copied from class: TermsEnum
        Returns ordinal position for current term. This is an optional method (the codec may throw UnsupportedOperationException). Do not call this when the enum is unpositioned.
        Specified by:
        ord in class TermsEnum
      • docFreq

        public int docFreq()
                    throws java.io.IOException
        Description copied from class: TermsEnum
        Returns the number of documents containing the current term. Do not call this when the enum is unpositioned. TermsEnum.SeekStatus.END.
        Specified by:
        docFreq in class TermsEnum
        Throws:
        java.io.IOException
      • totalTermFreq

        public long totalTermFreq()
                           throws java.io.IOException
        Description copied from class: TermsEnum
        Returns the total number of occurrences of this term across all documents (the sum of the freq() for each doc that has this term). Note that, like other term measures, this measure does not take deleted documents into account.
        Specified by:
        totalTermFreq in class TermsEnum
        Throws:
        java.io.IOException
      • postings

        public PostingsEnum postings​(PostingsEnum reuse,
                                     int flags)
                              throws java.io.IOException
        Description copied from class: TermsEnum
        Get PostingsEnum for the current term, with control over whether freqs, positions, offsets or payloads are required. Do not call this when the enum is unpositioned. This method will not return null.

        NOTE: the returned iterator may return deleted documents, so deleted documents have to be checked on top of the PostingsEnum.

        Specified by:
        postings in class TermsEnum
        Parameters:
        reuse - pass a prior PostingsEnum for possible reuse
        flags - specifies which optional per-document values you require; see PostingsEnum.FREQS
        Throws:
        java.io.IOException
      • ramBytesUsed

        public long ramBytesUsed()
        Description copied from interface: Accountable
        Return the memory usage of this object in bytes. Negative values are illegal.
        Specified by:
        ramBytesUsed in interface Accountable
      • getOrCreateDictionaryBrowser

        protected IndexDictionary.Browser getOrCreateDictionaryBrowser()
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • clearTermState

        protected void clearTermState()
        Called by the primary TermsEnum methods to clear the previous TermState.
      • newCorruptIndexException

        protected CorruptIndexException newCorruptIndexException​(java.lang.String msg,
                                                                 java.lang.Long fp)