mirror of https://github.com/apache/lucene.git
- Fixed bug 20290
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20290 - Added @version. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2310d71e07
commit
2357f0c106
|
@ -68,10 +68,12 @@ import org.apache.lucene.index.IndexReader;
|
||||||
* QueryFilter that matches, e.g., only documents modified within the last
|
* QueryFilter that matches, e.g., only documents modified within the last
|
||||||
* week. The QueryFilter and RangeQuery would only need to be reconstructed
|
* week. The QueryFilter and RangeQuery would only need to be reconstructed
|
||||||
* once per day.
|
* once per day.
|
||||||
|
*
|
||||||
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QueryFilter extends Filter {
|
public class QueryFilter extends Filter {
|
||||||
private Query query;
|
private Query query;
|
||||||
private transient WeakHashMap cache = new WeakHashMap();
|
private transient WeakHashMap cache = null;
|
||||||
|
|
||||||
/** Constructs a filter which only matches documents matching
|
/** Constructs a filter which only matches documents matching
|
||||||
* <code>query</code>.
|
* <code>query</code>.
|
||||||
|
@ -82,6 +84,10 @@ public class QueryFilter extends Filter {
|
||||||
|
|
||||||
public BitSet bits(IndexReader reader) throws IOException {
|
public BitSet bits(IndexReader reader) throws IOException {
|
||||||
|
|
||||||
|
if (cache == null) {
|
||||||
|
cache = new WeakHashMap();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (cache) { // check cache
|
synchronized (cache) { // check cache
|
||||||
BitSet cached = (BitSet) cache.get(reader);
|
BitSet cached = (BitSet) cache.get(reader);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
|
@ -97,7 +103,6 @@ public class QueryFilter extends Filter {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
synchronized (cache) { // update cache
|
synchronized (cache) { // update cache
|
||||||
cache.put(reader, bits);
|
cache.put(reader, bits);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue