Package org.apache.maven.index
Class DefaultIteratorResultSet
java.lang.Object
org.apache.maven.index.DefaultIteratorResultSet
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ArtifactInfo>
,Iterator<ArtifactInfo>
,IteratorResultSet
Default implementation of IteratorResultSet. TODO: there is too much of logic, refactor this!
- Author:
- cstamas
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultIteratorResultSet
(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
calculateHighlights
(IndexingContext context, org.apache.lucene.document.Document d, ArtifactInfo ai) Creates the MatchHighlights and adds them to ArtifactInfo if found/can.protected void
cleanUp()
void
close()
protected ArtifactInfo
void
finalize()
getBestFragments
(org.apache.lucene.search.Query query, org.apache.lucene.search.highlight.Formatter formatter, org.apache.lucene.analysis.TokenStream tokenStream, String text, int maxNumFragments) protected IndexingContext
getIndexingContextForPointer
(org.apache.lucene.document.Document doc, int docPtr) int
Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation.boolean
hasNext()
highlightField
(IndexingContext context, MatchHighlightRequest hr, IndexerField field, String text) Returns a string that contains match fragment highlighted in style as user requested.iterator()
next()
void
remove()
protected IndexerField
selectStoredIndexerField
(Field field) Select a STORED IndexerField assigned to passed in Field.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
DefaultIteratorResultSet
protected DefaultIteratorResultSet(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits) throws IOException - Throws:
IOException
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<ArtifactInfo>
-
next
- Specified by:
next
in interfaceIterator<ArtifactInfo>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<ArtifactInfo>
-
iterator
- Specified by:
iterator
in interfaceIterable<ArtifactInfo>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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 interfaceIteratorResultSet
- Returns:
- total number of processed ArtifactInfos so far
-
finalize
-
createNextAi
- Throws:
IOException
-
cleanUp
protected void cleanUp() -
calculateHighlights
protected void calculateHighlights(IndexingContext context, org.apache.lucene.document.Document d, ArtifactInfo ai) throws IOException Creates the MatchHighlights and adds them to ArtifactInfo if found/can.- Parameters:
context
-d
-ai
-- Throws:
IOException
-
selectStoredIndexerField
Select a STORED IndexerField assigned to passed in Field.- Parameters:
field
-- Returns:
-
highlightField
protected List<String> highlightField(IndexingContext context, MatchHighlightRequest hr, IndexerField field, String text) throws IOException Returns a string that contains match fragment highlighted in style as user requested.- Parameters:
context
-hr
-field
-text
-- Returns:
- Throws:
IOException
-
getBestFragments
protected final List<String> getBestFragments(org.apache.lucene.search.Query query, org.apache.lucene.search.highlight.Formatter formatter, org.apache.lucene.analysis.TokenStream tokenStream, String text, int maxNumFragments) throws IOException - Throws:
IOException
-
getIndexingContextForPointer
protected IndexingContext getIndexingContextForPointer(org.apache.lucene.document.Document doc, int docPtr)
-