Class ExclusiveLongRangeCounter

java.lang.Object
org.apache.lucene.facet.range.LongRangeCounter
org.apache.lucene.facet.range.ExclusiveLongRangeCounter

class ExclusiveLongRangeCounter extends LongRangeCounter
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.
  • Field Details

    • boundaries

      private final long[] boundaries
      elementary interval boundaries used for efficient counting (bsearch to find interval)
    • rangeNums

      private final int[] rangeNums
      original range number each elementary interval corresponds to (index into countBuffer)
    • missingCount

      private int missingCount
      number of counted documents that haven't matched any requested ranges
    • multiValuedDocMatchedRange

      private boolean multiValuedDocMatchedRange
      whether-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 class LongRangeCounter
    • 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 class LongRangeCounter
    • addSingleValued

      void addSingleValued(long v)
      Description copied from class: LongRangeCounter
      Count a single valued doc
      Overrides:
      addSingleValued in class LongRangeCounter
    • 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 class LongRangeCounter
    • boundaries

      protected long[] boundaries()
      Description copied from class: LongRangeCounter
      Provide boundary information for elementary intervals (max inclusive value per interval)
      Specified by:
      boundaries in class LongRangeCounter
    • processSingleValuedHit

      protected void processSingleValuedHit(int elementaryIntervalNum)
      Description copied from class: LongRangeCounter
      Process a single-value "hit" against an elementary interval.
      Specified by:
      processSingleValuedHit in class LongRangeCounter
    • processMultiValuedHit

      protected void processMultiValuedHit(int elementaryIntervalNum)
      Description copied from class: LongRangeCounter
      Process a multi-value "hit" against an elementary interval.
      Specified by:
      processMultiValuedHit in class LongRangeCounter
    • 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.