Lucene++ - a full-featured, c++ search engine
API Documentation


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Lucene::CachingWrapperFilter Class Reference

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. More...

#include <CachingWrapperFilter.h>

+ Inheritance diagram for Lucene::CachingWrapperFilter:

Public Types

enum  DeletesMode { DELETES_IGNORE, DELETES_RECACHE, DELETES_DYNAMIC }
 Specifies how new deletions against a reopened reader should be handled. More...
 

Public Member Functions

 CachingWrapperFilter (FilterPtr filter, DeletesMode deletesMode=DELETES_IGNORE)
 New deletes are ignored by default, which gives higher cache hit rate on reopened readers. Most of the time this is safe, because the filter will be AND'd with a Query that fully enforces deletions. If instead you need this filter to always enforce deletions, pass either DeletesMode#RECACHE or DeletesMode#DYNAMIC. More...
 
virtual ~CachingWrapperFilter ()
 
virtual String getClassName ()
 
boost::shared_ptr
< CachingWrapperFilter
shared_from_this ()
 
virtual DocIdSetPtr getDocIdSet (IndexReaderPtr reader)
 Creates a DocIdSet enumerating the documents that should be permitted in search results. More...
 
virtual String toString ()
 Returns a string representation of the object. More...
 
virtual bool equals (LuceneObjectPtr other)
 Return whether two objects are equal. More...
 
virtual int32_t hashCode ()
 Return hash code for this object. More...
 
- Public Member Functions inherited from Lucene::Filter
virtual ~Filter ()
 
boost::shared_ptr< Filtershared_from_this ()
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed. More...
 
virtual LuceneObjectPtr clone (LuceneObjectPtr other=LuceneObjectPtr())
 Return clone of this object. More...
 
virtual int32_t compareTo (LuceneObjectPtr other)
 Compare two objects. More...
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock. More...
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal. More...
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout. More...
 
virtual void unlock ()
 Unlock this object. More...
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread. More...
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout. More...
 
virtual void notifyAll ()
 Notify all threads waiting for signal. More...
 

Static Public Member Functions

static String _getClassName ()
 
- Static Public Member Functions inherited from Lucene::Filter
static String _getClassName ()
 

Data Fields

INTERNAL __pad0__: FilterPtr filter
 
int32_t hitCount
 
int32_t missCount
 

Protected Member Functions

DocIdSetPtr docIdSetToCache (DocIdSetPtr docIdSet, IndexReaderPtr reader)
 Provide the DocIdSet to be cached, using the DocIdSet provided by the wrapped Filter. More...
 

Protected Attributes

FilterCachePtr cache
 A Filter cache. More...
 

Detailed Description

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.

Member Enumeration Documentation

Specifies how new deletions against a reopened reader should be handled.

The default is IGNORE, which means the cache entry will be re-used for a given segment, even when that segment has been reopened due to changes in deletions. This is a big performance gain, especially with near-real-timer readers, since you don't hit a cache miss on every reopened reader for prior segments.

However, in some cases this can cause invalid query results, allowing deleted documents to be returned. This only happens if the main query does not rule out deleted documents on its own, such as a toplevel ConstantScoreQuery. To fix this, use RECACHE to re-create the cached filter (at a higher per-reopen cost, but at faster subsequent search performance), or use DYNAMIC to dynamically intersect deleted docs (fast reopen time but some hit to search performance).

Enumerator
DELETES_IGNORE 
DELETES_RECACHE 
DELETES_DYNAMIC 

Constructor & Destructor Documentation

Lucene::CachingWrapperFilter::CachingWrapperFilter ( FilterPtr  filter,
DeletesMode  deletesMode = DELETES_IGNORE 
)

New deletes are ignored by default, which gives higher cache hit rate on reopened readers. Most of the time this is safe, because the filter will be AND'd with a Query that fully enforces deletions. If instead you need this filter to always enforce deletions, pass either DeletesMode#RECACHE or DeletesMode#DYNAMIC.

virtual Lucene::CachingWrapperFilter::~CachingWrapperFilter ( )
virtual

Member Function Documentation

static String Lucene::CachingWrapperFilter::_getClassName ( )
inlinestatic
DocIdSetPtr Lucene::CachingWrapperFilter::docIdSetToCache ( DocIdSetPtr  docIdSet,
IndexReaderPtr  reader 
)
protected

Provide the DocIdSet to be cached, using the DocIdSet provided by the wrapped Filter.

This implementation returns the given DocIdSet, if DocIdSet#isCacheable returns true, else it copies the DocIdSetIterator into an OpenBitSetDISI.

virtual bool Lucene::CachingWrapperFilter::equals ( LuceneObjectPtr  other)
virtual

Return whether two objects are equal.

Reimplemented from Lucene::LuceneObject.

virtual String Lucene::CachingWrapperFilter::getClassName ( )
inlinevirtual

Reimplemented from Lucene::Filter.

virtual DocIdSetPtr Lucene::CachingWrapperFilter::getDocIdSet ( IndexReaderPtr  reader)
virtual

Creates a DocIdSet enumerating the documents that should be permitted in search results.

Note: null can be returned if no documents are accepted by this Filter.

Note: This method will be called once per segment in the index during searching. The returned DocIdSet must refer to document IDs for that segment, not for the top-level reader.

Parameters
readera IndexReader instance opened on the index currently searched on. Note, it is likely that the provided reader does not represent the whole underlying index ie. if the index has more than one segment the given reader only represents a single segment.
Returns
a DocIdSet that provides the documents which should be permitted or prohibited in search results. NOTE: null can be returned if no documents will be accepted by this Filter.
See Also
DocIdBitSet

Implements Lucene::Filter.

virtual int32_t Lucene::CachingWrapperFilter::hashCode ( )
virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

boost::shared_ptr< CachingWrapperFilter > Lucene::CachingWrapperFilter::shared_from_this ( )
inline
virtual String Lucene::CachingWrapperFilter::toString ( )
virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

Field Documentation

INTERNAL Lucene::CachingWrapperFilter::__pad0__
FilterCachePtr Lucene::CachingWrapperFilter::cache
protected

A Filter cache.

int32_t Lucene::CachingWrapperFilter::hitCount
int32_t Lucene::CachingWrapperFilter::missCount

The documentation for this class was generated from the following file:

clucene.sourceforge.net