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
ConstructorsModifierConstructorDescriptionprotectedDefaultIteratorResultSet(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcalculateHighlights(IndexingContext context, org.apache.lucene.document.Document d, ArtifactInfo ai) Creates the MatchHighlights and adds them to ArtifactInfo if found/can.protected voidcleanUp()voidclose()protected ArtifactInfovoidfinalize()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 IndexingContextgetIndexingContextForPointer(org.apache.lucene.document.Document doc, int docPtr) intReturns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation.booleanhasNext()highlightField(IndexingContext context, MatchHighlightRequest hr, IndexerField field, String text) Returns a string that contains match fragment highlighted in style as user requested.iterator()next()voidremove()protected IndexerFieldselectStoredIndexerField(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, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:
hasNextin interfaceIterator<ArtifactInfo>
-
next
- Specified by:
nextin interfaceIterator<ArtifactInfo>
-
remove
public void remove()- Specified by:
removein interfaceIterator<ArtifactInfo>
-
iterator
- Specified by:
iteratorin interfaceIterable<ArtifactInfo>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getTotalProcessedArtifactInfoCount
public int getTotalProcessedArtifactInfoCount()Description copied from interface:IteratorResultSetReturns 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:
getTotalProcessedArtifactInfoCountin 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)
-