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 recordSimple 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 intnumber of counted documents that haven't matched any requested rangesprivate booleanwhether-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) voidaddSingleValued(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) booleanFinish processing a new doc.(package private) intfinish()Finish processing all documents.protected voidprocessMultiValuedHit(int elementaryIntervalNum) Process a multi-value "hit" against an elementary interval.protected voidprocessSingleValuedHit(int elementaryIntervalNum) Process a single-value "hit" against an elementary interval.(package private) voidStart 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:LongRangeCounterStart processing a new doc. It's unnecessary to call this for single-value cases.- Overrides:
startMultiValuedDocin classLongRangeCounter
-
endMultiValuedDoc
boolean endMultiValuedDoc()Description copied from class:LongRangeCounterFinish 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:
endMultiValuedDocin classLongRangeCounter
-
addSingleValued
void addSingleValued(long v) Description copied from class:LongRangeCounterCount a single valued doc- Overrides:
addSingleValuedin classLongRangeCounter
-
finish
int finish()Description copied from class:LongRangeCounterFinish 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:
finishin classLongRangeCounter
-
boundaries
protected long[] boundaries()Description copied from class:LongRangeCounterProvide boundary information for elementary intervals (max inclusive value per interval)- Specified by:
boundariesin classLongRangeCounter
-
processSingleValuedHit
protected void processSingleValuedHit(int elementaryIntervalNum) Description copied from class:LongRangeCounterProcess a single-value "hit" against an elementary interval.- Specified by:
processSingleValuedHitin classLongRangeCounter
-
processMultiValuedHit
protected void processMultiValuedHit(int elementaryIntervalNum) Description copied from class:LongRangeCounterProcess a multi-value "hit" against an elementary interval.- Specified by:
processMultiValuedHitin 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.
-