| 1 |
|
package org.apache.lucene.search; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
import java.io.IOException; |
| 20 |
|
|
|
|
|
| 73.5% |
Uncovered Elements: 36 (136) |
Complexity: 40 |
Complexity Density: 0.51 |
|
| 21 |
|
final class BooleanScorer extends Scorer { |
| 22 |
|
private SubScorer scorers = null; |
| 23 |
|
private BucketTable bucketTable = new BucketTable(this); |
| 24 |
|
|
| 25 |
|
private int maxCoord = 1; |
| 26 |
|
private float[] coordFactors = null; |
| 27 |
|
|
| 28 |
|
private int requiredMask = 0; |
| 29 |
|
private int prohibitedMask = 0; |
| 30 |
|
private int nextMask = 1; |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 32 |
1706
|
BooleanScorer(Similarity similarity) {... |
| 33 |
1706
|
super(similarity); |
| 34 |
|
} |
| 35 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 36 |
|
static final class SubScorer { |
| 37 |
|
public Scorer scorer; |
| 38 |
|
public boolean done; |
| 39 |
|
public boolean required = false; |
| 40 |
|
public boolean prohibited = false; |
| 41 |
|
public HitCollector collector; |
| 42 |
|
public SubScorer next; |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 44 |
5980
|
public SubScorer(Scorer scorer, boolean required, boolean prohibited,... |
| 45 |
|
HitCollector collector, SubScorer next) |
| 46 |
|
throws IOException { |
| 47 |
5980
|
this.scorer = scorer; |
| 48 |
5980
|
this.done = !scorer.next(); |
| 49 |
5980
|
this.required = required; |
| 50 |
5980
|
this.prohibited = prohibited; |
| 51 |
5980
|
this.collector = collector; |
| 52 |
5980
|
this.next = next; |
| 53 |
|
} |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 56 |
5980
|
final void add(Scorer scorer, boolean required, boolean prohibited)... |
| 57 |
|
throws IOException { |
| 58 |
5980
|
int mask = 0; |
| 59 |
5980
|
if (required || prohibited) { |
| 60 |
2953
|
if (nextMask == 0) |
| 61 |
0
|
throw new IndexOutOfBoundsException |
| 62 |
|
("More than 32 required/prohibited clauses in query."); |
| 63 |
2953
|
mask = nextMask; |
| 64 |
2953
|
nextMask = nextMask << 1; |
| 65 |
|
} else |
| 66 |
3027
|
mask = 0; |
| 67 |
|
|
| 68 |
5980
|
if (!prohibited) |
| 69 |
4774
|
maxCoord++; |
| 70 |
|
|
| 71 |
5980
|
if (prohibited) |
| 72 |
1206
|
prohibitedMask |= mask; |
| 73 |
4774
|
else if (required) |
| 74 |
1747
|
requiredMask |= mask; |
| 75 |
|
|
| 76 |
5980
|
scorers = new SubScorer(scorer, required, prohibited, |
| 77 |
|
bucketTable.newCollector(mask), scorers); |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 80 |
1354
|
private final void computeCoordFactors() {... |
| 81 |
1354
|
coordFactors = new float[maxCoord]; |
| 82 |
6502
|
for (int i = 0; i < maxCoord; i++) |
| 83 |
5148
|
coordFactors[i] = getSimilarity().coord(i, maxCoord-1); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
private int end; |
| 87 |
|
private Bucket current; |
| 88 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 89 |
912
|
public void score(HitCollector hc) throws IOException {... |
| 90 |
912
|
next(); |
| 91 |
912
|
score(hc, Integer.MAX_VALUE); |
| 92 |
|
} |
| 93 |
|
|
|
|
|
| 61.7% |
Uncovered Elements: 18 (47) |
Complexity: 12 |
Complexity Density: 0.41 |
|
| 94 |
912
|
protected boolean score(HitCollector hc, int max) throws IOException {... |
| 95 |
912
|
if (coordFactors == null) |
| 96 |
912
|
computeCoordFactors(); |
| 97 |
|
|
| 98 |
912
|
boolean more; |
| 99 |
912
|
Bucket tmp; |
| 100 |
|
|
| 101 |
912
|
do { |
| 102 |
912
|
bucketTable.first = null; |
| 103 |
|
|
| 104 |
2756
|
while (current != null) { |
| 105 |
|
|
| 106 |
|
|
| 107 |
1844
|
if ((current.bits & prohibitedMask) == 0 && |
| 108 |
|
(current.bits & requiredMask) == requiredMask) { |
| 109 |
|
|
| 110 |
1215
|
if (current.doc >= max){ |
| 111 |
0
|
tmp = current; |
| 112 |
<