Module org.apache.lucene.facet
Package org.apache.lucene.facet.range
Class OverlappingLongRangeCounter
java.lang.Object
org.apache.lucene.facet.range.LongRangeCounter
org.apache.lucene.facet.range.OverlappingLongRangeCounter
This implementation supports requested ranges that overlap. Because of this, we use a
segment-tree to more efficiently aggregate counts into ranges at the end of processing. We also
need to worry about double-counting issues since it's possible that multiple elementary
intervals, although mutually-exclusive, can roll-up to the same requested range. This creates
some complexity with how we need to handle multi-valued documents.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classHolds one node of the segment tree.Nested 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 intprivate booleanwhether-or-not there are elementary interval counts that still need to be rolled up at the endprivate intnumber of counted documents that haven't matched any requested rangesprivate FixedBitSetwhether-or-not an elementary interval has seen at least one match for a single docprivate FixedBitSetwhether-or-not a requested range has seen at least one match for a single docprivate final OverlappingLongRangeCounter.LongRangeNodesegment tree root nodeprivate int[]counts seen in each elementary intervalFields inherited from class org.apache.lucene.facet.range.LongRangeCounter
multiValuedDocLastSeenElementaryInterval -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected long[]Provide boundary information for elementary intervals (max inclusive value per interval)private static List<LongRangeCounter.InclusiveRange> buildElementaryIntervals(LongRange[] ranges) (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.private booleanRolls up all the multi-valued doc counts.private introllupSingleValued(OverlappingLongRangeCounter.LongRangeNode node, boolean sawOutputs) Rolls up all the single-valued doc counts.private static OverlappingLongRangeCounter.LongRangeNodesplit(int start, int end, List<LongRangeCounter.InclusiveRange> elementaryIntervals) (package private) voidStart processing a new doc.Methods inherited from class org.apache.lucene.facet.range.LongRangeCounter
addMultiValued, addSingleValued, create, increment, increment, rangeCount
-
Field Details
-
root
segment tree root node -
boundaries
private final long[] boundarieselementary interval boundaries used for efficient counting (bsearch to find interval) -
hasUnflushedCounts
private boolean hasUnflushedCountswhether-or-not there are elementary interval counts that still need to be rolled up at the end -
singleValuedElementaryIntervalCounts
private int[] singleValuedElementaryIntervalCountscounts seen in each elementary interval -
multiValuedDocElementaryIntervalHits
whether-or-not an elementary interval has seen at least one match for a single doc -
multiValuedDocRangeHits
whether-or-not a requested range has seen at least one match for a single doc -
elementaryIntervalUpto
private int elementaryIntervalUpto -
missingCount
private int missingCountnumber of counted documents that haven't matched any requested ranges
-
-
Constructor Details
-
OverlappingLongRangeCounter
OverlappingLongRangeCounter(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
-
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
-
split
private static OverlappingLongRangeCounter.LongRangeNode split(int start, int end, List<LongRangeCounter.InclusiveRange> elementaryIntervals) -
rollupSingleValued
Rolls up all the single-valued doc counts. Note that this is done once at the end of processing all documents (as part offinish(). This is done in bulk at the end for efficiency purposes (vs. after ever document). This works only for cases where documents have a single-value. Multi-valued docs need to get rolled up after each document to ensure there's no double-counting (seerollupMultiValued(LongRangeNode)) -
rollupMultiValued
Rolls up all the multi-valued doc counts. Note that this is done at the end of each document (as part ofendMultiValuedDoc()). All of the counts contributed by a single document get rolled up into the appropriate ranges in this step. It must be done after each document so that counts don't get double-counted, and so we know whether-or-not an individual doc actually contributed to any of the user-requested ranges. -
buildElementaryIntervals
-