CachingWrapperFilter.javaAPI DocApache Lucene 2.2.02309Sat Jun 16 22:20:34 BST


public class CachingWrapperFilter extends Filter
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.

Fields Summary
protected Filter
protected transient Map
A transient Filter cache. To cache Filters even when using {@link RemoteSearchable} use {@link RemoteCachingWrapperFilter} instead.
Constructors Summary
public CachingWrapperFilter(Filter filter)

filter Filter to cache results of

    this.filter = filter;
Methods Summary
public java.util.BitSetbits(org.apache.lucene.index.IndexReader reader)

    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 booleanequals(java.lang.Object o)

    if (!(o instanceof CachingWrapperFilter)) return false;
    return this.filter.equals(((CachingWrapperFilter)o).filter);
public inthashCode()

    return filter.hashCode() ^ 0x1117BF25;  
public java.lang.StringtoString()

    return "CachingWrapperFilter("+filter+")";