|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReqOptSumScorer | Line # 25 | 24 | 11 | 85% |
0.85
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (27) | |||
| Result | |||
|
0.85
|
org.apache.lucene.search.TestBooleanMinShouldMatch.testRandomQueries
org.apache.lucene.search.TestBooleanMinShouldMatch.testRandomQueries
|
1 PASS | |
|
0.85
|
org.apache.lucene.search.TestBoolean2.testRandomQueries
org.apache.lucene.search.TestBoolean2.testRandomQueries
|
1 PASS | |
|
0.775
|
org.apache.lucene.search.TestSimpleExplanations.testBQ9
org.apache.lucene.search.TestSimpleExplanations.testBQ9
|
1 PASS | |
|
0.725
|
org.apache.lucene.search.TestSimpleExplanations.testBQ8
org.apache.lucene.search.TestSimpleExplanations.testBQ8
|
1 PASS | |
|
0.65
|
org.apache.lucene.search.TestSimpleExplanations.testBQ3
org.apache.lucene.search.TestSimpleExplanations.testBQ3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testBQ22
org.apache.lucene.search.TestComplexExplanations.testBQ22
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testT3
org.apache.lucene.search.TestComplexExplanations.testT3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testDMQ10
org.apache.lucene.search.TestComplexExplanations.testDMQ10
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testBQ21
org.apache.lucene.search.TestComplexExplanations.testBQ21
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testMA3
org.apache.lucene.search.TestComplexExplanations.testMA3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testSF3
org.apache.lucene.search.TestComplexExplanations.testSF3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.test2
org.apache.lucene.search.TestComplexExplanations.test2
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testMPQ7
org.apache.lucene.search.TestComplexExplanations.testMPQ7
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testBQ18
org.apache.lucene.search.TestComplexExplanations.testBQ18
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testSNot6
org.apache.lucene.search.TestComplexExplanations.testSNot6
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.test1
org.apache.lucene.search.TestComplexExplanations.test1
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testST3
org.apache.lucene.search.TestComplexExplanations.testST3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testSNot3
org.apache.lucene.search.TestComplexExplanations.testSNot3
|
1 PASS | |
|
0.625
|
org.apache.lucene.search.TestComplexExplanations.testSF7
org.apache.lucene.search.TestComplexExplanations.testSF7
|
1 PASS | |
|
0.6
|
org.apache.lucene.search.TestBoolean2.testQueries02
org.apache.lucene.search.TestBoolean2.testQueries02
|
1 PASS | |
|
0.6
|
org.apache.lucene.search.TestBoolean2.testQueries08
org.apache.lucene.search.TestBoolean2.testQueries08
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.TestBoolean2.testQueries10
org.apache.lucene.search.TestBoolean2.testQueries10
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.TestBoolean2.testQueries09
org.apache.lucene.search.TestBoolean2.testQueries09
|
1 PASS | |
|
0.5
|
org.apache.lucene.search.TestComplexExplanations.testCSQ4
org.apache.lucene.search.TestComplexExplanations.testCSQ4
|
1 PASS | |
|
0.5
|
org.apache.lucene.search.TestBooleanOr.testParenthesisMust2
org.apache.lucene.search.TestBooleanOr.testParenthesisMust2
|
1 PASS | |
|
0.5
|
org.apache.lucene.search.TestComplexExplanations.testFQ5
org.apache.lucene.search.TestComplexExplanations.testFQ5
|
1 PASS | |
|
0.15
|
org.apache.lucene.search.TestSimpleExplanations.testBQ5
org.apache.lucene.search.TestSimpleExplanations.testBQ5
|
1 PASS | |
| 1 | package org.apache.lucene.search; | |
| 2 | /** | |
| 3 | * Copyright 2005 Apache Software Foundation. | |
| 4 | * | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 | * you may not use this file except in compliance with the License. | |
| 7 | * You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | import java.io.IOException; | |
| 19 | ||
| 20 | /** A Scorer for queries with a required part and an optional part. | |
| 21 | * Delays skipTo() on the optional part until a score() is needed. | |
| 22 | * <br> | |
| 23 | * This <code>Scorer</code> implements {@link Scorer#skipTo(int)}. | |
| 24 | */ | |
| 25 | public class ReqOptSumScorer extends Scorer { | |
| 26 | /** The scorers passed from the constructor. | |
| 27 | * These are set to null as soon as their next() or skipTo() returns false. | |
| 28 | */ | |
| 29 | private Scorer reqScorer; | |
| 30 | private Scorer optScorer; | |
| 31 | ||
| 32 | /** Construct a <code>ReqOptScorer</code>. | |
| 33 | * @param reqScorer The required scorer. This must match. | |
| 34 | * @param optScorer The optional scorer. This is used for scoring only. | |
| 35 | */ | |
| 36 | 9493 |
public ReqOptSumScorer( |
| 37 | Scorer reqScorer, | |
| 38 | Scorer optScorer) | |
| 39 | { | |
| 40 | 9493 | super(null); // No similarity used. |
| 41 | 9493 | this.reqScorer = reqScorer; |
| 42 | 9493 | this.optScorer = optScorer; |
| 43 | } | |
| 44 | ||
| 45 | private boolean firstTimeOptScorer = true; | |
| 46 | ||
| 47 | 12799 |
public boolean next() throws IOException { |
| 48 | 12799 | return reqScorer.next(); |
| 49 | } | |
| 50 | ||
| 51 | 3803 |
public boolean skipTo(int target) throws IOException { |
| 52 | 3803 | return reqScorer.skipTo(target); |
| 53 | } | |
| 54 | ||
| 55 | 10791 |
public int doc() { |
| 56 | 10791 | return reqScorer.doc(); |
| 57 | } | |
| 58 | ||
| 59 | /** Returns the score of the current document matching the query. | |
| 60 | * Initially invalid, until {@link #next()} is called the first time. | |
| 61 | * @return The score of the required scorer, eventually increased by the score | |
| 62 | * of the optional scorer when it also matches the current document. | |
| 63 | */ | |
| 64 | 6327 |
public float score() throws IOException { |
| 65 | 6327 | int curDoc = reqScorer.doc(); |
| 66 | 6327 | float reqScore = reqScorer.score(); |
| 67 | 6327 | if (firstTimeOptScorer) { |
| 68 | 3186 | firstTimeOptScorer = false; |
| 69 | 3186 | if (! optScorer.skipTo(curDoc)) { |
| 70 | 404 | optScorer = null; |
| 71 | 404 | return reqScore; |
| 72 | } | |
| 73 | 3141 | } else if (optScorer == null) { |
| 74 | 572 | return reqScore; |
| 75 | 2569 | } else if ((optScorer.doc() < curDoc) && (! optScorer.skipTo(curDoc))) { |
| 76 | 266 | optScorer = null; |
| 77 | 266 | return reqScore; |
| 78 | } | |
| 79 | // assert (optScorer != null) && (optScorer.doc() >= curDoc); | |
| 80 | 5085 | return (optScorer.doc() == curDoc) |
| 81 | ? reqScore + optScorer.score() | |
| 82 | : reqScore; | |
| 83 | } | |
| 84 | ||
| 85 | /** Explain the score of a document. | |
| 86 | * @todo Also show the total score. | |
| 87 | * See BooleanScorer.explain() on how to do this. | |
| 88 | */ | |
| 89 | 0 |
public Explanation explain(int doc) throws IOException { |
| 90 | 0 | Explanation res = new Explanation(); |
| 91 | 0 | res.setDescription("required, optional"); |
| 92 | 0 | res.addDetail(reqScorer.explain(doc)); |
| 93 | 0 | res.addDetail(optScorer.explain(doc)); |
| 94 | 0 | return res; |
| 95 | } | |
| 96 | } | |
| 97 | ||
|
||||||||||