| 1 |
|
package org.apache.lucene.search.spans; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
import java.io.IOException; |
| 20 |
|
|
| 21 |
|
import java.util.List; |
| 22 |
|
import java.util.ArrayList; |
| 23 |
|
|
| 24 |
|
import org.apache.lucene.index.IndexReader; |
| 25 |
|
import org.apache.lucene.util.PriorityQueue; |
| 26 |
|
|
|
|
|
| 85.3% |
Uncovered Elements: 20 (136) |
Complexity: 40 |
Complexity Density: 0.54 |
|
| 27 |
|
class NearSpansUnordered implements Spans { |
| 28 |
|
private SpanNearQuery query; |
| 29 |
|
|
| 30 |
|
private List ordered = new ArrayList(); |
| 31 |
|
private int slop; |
| 32 |
|
|
| 33 |
|
private SpansCell first; |
| 34 |
|
private SpansCell last; |
| 35 |
|
|
| 36 |
|
private int totalLength; |
| 37 |
|
|
| 38 |
|
private CellQueue queue; |
| 39 |
|
private SpansCell max; |
| 40 |
|
|
| 41 |
|
private boolean more = true; |
| 42 |
|
private boolean firstTime = true; |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 44 |
|
private class CellQueue extends PriorityQueue { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 45 |
21
|
public CellQueue(int size) {... |
| 46 |
21
|
initialize(size); |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 49 |
292
|
protected final boolean lessThan(Object o1, Object o2) {... |
| 50 |
292
|
SpansCell spans1 = (SpansCell)o1; |
| 51 |
292
|
SpansCell spans2 = (SpansCell)o2; |
| 52 |
292
|
if (spans1.doc() == spans2.doc()) { |
| 53 |
149
|
return NearSpansOrdered.docSpansOrdered(spans1, spans2); |
| 54 |
|
} else { |
| 55 |
143
|
return spans1.doc() < spans2.doc(); |
| 56 |
|
} |
| 57 |
|
} |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
|
|
|
| 93.5% |
Uncovered Elements: 2 (31) |
Complexity: 14 |
Complexity Density: 0.82 |
|
| 62 |
|
private class SpansCell implements Spans { |
| 63 |
|
private Spans spans; |
| 64 |
|
private SpansCell next; |
| 65 |
|
private int length = -1; |
| 66 |
|
private int index; |
| 67 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 68 |
50
|
public SpansCell(Spans spans, int index) {... |
| 69 |
50
|
this.spans = spans; |
| 70 |
50
|
this.index = index; |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 73 |
149
|
public boolean next() throws IOException {... |
| 74 |
149
|
return adjust(spans.next()); |
| 75 |
|
} |
| 76 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
959
|
public boolean skipTo(int target) throws IOException {... |
| 78 |
959
|
return adjust(spans.skipTo(target)); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 7 |
Complexity Density: 0.78 |
|
| 81 |
1108
|
private boolean adjust(boolean condition) {... |
| 82 |
1108
|
if (length != -1) { |
| 83 |
1058
|
totalLength -= length; |
| 84 |
|
} |
| 85 |
1108
|
if (condition) { |
| 86 |
1087
|
length = end() - start(); |
| 87 |
1087
|
totalLength += length; |
| 88 |
|
|
| 89 |
1087
|
if (max == null || doc() > max.doc() |
| 90 |
|
|| (doc() == max.doc()) && (end() > max.end())) { |
| 91 |
954
|
max = this; |
| 92 |
|
} |
| 93 |
|
} |
| 94 |
1108
|
more = condition; |
| 95 |
1108
|
return condition; |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
7167
|
public int doc() { return spans.doc(); }... |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 99 |
1609
|
public int start() { return spans.start(); }... |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
1581
|
public int end() { return spans.end(); }... |
| 101 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
0
|
public String toString() { return spans.toString() + "#" + index; }... |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|