Class AbstractOneDimensionalHitCollector
java.lang.Object
org.apache.lucene.search.SimpleCollector
com.atlassian.jira.issue.statistics.util.AbstractOneDimensionalHitCollector
- All Implemented Interfaces:
org.apache.lucene.search.Collector
,org.apache.lucene.search.LeafCollector
- Direct Known Subclasses:
OneDimensionalDocIssueHitCollector
,OneDimensionalTermHitCollector
@Internal
@NotThreadSafe
public abstract class AbstractOneDimensionalHitCollector
extends org.apache.lucene.search.SimpleCollector
Used to traverse a query and collect if the specified one dimension is relevant, this will keep track of the
irrelevant count.
This class implements Collector
which is a callback mechanism for use by
IndexSearcher
, but it is widely abused and called directly from within JIRA.
This class assumes the collected values will be sorted. This is not possible in the current API (SearchProvider
).
Users of this class should
- Retrieve the sorted document ids from Lucene
- Use doSetNextReader(LeafReaderContext)
or doSetNextIndexReader(IndexReaderContext)
to set context
- Feed sorted ids into collect(int)
method
This class is not thread-safe.
- Since:
- v4.0
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractOneDimensionalHitCollector
(String documentFieldId, FieldVisibilityManager fieldVisibilityManager, ReaderCache readerCache, FieldManager fieldManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
collect
(int i) Collect hits.protected abstract void
collectIrrelevant
(int docId) Implement this if you would like to do something when the hit collector has encountered a docId that contains an irrelevant data matchprotected abstract void
collectWithTerms
(int docId, JiraBytesRef[] terms) Implement this if you would like to do something with the hit we have found.void
doSetNextIndexReader
(org.apache.lucene.index.IndexReaderContext context) void
doSetNextReader
(org.apache.lucene.index.LeafReaderContext context) long
Returns the number of times thecollect(int)
method was called.long
boolean
Methods inherited from class org.apache.lucene.search.SimpleCollector
getLeafCollector, setScorer
-
Constructor Details
-
AbstractOneDimensionalHitCollector
public AbstractOneDimensionalHitCollector(String documentFieldId, FieldVisibilityManager fieldVisibilityManager, ReaderCache readerCache, FieldManager fieldManager) - Since:
- v6.4
-
-
Method Details
-
doSetNextReader
public void doSetNextReader(org.apache.lucene.index.LeafReaderContext context) - Overrides:
doSetNextReader
in classorg.apache.lucene.search.SimpleCollector
-
doSetNextIndexReader
public void doSetNextIndexReader(org.apache.lucene.index.IndexReaderContext context) -
collect
public void collect(int i) Collect hits. When accessing our value caches we do not need to increment i by the docBase as the value caches are built against the current (segment) reader. When calling the abstract collectXXX() methods these expect the index of the whole reader, so we need to use (i + docBase).- Specified by:
collect
in interfaceorg.apache.lucene.search.LeafCollector
- Specified by:
collect
in classorg.apache.lucene.search.SimpleCollector
- Parameters:
i
- Index to the current reader
-
getIrrelevantCount
public long getIrrelevantCount() -
getHitCount
public long getHitCount()Returns the number of times thecollect(int)
method was called. This should return the number of unique issues that was matched during a search.- Returns:
- number of times the
collect(int)
method was called.
-
collectIrrelevant
protected abstract void collectIrrelevant(int docId) Implement this if you would like to do something when the hit collector has encountered a docId that contains an irrelevant data match- Parameters:
docId
- the match we have found. This is an index into the overall directory reader.
-
collectWithTerms
Implement this if you would like to do something with the hit we have found.- Parameters:
docId
- the doc id of the hit. This is an index into the overall directory reader.terms
- the terms for the fieldId for this document, pre-calculated so you may not need to call getDocument
-
needsScores
public boolean needsScores()
-