net.conquiris.lucene.search
Class GuavaCachingFilter

java.lang.Object
  extended by org.apache.lucene.search.Filter
      extended by net.conquiris.lucene.search.GuavaCachingFilter
All Implemented Interfaces:
Serializable

public final class GuavaCachingFilter
extends Filter

A wrapping filter based on Guava Cache. Uses a caching mode equivalent to Lucene's DeletesMode.RECACHE.

Author:
Andres Rodriguez
See Also:
Serialized Form

Method Summary
static
<K,V extends Filter>
LoadingCache<K,Filter>
cachingFactory(CacheLoader<K,V> loader, int primarySize, long primaryDuration, TimeUnit primaryUnit, int secondarySize, long secondaryDuration, TimeUnit secondaryUnit)
          Caching factory method.
 boolean equals(Object o)
           
 DocIdSet getDocIdSet(IndexReader reader)
           
 int hashCode()
           
static GuavaCachingFilter of(Filter filter)
          Factory method with a maximum size of 100 elements and a expiration time of 10 minutes.
static GuavaCachingFilter of(Filter filter, int size, long duration, TimeUnit unit)
          Factory method.
 CacheStats stats()
          Returns a current snapshot of this cache's cumulative statistics.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

cachingFactory

public static <K,V extends Filter> LoadingCache<K,Filter> cachingFactory(CacheLoader<K,V> loader,
                                                                         int primarySize,
                                                                         long primaryDuration,
                                                                         TimeUnit primaryUnit,
                                                                         int secondarySize,
                                                                         long secondaryDuration,
                                                                         TimeUnit secondaryUnit)
Caching factory method. The primary cache is that from the filter key to the cachinf filter. The seondary cache is that contained in the caching filter itself.

Parameters:
loader - Filter loader. Its result will be wrapped in a caching filter.
primarySize - the maximum size of the primary cache.
primaryDuration - the length of time after an entry is last accessed that it should be automatically removed from the primary cache.
primaryUnit - the unit that primaryDuration is expressed in
secondarySize - the maximum size of the secondary cache.
secondaryDuration - the length of time after an entry is last accessed that it should be automatically removed from the secondary cache.
secondaryUnit - the unit that secondaryDuration is expressed in
Throws:
IllegalArgumentException - if any of the sizes is negative
IllegalArgumentException - if any of the durations is negative

of

public static GuavaCachingFilter of(Filter filter,
                                    int size,
                                    long duration,
                                    TimeUnit unit)
Factory method.

Parameters:
filter - Filter to cache results of.
size - the maximum size of the cache.
duration - the length of time after an entry is last accessed that it should be automatically removed.
unit - the unit that duration is expressed in
Throws:
IllegalArgumentException - if size is negative
IllegalArgumentException - if duration is negative

of

public static GuavaCachingFilter of(Filter filter)
Factory method with a maximum size of 100 elements and a expiration time of 10 minutes.

Parameters:
filter - Filter to cache results of

getDocIdSet

public DocIdSet getDocIdSet(IndexReader reader)
                     throws IOException
Specified by:
getDocIdSet in class Filter
Throws:
IOException

stats

public CacheStats stats()
Returns a current snapshot of this cache's cumulative statistics.


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013 Derquinse Projects. All Rights Reserved.