GlobalOrdinalsWithScoreCollector(String field, MultiDocValues.OrdinalMap ordinalMap, long valueCount, ScoreMode scoreMode, int min, int max) { if (valueCount > Integer.MAX_VALUE) { // We simply don't support more than throw new IllegalStateException("Can't collect more than [" + Integer.MAX_VALUE + "] ids"); } this.field = field; this.doMinMax = !(min <= 0 && max == Integer.MAX_VALUE); this.min = min; this.max = max;; this.ordinalMap = ordinalMap; this.collectedOrds = new LongBitSet(valueCount); if (scoreMode != ScoreMode.None) { this.scores = new Scores(valueCount, unset()); } else { this.scores = null; } if (scoreMode == ScoreMode.Avg || doMinMax) { this.occurrences = new Occurrences(valueCount); } else { this.occurrences = null; } }
@Override public float score(int globalOrdinal) { return scores.getScore(globalOrdinal) / occurrences.getOccurrence(globalOrdinal); }
@Override public void collect(int doc) throws IOException { final long segmentOrd = docTermOrds.getOrd(doc); if (segmentOrd != -1) { final int globalOrd = (int) segmentOrdToGlobalOrdLookup.get(segmentOrd); collectedOrds.set(globalOrd); float existingScore = scores.getScore(globalOrd); float newScore = scorer.score(); doScore(globalOrd, existingScore, newScore); if (occurrences != null) { occurrences.increment(globalOrd); } } }
@Override public void collect(int doc) throws IOException { final int segmentOrd = docTermOrds.getOrd(doc); if (segmentOrd != -1) { collectedOrds.set(segmentOrd); float existingScore = scores.getScore(segmentOrd); float newScore = scorer.score(); doScore(segmentOrd, existingScore, newScore); if (occurrences != null) { occurrences.increment(segmentOrd); } } }
@Override public void collect(int doc) throws IOException { final int segmentOrd = docTermOrds.getOrd(doc); if (segmentOrd != -1) { collectedOrds.set(segmentOrd); occurrences.increment(segmentOrd); } } };
@Override public void collect(int doc) throws IOException { final long segmentOrd = docTermOrds.getOrd(doc); if (segmentOrd != -1) { final int globalOrd = (int) segmentOrdToGlobalOrdLookup.get(segmentOrd); collectedOrds.set(globalOrd); occurrences.increment(globalOrd); } } };
public boolean match(int globalOrd) { if (collectedOrds.get(globalOrd)) { if (doMinMax) { final int occurrence = occurrences.getOccurrence(globalOrd); return occurrence >= min && occurrence <= max; } else { return true; } } return false; }