Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
42   166   23   2.1
8   104   0.55   6.67
20     1.15  
3    
 
  ConstantScoreQuery       Line # 32 11 9 95.8% 0.9583333
  ConstantScoreQuery.ConstantWeight       Line # 48 21 8 93.3% 0.93333334
  ConstantScoreQuery.ConstantScorer       Line # 103 10 6 87.5% 0.875
 
  (20)
 
1    package org.apache.lucene.search;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19    import org.apache.lucene.index.IndexReader;
20   
21    import java.io.IOException;
22    import java.util.BitSet;
23    import java.util.Set;
24   
25    /**
26    * A query that wraps a filter and simply returns a constant score equal to the
27    * query boost for every document in the filter.
28    *
29    * @author yonik
30    * @version $Id: ConstantScoreQuery.java 417275 2006-06-26 18:38:47Z hossman $
31    */
 
32    public class ConstantScoreQuery extends Query {
33    protected final Filter filter;
34   
 
35  97563 toggle public ConstantScoreQuery(Filter filter) {
36  97563 this.filter=filter;
37    }
38   
 
39  97607 toggle public Query rewrite(IndexReader reader) throws IOException {
40  97607 return this;
41    }
42   
 
43  0 toggle public void extractTerms(Set terms) {
44    // OK to not add any terms when used for MultiSearcher,
45    // but may not be OK for highlighting
46    }
47   
 
48    protected class ConstantWeight implements Weight {
49    private Similarity similarity;
50    private float queryNorm;
51    private float queryWeight;
52   
 
53  97607 toggle public ConstantWeight(Searcher searcher) {
54  97607 this.similarity = getSimilarity(searcher);
55    }
56   
 
57  0 toggle public Query getQuery() {
58  0 return ConstantScoreQuery.this;
59    }
60   
 
61  97607 toggle public float getValue() {
62  97607 return queryWeight;
63    }
64   
 
65  97607 toggle public float sumOfSquaredWeights() throws IOException {
66  97607 queryWeight = getBoost();
67  97607 return queryWeight * queryWeight;
68    }
69   
 
70  97607 toggle public void normalize(float norm) {
71  97607 this.queryNorm = norm;
72  97607 queryWeight *= this.queryNorm;
73    }
74   
 
75  97607 toggle public Scorer scorer(IndexReader reader) throws IOException {
76