- Direct Known Subclasses:
ExclusiveLongRangeCounter
,OverlappingLongRangeCounter
Usage notes: When counting a document field that only has a single value, callers should call
addSingleValued() with the value. Whenever a document field has multiple values, callers should
call startMultiValuedDoc() at the beginning of processing the document, followed by
addMultiValued() with each value before finally calling endMultiValuedDoc() at the end of
processing the document. The call to endMultiValuedDoc() will respond with a boolean indicating
whether-or-not the specific document matched against at least one of the ranges being counted.
Finally, after processing all documents, the caller should call finish(). This final call will
ensure the contents of the user-provided countBuffer
contains accurate counts (each index
corresponding to the provided LongRange
in ranges
). The final call to finish()
will also report how many additional documents did not match against any ranges. The combination
of the endMultiValuedDoc() boolean responses and the number reported by finish() communicates the
total number of missing documents. Note that the call to finish() will not report any documents
already reported missing by endMultiValuedDoc().
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[]
accumulated counts for all of the rangesprotected int
for multi-value docs, we keep track of the last elementary interval we've counted so we can use that as a lower-bound when counting subsequent values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addMultiValued
(long v) Count a multi-valued doc value(package private) void
addSingleValued
(long v) Count a single valued docprotected abstract long[]
Provide boundary information for elementary intervals (max inclusive value per interval)(package private) static LongRangeCounter
(package private) abstract boolean
Finish processing a new doc.(package private) abstract int
finish()
Finish processing all documents.private static boolean
hasOverlappingRanges
(LongRange[] ranges) Determine whether-or-not any requested ranges overlapprotected final void
increment
(int rangeNum) Increment the specified range by one.protected final void
increment
(int rangeNum, int count) Increment the specified range by the specified count.protected abstract void
processMultiValuedHit
(int elementaryIntervalNum) Process a multi-value "hit" against an elementary interval.protected abstract void
processSingleValuedHit
(int elementaryIntervalNum) Process a single-value "hit" against an elementary interval.protected final int
Number of ranges requested by the caller.(package private) void
Start processing a new doc.
-
Field Details
-
countBuffer
private final int[] countBufferaccumulated counts for all of the ranges -
multiValuedDocLastSeenElementaryInterval
protected int multiValuedDocLastSeenElementaryIntervalfor multi-value docs, we keep track of the last elementary interval we've counted so we can use that as a lower-bound when counting subsequent values. this takes advantage of the fact that values within a given doc are sorted.
-
-
Constructor Details
-
LongRangeCounter
protected LongRangeCounter(int[] countBuffer)
-
-
Method Details
-
create
-
startMultiValuedDoc
void startMultiValuedDoc()Start processing a new doc. It's unnecessary to call this for single-value cases. -
endMultiValuedDoc
abstract boolean endMultiValuedDoc()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. -
addSingleValued
void addSingleValued(long v) Count a single valued doc -
addMultiValued
void addMultiValued(long v) Count a multi-valued doc value -
finish
abstract int finish()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()). -
boundaries
protected abstract long[] boundaries()Provide boundary information for elementary intervals (max inclusive value per interval) -
processSingleValuedHit
protected abstract void processSingleValuedHit(int elementaryIntervalNum) Process a single-value "hit" against an elementary interval. -
processMultiValuedHit
protected abstract void processMultiValuedHit(int elementaryIntervalNum) Process a multi-value "hit" against an elementary interval. -
increment
protected final void increment(int rangeNum) Increment the specified range by one. -
increment
protected final void increment(int rangeNum, int count) Increment the specified range by the specified count. -
rangeCount
protected final int rangeCount()Number of ranges requested by the caller. -
hasOverlappingRanges
Determine whether-or-not any requested ranges overlap
-