Class DefaultIteratorResultSet

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable<ArtifactInfo>, java.util.Iterator<ArtifactInfo>, IteratorResultSet

    public class DefaultIteratorResultSet
    extends java.lang.Object
    implements IteratorResultSet
    Default implementation of IteratorResultSet. TODO: there is too much of logic, refactor this!
    • Field Detail

      • starts

        private final int[] starts
      • hits

        private final org.apache.lucene.search.TopDocs hits
      • from

        private final int from
      • count

        private final int count
      • maxRecPointer

        private final int maxRecPointer
      • pointer

        private int pointer
      • processedArtifactInfoCount

        private int processedArtifactInfoCount
      • cleanedUp

        private volatile boolean cleanedUp
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<ArtifactInfo>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<ArtifactInfo>
      • iterator

        public java.util.Iterator<ArtifactInfo> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<ArtifactInfo>
      • close

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

        public int getTotalProcessedArtifactInfoCount()
        Description copied from interface: IteratorResultSet
        Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation. Warning: this method will return ALL touched/loaded document count, even those that are filtered out and NOT returned by iterator's next() method!
        Specified by:
        getTotalProcessedArtifactInfoCount in interface IteratorResultSet
        Returns:
        total number of processed ArtifactInfos so far
      • finalize

        public void finalize()
                      throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • createNextAi

        protected ArtifactInfo createNextAi()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • cleanUp

        protected void cleanUp()
      • calculateHighlights

        protected void calculateHighlights​(IndexingContext context,
                                           org.apache.lucene.document.Document d,
                                           ArtifactInfo ai)
                                    throws java.io.IOException
        Creates the MatchHighlights and adds them to ArtifactInfo if found/can.
        Parameters:
        context -
        d -
        ai -
        Throws:
        java.io.IOException
      • selectStoredIndexerField

        protected IndexerField selectStoredIndexerField​(Field field)
        Select a STORED IndexerField assigned to passed in Field.
        Parameters:
        field -
        Returns:
      • highlightField

        protected java.util.List<java.lang.String> highlightField​(IndexingContext context,
                                                                  MatchHighlightRequest hr,
                                                                  IndexerField field,
                                                                  java.lang.String text)
                                                           throws java.io.IOException
        Returns a string that contains match fragment highlighted in style as user requested.
        Parameters:
        context -
        hr -
        field -
        text -
        Returns:
        Throws:
        java.io.IOException
      • getBestFragments

        protected final java.util.List<java.lang.String> getBestFragments​(org.apache.lucene.search.Query query,
                                                                          org.apache.lucene.search.highlight.Formatter formatter,
                                                                          org.apache.lucene.analysis.TokenStream tokenStream,
                                                                          java.lang.String text,
                                                                          int maxNumFragments)
                                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getIndexingContextForPointer

        protected IndexingContext getIndexingContextForPointer​(org.apache.lucene.document.Document doc,
                                                               int docPtr)
      • readerIndex

        private static int readerIndex​(int n,
                                       int[] starts,
                                       int numSubReaders)