| 1 |
|
package org.apache.lucene.index; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
import java.io.IOException; |
| 20 |
|
import java.util.Arrays; |
| 21 |
|
import java.util.Iterator; |
| 22 |
|
import java.util.LinkedList; |
| 23 |
|
import java.util.List; |
| 24 |
|
|
| 25 |
|
import org.apache.lucene.util.PriorityQueue; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@author |
| 31 |
|
@version |
| 32 |
|
|
|
|
|
| 83.6% |
Uncovered Elements: 10 (61) |
Complexity: 20 |
Complexity Density: 0.57 |
|
| 33 |
|
public class MultipleTermPositions implements TermPositions { |
| 34 |
|
|
|
|
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 35 |
|
private static final class TermPositionsQueue extends PriorityQueue { |
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 36 |
47
|
TermPositionsQueue(List termPositions) throws IOException {... |
| 37 |
47
|
initialize(termPositions.size()); |
| 38 |
|
|
| 39 |
47
|
Iterator i = termPositions.iterator(); |
| 40 |
153
|
while (i.hasNext()) { |
| 41 |
106
|
TermPositions tp = (TermPositions) i.next(); |
| 42 |
106
|
if (tp.next()) |
| 43 |
106
|
put(tp); |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 47 |
783
|
final TermPositions peek() {... |
| 48 |
783
|
return (TermPositions) top(); |
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
323
|
public final boolean lessThan(Object a, Object b) {... |
| 52 |
323
|
return ((TermPositions) a).doc() < ((TermPositions) b).doc(); |
| 53 |
|
} |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 65% |
Uncovered Elements: 7 (20) |
Complexity: 7 |
Complexity Density: 0.58 |
|
| 56 |
|
private static final class IntQueue { |
| 57 |
|
private int _arraySize = 16; |
| 58 |
|
private int _index = 0; |
| 59 |
|
private int _lastIndex = 0; |
| 60 |
|
private int[] _array = new int[_arraySize]; |
| 61 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 62 |
325
|
final void add(int i) {... |
| 63 |
325
|
if (_lastIndex == _arraySize) |
| 64 |
0
|
growArray(); |
| 65 |
|
|
| 66 |
325
|
_array[_lastIndex++] = i; |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 69 |
230
|
final int next() {... |
| 70 |
230
|
return _array[_index++]; |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 73 |
148
|
final void sort() {... |
| 74 |
148
|
Arrays.sort(_array, _index, _lastIndex); |
| 75 |
|
} |
| 76 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 77 |
148
|
final void clear() {... |
| 78 |
148
|
_index = 0; |
| 79 |
148
|
_lastIndex = 0; |
| 80 |
|
} |
| 81 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
148
|
final int size() {... |
| 83 |
148
|
return (_lastIndex - _index); |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 86 |
0
|
private void growArray() {... |
| 87 |
0
|
int[] newArray = new int[_arraySize * 2]; |
| 88 |
0
|
System.arraycopy(_array, 0, newArray, 0, _arraySize); |
| 89 |
0
|
_array = newArray; |
| 90 |
0
|
_arraySize *= 2; |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
private int _doc; |
| 95 |
|
private int _freq; |
| 96 |
|
private TermPositionsQueue _termPositionsQueue; |
| 97 |
|
private IntQueue _posList; |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
@exception |
| 103 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 104 |
47
|
public MultipleTermPositions(IndexReader indexReader, Term[] terms) throws IOException {... |
| 105 |
47
|
List termPositions = new LinkedList(); |
| 106 |
|
|
| 107 |
153
|
for (int i = 0; i < terms.length; i++) |
| 108 |
106
|
termPositions.add(indexReader.termPositions(terms[i])); |
| 109 |
|
|
| 110 |
47
|
_termPositionsQueue = new TermPositionsQueue(termPositions); |
| 111 |
47
|
|