Module org.apache.lucene.facet
Package org.apache.lucene.facet.range
Class ExclusiveLongRangeCounter
java.lang.Object
org.apache.lucene.facet.range.LongRangeCounter
org.apache.lucene.facet.range.ExclusiveLongRangeCounter
This implementation assumes the requested ranges do not overlap. With this assumption,
we're able to take a simpler approach to accumulating range counts by just binary searching for
the appropriate range and counting directly as each value comes in.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Simple container for a requested range and its original positionNested classes/interfaces inherited from class org.apache.lucene.facet.range.LongRangeCounter
LongRangeCounter.InclusiveRange
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long[]
elementary interval boundaries used for efficient counting (bsearch to find interval)private int
number of counted documents that haven't matched any requested rangesprivate boolean
whether-or-not the multi-valued doc currently being counted has matched any rangesprivate final int[]
original range number each elementary interval corresponds to (index into countBuffer)Fields inherited from class org.apache.lucene.facet.range.LongRangeCounter
multiValuedDocLastSeenElementaryInterval
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addSingleValued
(long v) Count a single valued docprotected long[]
Provide boundary information for elementary intervals (max inclusive value per interval)private static List
<LongRangeCounter.InclusiveRange> buildElementaryIntervals
(ExclusiveLongRangeCounter.LongRangeAndPos[] sortedRanges) Create elementary intervals, which include requested ranges and "gaps" in-between.(package private) boolean
Finish processing a new doc.(package private) int
finish()
Finish processing all documents.protected void
processMultiValuedHit
(int elementaryIntervalNum) Process a multi-value "hit" against an elementary interval.protected void
processSingleValuedHit
(int elementaryIntervalNum) Process a single-value "hit" against an elementary interval.(package private) void
Start processing a new doc.Methods inherited from class org.apache.lucene.facet.range.LongRangeCounter
addMultiValued, create, increment, increment, rangeCount
-
Field Details
-
boundaries
private final long[] boundarieselementary interval boundaries used for efficient counting (bsearch to find interval) -
rangeNums
private final int[] rangeNumsoriginal range number each elementary interval corresponds to (index into countBuffer) -
missingCount
private int missingCountnumber of counted documents that haven't matched any requested ranges -
multiValuedDocMatchedRange
private boolean multiValuedDocMatchedRangewhether-or-not the multi-valued doc currently being counted has matched any ranges
-
-
Constructor Details
-
ExclusiveLongRangeCounter
ExclusiveLongRangeCounter(LongRange[] ranges, int[] countBuffer)
-
-
Method Details
-
startMultiValuedDoc
void startMultiValuedDoc()Description copied from class:LongRangeCounter
Start processing a new doc. It's unnecessary to call this for single-value cases.- Overrides:
startMultiValuedDoc
in classLongRangeCounter
-
endMultiValuedDoc
boolean endMultiValuedDoc()Description copied from class:LongRangeCounter
Finish processing a new doc. Returns whether-or-not the document contributed a count to at least one range. It's unnecessary to call this for single-value cases.- Specified by:
endMultiValuedDoc
in classLongRangeCounter
-
addSingleValued
void addSingleValued(long v) Description copied from class:LongRangeCounter
Count a single valued doc- Overrides:
addSingleValued
in classLongRangeCounter
-
finish
int finish()Description copied from class:LongRangeCounter
Finish processing all documents. This will return the number of docs that didn't contribute to any ranges (that weren't already reported when calling endMultiValuedDoc()).- Specified by:
finish
in classLongRangeCounter
-
boundaries
protected long[] boundaries()Description copied from class:LongRangeCounter
Provide boundary information for elementary intervals (max inclusive value per interval)- Specified by:
boundaries
in classLongRangeCounter
-
processSingleValuedHit
protected void processSingleValuedHit(int elementaryIntervalNum) Description copied from class:LongRangeCounter
Process a single-value "hit" against an elementary interval.- Specified by:
processSingleValuedHit
in classLongRangeCounter
-
processMultiValuedHit
protected void processMultiValuedHit(int elementaryIntervalNum) Description copied from class:LongRangeCounter
Process a multi-value "hit" against an elementary interval.- Specified by:
processMultiValuedHit
in classLongRangeCounter
-
buildElementaryIntervals
private static List<LongRangeCounter.InclusiveRange> buildElementaryIntervals(ExclusiveLongRangeCounter.LongRangeAndPos[] sortedRanges) Create elementary intervals, which include requested ranges and "gaps" in-between. This logic assumes no requested ranges overlap, and that the incoming ranges have already been sorted.
-