@Override protected TopDocs newTopDocs(ScoreDoc[] results, int start) { if (results == null) { return EMPTY_TOPDOCS; } // We need to compute maxScore in order to set it in TopDocs. If start == 0, // it means the largest element is already in results, use its score as // maxScore. Otherwise pop everything else, until the largest element is // extracted and use its score as maxScore. float maxScore = Float.NaN; if (start == 0) { maxScore = results[0].score; } else { for (int i = pq.size(); i > 1; i--) { pq.pop(); } maxScore = pq.pop().score; } return new TopDocs(totalHits, results, maxScore); }
@Override public boolean next() throws IOException { if (started == false) { return started = true; } if (queue.top().next() == false) { queue.pop(); } if (queue.size() > 0) { queue.updateTop(); return true; } return false; }
if (queue.size() == 0) { return null;
for (int i = pq.size() - start - howMany; i > 0; i--) { pq.pop(); }
while (unverifiedMatches.size() > 0) { DisiWrapper w = unverifiedMatches.pop(); if (w.twoPhaseView.matches()) {
@Override public int nextDoc() { // Advance all sub iterators past current doc while (true) { if (queue.size() == 0) { doc = NO_MORE_DOCS; break; } int newDoc = queue.top().docID(); if (newDoc != doc) { assert newDoc > doc: "doc=" + doc + " newDoc=" + newDoc; doc = newDoc; break; } if (queue.top().nextDoc() == NO_MORE_DOCS) { queue.pop(); } else { queue.updateTop(); } } return doc; }
int hitUpto = 0; while (hitUpto < numIterOnHits) { assert queue.size() > 0; ShardRef ref = queue.top(); final ScoreDoc hit = shardHits[ref.shardIndex].scoreDocs[ref.hitIndex++];
int lastReaderIndex = 0; boolean isSorted = true; while (queue.size() != 0) { LeafAndDocID top = queue.top(); if (lastReaderIndex > top.readerIndex) {
public Correction[] findBestCandiates(CandidateSet[] sets, float errorFraction, double cutoffScore) throws IOException { if (sets.length == 0) { return Correction.EMPTY; } PriorityQueue<Correction> corrections = new PriorityQueue<Correction>(maxNumCorrections) { @Override protected boolean lessThan(Correction a, Correction b) { return a.compareTo(b) < 0; } }; int numMissspellings = 1; if (errorFraction >= 1.0) { numMissspellings = (int) errorFraction; } else { numMissspellings = Math.round(errorFraction * sets.length); } findCandidates(sets, new Candidate[sets.length], 0, Math.max(1, numMissspellings), corrections, cutoffScore, 0.0); Correction[] result = new Correction[corrections.size()]; for (int i = result.length - 1; i >= 0; i--) { result[i] = corrections.pop(); } assert corrections.size() == 0; return result; }
private void updateTop(CandidateSet[] candidates, Candidate[] path, PriorityQueue<Correction> corrections, double cutoffScore, double score) throws IOException { score = Math.exp(score); assert Math.abs(score - score(path, candidates)) < 0.00001; if (score > cutoffScore) { if (corrections.size() < maxNumCorrections) { Candidate[] c = new Candidate[candidates.length]; System.arraycopy(path, 0, c, 0, path.length); corrections.add(new Correction(score, c)); } else if (corrections.top().compareTo(score, path) < 0) { Correction top = corrections.top(); System.arraycopy(path, 0, top.candidates, 0, path.length); top.score = score; corrections.updateTop(); } } }
int resultSize = Math.max(ordered.size() - from, 0);
Set<Object> seen = new HashSet<>(); while (hitUpto < numIterOnHits) { if (queue.size() == 0) { break;