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!
-
-
Field Summary
Fields Modifier and Type Field Description private ArtifactInfo
ai
private boolean
cleanedUp
private java.util.List<IndexingContext>
contexts
private int
count
private ArtifactInfoFilter
filter
private int
from
private org.apache.lucene.search.TopDocs
hits
private NexusIndexMultiSearcher
indexSearcher
private java.util.List<MatchHighlightRequest>
matchHighlightRequests
private int
maxRecPointer
private int
pointer
private ArtifactInfoPostprocessor
postprocessor
private int
processedArtifactInfoCount
private IteratorSearchRequest
searchRequest
private int[]
starts
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultIteratorResultSet(IteratorSearchRequest request, NexusIndexMultiSearcher indexSearcher, java.util.List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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
createNextAi()
void
finalize()
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 IndexingContext
getIndexingContextForPointer(org.apache.lucene.document.Document doc, int docPtr)
int
getTotalProcessedArtifactInfoCount()
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()
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()
ArtifactInfo
next()
private static int
readerIndex(int n, int[] starts, int numSubReaders)
void
remove()
protected IndexerField
selectStoredIndexerField(Field field)
Select a STORED IndexerField assigned to passed in Field.
-
-
-
Field Detail
-
searchRequest
private final IteratorSearchRequest searchRequest
-
indexSearcher
private final NexusIndexMultiSearcher indexSearcher
-
contexts
private final java.util.List<IndexingContext> contexts
-
starts
private final int[] starts
-
filter
private final ArtifactInfoFilter filter
-
postprocessor
private final ArtifactInfoPostprocessor postprocessor
-
matchHighlightRequests
private final java.util.List<MatchHighlightRequest> matchHighlightRequests
-
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
-
ai
private ArtifactInfo ai
-
cleanedUp
private volatile boolean cleanedUp
-
-
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:
hasNext
in interfacejava.util.Iterator<ArtifactInfo>
-
next
public ArtifactInfo next()
- Specified by:
next
in interfacejava.util.Iterator<ArtifactInfo>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<ArtifactInfo>
-
iterator
public java.util.Iterator<ArtifactInfo> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<ArtifactInfo>
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.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 interfaceIteratorResultSet
- Returns:
- total number of processed ArtifactInfos so far
-
finalize
public void finalize() throws java.lang.Throwable
- Overrides:
finalize
in 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)
-
readerIndex
private static int readerIndex(int n, int[] starts, int numSubReaders)
-
-