@Override public boolean skipToCandidate(final int target) throws IOException { return scorer.skipToCandidate(target); }
@Override public boolean skipToCandidate(final int target) throws IOException { return reqScorer.skipToCandidate(target); }
@Override public boolean skipToCandidate(final int target) throws IOException { return scorer.skipToCandidate(target); }
@Override public boolean skipToCandidate(final int target) throws IOException { return scorer.skipToCandidate(target); }
@Override public boolean skipToCandidate(final int target) throws IOException { return countingSumScorer.skipToCandidate(target); }
@Override public boolean skipToCandidate(final int target) throws IOException { if (exclScorer == null) { return reqScorer.skipToCandidate(target); } if (!reqScorer.skipToCandidate(target)) { return false; } return this.toNonExcludedCandidateDocument(); }
/** * Move all the scorers to the candidate document beyond (see NOTE below) the * current whose number is greater than or equal to <i>target</i>. * <p> * <b>NOTE:</b> when <code> target ≤ current</code> implementations must * not advance beyond their current {@link #doc()}. * * @return If the least scorer has no more nodes, returns false. */ public final boolean skipToCandidateAndAdjustElsePop(final int target) throws IOException { if (topHSN != null) { while (size > 0 && topHSN.doc < target) { this.checkAdjustElsePop(topHSN.scorer.skipToCandidate(target)); } // no more doc when queue empty return (size > 0); } else { return false; } }
@Override public boolean skipToCandidate(final int target) throws IOException { // reset currentNode and matchStart this.resetCurrentNode(); this.resetStart(); if (!scorer.skipToCandidate(target)) { return false; } this.pendingNode = false; return true; }
@Override public int advance(final int target) throws IOException { if (scorer.skipToCandidate(target)) { do { if (scorer.nextNode()) { return this.docID(); } } while (scorer.nextCandidateDocument()); } return NO_MORE_DOCS; }
/** * Perform a next without initial increment */ private boolean doNext() throws IOException { int first = 0; int doc = scorers[scorers.length - 1].doc(); NodeScorer firstScorer = scorers[first]; boolean more = true; while (firstScorer.doc() < doc) { more = firstScorer.skipToCandidate(doc); doc = firstScorer.doc(); first = first == scorers.length - 1 ? 0 : first + 1; firstScorer = scorers[first]; } return more; }
@Override public boolean skipToCandidate(final int target) throws IOException { if (lastDocument == DocsAndNodesIterator.NO_MORE_DOC) { return false; } else if (scorers[(scorers.length - 1)].doc() < target) { scorers[(scorers.length - 1)].skipToCandidate(target); } final boolean more = this.doNext(); lastDocument = scorers[scorers.length - 1].doc(); lastNode = scorers[scorers.length - 1].node(); return more; }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { return weight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { return weight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc && scorer.nextNode()) { return includeWeight.explain(context, doc); } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public float scoreInNode() throws IOException { final float reqScore = reqScorer.scoreInNode(); final int doc = this.doc(); if (optScorer == null) { return reqScore; } else if (optScorer.doc() < doc && // if it is the first call, optScorer.doc() returns -1 !optScorer.skipToCandidate(doc)) { optScorer = null; return reqScore; } final IntsRef reqNode = this.node(); /* * the optional scorer can be in a node that is before the one where * the required scorer is in. */ int cmp = 1; while ((cmp = NodeUtils.compare(optScorer.node(), reqNode)) < 0) { if (!optScorer.nextNode()) { return reqScore; } } // If the optional scorer matches the same node, increase the score return (optScorer.doc() == doc && cmp == 0) ? reqScore + optScorer.scoreInNode() : reqScore; }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { final Similarity.SimScorer docScorer = similarity.simScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight("+this.getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); while (scorer.nextNode()) { final ComplexExplanation nodeMatch = new ComplexExplanation(); nodeMatch.setDescription("in "+scorer.node()+"), result of:"); final float freq = scorer.freqInNode(); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); nodeMatch.setValue(scoreExplanation.getValue()); nodeMatch.setMatch(true); nodeMatch.addDetail(scoreExplanation); result.addDetail(nodeMatch); } result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { final Similarity.SimScorer docScorer = similarity.simScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight("+this.getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], sum of:"); float sum = 0; while (scorer.nextNode()) { final ComplexExplanation nodeMatch = new ComplexExplanation(); nodeMatch.setDescription("in "+scorer.node()+"), result of:"); final float freq = scorer.freqInNode(); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); nodeMatch.setValue(scoreExplanation.getValue()); sum += scoreExplanation.getValue(); nodeMatch.setMatch(true); nodeMatch.addDetail(scoreExplanation); result.addDetail(nodeMatch); } result.setValue(sum); result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { final Similarity.SimScorer docScorer = similarity.simScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); float sum = 0; result.setDescription("weight("+this.getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], sum of:"); while (scorer.nextNode()) { final ComplexExplanation nodeMatch = new ComplexExplanation(); nodeMatch.setDescription("in "+scorer.node()+"), result of:"); final float freq = scorer.freqInNode(); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); nodeMatch.setValue(scoreExplanation.getValue()); sum += scoreExplanation.getValue(); nodeMatch.setMatch(true); nodeMatch.addDetail(scoreExplanation); result.addDetail(nodeMatch); } result.setValue(sum); result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer cs = (NodeScorer) this.scorer(context, context.reader().getLiveDocs()); final boolean exists = (cs != null && cs.skipToCandidate(doc) && cs.doc() == doc && cs.nextNode()); final ComplexExplanation result = new ComplexExplanation(); if (exists) { result.setDescription(NodeConstantScoreQuery.this.toString() + ", product of:"); result.setValue(queryWeight); result.setMatch(Boolean.TRUE); result.addDetail(new Explanation(NodeConstantScoreQuery.this.getBoost(), "boost")); result.addDetail(new Explanation(queryNorm, "queryNorm")); } else { result.setDescription(NodeConstantScoreQuery.this.toString() + " doesn't match id " + doc); result.setValue(0); result.setMatch(Boolean.FALSE); } return result; } }
); assertTrue(scorer.skipToCandidate(16)); assertEquals(16, scorer.doc()); assertEquals(node(-1), scorer.node()); assertEquals(DocsAndNodesIterator.NO_MORE_NOD, scorer.node()); assertTrue(scorer.skipToCandidate(40)); assertEquals(40, scorer.doc()); assertEquals(node(-1), scorer.node()); assertEquals(DocsAndNodesIterator.NO_MORE_NOD, scorer.node()); assertFalse(scorer.skipToCandidate(65)); assertEndOfStream(scorer);