| 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 |
|
import java.util.WeakHashMap; |
| 21 |
|
import java.util.BitSet; |
| 22 |
|
import org.apache.lucene.index.IndexReader; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
@link |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@version |
| 35 |
|
|
|
|
|
| 63.3% |
Uncovered Elements: 11 (30) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 36 |
|
public class QueryFilter extends Filter { |
| 37 |
|
private Query query; |
| 38 |
|
private transient WeakHashMap cache = null; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
3
|
public QueryFilter(Query query) {... |
| 44 |
3
|
this.query = query; |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 47 |
3
|
public BitSet bits(IndexReader reader) throws IOException {... |
| 48 |
|
|
| 49 |
3
|
if (cache == null) { |
| 50 |
3
|
cache = new WeakHashMap(); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
3
|
synchronized (cache) { |
| 54 |
3
|
BitSet cached = (BitSet) cache.get(reader); |
| 55 |
3
|
if (cached != null) { |
| 56 |
0
|
return cached; |
| 57 |
|
} |
| 58 |
|
} |
| 59 |
|
|
| 60 |
3
|
final BitSet bits = new BitSet(reader.maxDoc()); |
| 61 |
|
|
| 62 |
3
|
new IndexSearcher(reader).search(query, new HitCollector() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
2
|
public final void collect(int doc, float score) {... |
| 64 |
2
|
bits.set(doc); |
| 65 |
|
} |
| 66 |
|
}); |
| 67 |
|
|
| 68 |
3
|
synchronized (cache) { |
| 69 |
3
|
cache.put(reader, bits); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
3
|
return bits; |
| 73 |
|
} |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0
|
public String toString() {... |
| 76 |
0
|
return "QueryFilter("+query+")"; |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 79 |
0
|
public boolean equals(Object o) {... |
| 80 |
0
|
if (!(o instanceof QueryFilter)) return false; |
| 81 |
0
|
return this.query.equals(((QueryFilter)o).query); |
| 82 |
|
} |
| 83 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
1
|
public int hashCode() {... |
| 85 |
1
|
return query.hashCode() ^ 0x923F64B9; |
| 86 |
|
} |
| 87 |
|
} |