org.apache.lucene.search
public class: CachingWrapperFilter [javadoc |
source]
java.lang.Object
org.apache.lucene.search.Filter
org.apache.lucene.search.CachingWrapperFilter
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
QueryFilter
Wraps another filter's result and caches it. The purpose is to allow
filters to simply filter, and then wrap with this class to add caching.
| Field Summary |
|---|
| protected Filter | filter | |
| protected transient Map | cache | A transient Filter cache. To cache Filters even when using RemoteSearchable use
RemoteCachingWrapperFilter instead. |
| Methods from org.apache.lucene.search.Filter: |
|---|
|
bits |
| Method from org.apache.lucene.search.CachingWrapperFilter Detail: |
public BitSet bits(IndexReader reader) throws IOException {
if (cache == null) {
cache = new WeakHashMap();
}
synchronized (cache) { // check cache
BitSet cached = (BitSet) cache.get(reader);
if (cached != null) {
return cached;
}
}
final BitSet bits = filter.bits(reader);
synchronized (cache) { // update cache
cache.put(reader, bits);
}
return bits;
}
|
public boolean equals(Object o) {
if (!(o instanceof CachingWrapperFilter)) return false;
return this.filter.equals(((CachingWrapperFilter)o).filter);
}
|
public int hashCode() {
return filter.hashCode() ^ 0x1117BF25;
}
|
public String toString() {
return "CachingWrapperFilter("+filter+")";
}
|