Package org.apache.maven.index
Class DefaultIteratorResultSet
- java.lang.Object
-
- org.apache.maven.index.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!- Author:
- cstamas
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultIteratorResultSet(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, java.util.List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 ArtifactInfocreateNextAi()voidfinalize()protected 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)protected IndexingContextgetIndexingContextForPointer(org.apache.lucene.document.Document doc, int docPtr)intgetTotalProcessedArtifactInfoCount()Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation.booleanhasNext()protected java.util.List<java.lang.String>highlightField(IndexingContext context, MatchHighlightRequest hr, IndexerField field, java.lang.String text)Returns a string that contains match fragment highlighted in style as user requested.java.util.Iterator<ArtifactInfo>iterator()ArtifactInfonext()voidremove()protected IndexerFieldselectStoredIndexerField(Field field)Select a STORED IndexerField assigned to passed in Field.
-
-
-
Constructor Detail
-
DefaultIteratorResultSet
protected DefaultIteratorResultSet(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, java.util.List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<ArtifactInfo>
-
next
public ArtifactInfo next()
- Specified by:
nextin interfacejava.util.Iterator<ArtifactInfo>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<ArtifactInfo>
-
iterator
public java.util.Iterator<ArtifactInfo> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<ArtifactInfo>
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
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
public void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.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)
-
-