Class OneDimensionalObjectHitCollector
java.lang.Object
org.apache.lucene.search.SimpleCollector
com.atlassian.jira.issue.statistics.util.OneDimensionalObjectHitCollector
- All Implemented Interfaces:
org.apache.lucene.search.Collector
,org.apache.lucene.search.LeafCollector
public class OneDimensionalObjectHitCollector
extends org.apache.lucene.search.SimpleCollector
A HitCollector that creates a doc -> object mapping. This is useful for collecting documents where there are a
limited number of terms. The caching also ensures that if multiple searches sort on the same terms, the doc ->
object mapping is maintained.
This HitCollector can be quite memory intensive, however the cache is stored with a weak reference, so it will be garbage collected.
This HitCollector differs from OneDimensionalTermHitCollector
in that it performs the term -> object
conversion here, rather than later. This is more expensive, but useful for StatisticsMappers that perform some sort
of runtime conversion / translation (eg a StatisticsMapper that groups dates by Month, or groups users by email
domain name).
-
Constructor Summary
ConstructorsConstructorDescriptionOneDimensionalObjectHitCollector
(String fieldName, StatisticsMapper statisticsMapper, Map result) Creates a normal one-dimensional object hit collector.OneDimensionalObjectHitCollector
(String fieldName, StatisticsMapper statisticsMapper, Map result, boolean isUnique) Allows the caller to specify whether or not the hit collector may assume that the field will never have more than one value for any issue. -
Method Summary
Modifier and TypeMethodDescriptionvoid
collect
(int i) protected void
doSetNextReader
(org.apache.lucene.index.LeafReaderContext context) boolean
void
setScorer
(org.apache.lucene.search.Scorer scorer) Methods inherited from class org.apache.lucene.search.SimpleCollector
getLeafCollector
-
Constructor Details
-
OneDimensionalObjectHitCollector
public OneDimensionalObjectHitCollector(String fieldName, StatisticsMapper statisticsMapper, Map result) Creates a normal one-dimensional object hit collector. This is equivalent toOneDimensionalObjectHitCollector(String, StatisticsMapper, Map, boolean)
} with false provided for isUnique, which should be safe for use with all fields. However, if it is known in advance that the field contains at most one value for the field, then specifying isUnique will be more efficient.- Parameters:
statisticsMapper
- provides the information required to map the fieldresult
- the map to which the result will be published
-
OneDimensionalObjectHitCollector
@ExperimentalApi public OneDimensionalObjectHitCollector(String fieldName, StatisticsMapper statisticsMapper, Map result, boolean isUnique) Allows the caller to specify whether or not the hit collector may assume that the field will never have more than one value for any issue. This allows the hit collector to be much more efficient in gathering the data for that field, but it will give incorrect results if the field can contain multiple values. Examples of suitable fields where isUnique should be set include the project id, issue type, created date, and resolved date.- Parameters:
statisticsMapper
- provides the information required to map the fieldresult
- the map to which the result will be publishedisUnique
- true if the field can safely be assumed to have at most one value for any issue; false if the field might be allowed to contain multiple values per issue
-
-
Method Details
-
collect
- Specified by:
collect
in interfaceorg.apache.lucene.search.LeafCollector
- Specified by:
collect
in classorg.apache.lucene.search.SimpleCollector
- Throws:
IOException
-
setScorer
- Specified by:
setScorer
in interfaceorg.apache.lucene.search.LeafCollector
- Overrides:
setScorer
in classorg.apache.lucene.search.SimpleCollector
- Throws:
IOException
-
doSetNextReader
protected void doSetNextReader(org.apache.lucene.index.LeafReaderContext context) throws IOException - Overrides:
doSetNextReader
in classorg.apache.lucene.search.SimpleCollector
- Throws:
IOException
-
needsScores
public boolean needsScores()
-