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

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 (const 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 {} or DeletesMode#DYNAMIC}. More...
virtual | ~CachingWrapperFilter ()
virtual String | getClassName ()
boost::shared_ptr< CachingWrapperFilter > | shared_from_this ()
virtual DocIdSetPtr | getDocIdSet (const 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 (const 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< Filter > | shared_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 (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | compareTo (const 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 (const DocIdSetPtr &docIdSet, const IndexReaderPtr &reader)
| Provide the DocIdSet to be cached, using the DocIdSet provided by the wrapped Filter. More...
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Protected Attributes

FilterCachePtr | cache
| A Filter cache. More...
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## 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

## ◆ DeletesMode

enum Lucene::CachingWrapperFilter::DeletesMode

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

## ◆ CachingWrapperFilter()

Lucene::CachingWrapperFilter::CachingWrapperFilter | ( | const 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 {} or DeletesMode#DYNAMIC}.

## ◆ ~CachingWrapperFilter()

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

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::CachingWrapperFilter::_getClassName | ( |  | ) |

inline static

## ◆ docIdSetToCache()

DocIdSetPtr Lucene::CachingWrapperFilter::docIdSetToCache | ( | const DocIdSetPtr & | docIdSet,
|  | const 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.

## ◆ equals()

virtual bool Lucene::CachingWrapperFilter::equals | ( | const LuceneObjectPtr & | other | ) |

virtual

Return whether two objects are equal.

Reimplemented from Lucene::LuceneObject.

## ◆ getClassName()

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

inline virtual

Reimplemented from Lucene::Filter.

## ◆ getDocIdSet()

virtual DocIdSetPtr Lucene::CachingWrapperFilter::getDocIdSet | ( | const 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

  reader | a 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.

## ◆ hashCode()

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

virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

## ◆ shared_from_this()

boost::shared_ptr< CachingWrapperFilter > Lucene::CachingWrapperFilter::shared_from_this | ( |  | ) |

inline

## ◆ toString()

virtual String Lucene::CachingWrapperFilter::toString | ( |  | ) |

virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

## Field Documentation

## ◆ __pad0__

INTERNAL Lucene::CachingWrapperFilter::__pad0__

## ◆ cache

FilterCachePtr Lucene::CachingWrapperFilter::cache

protected

A Filter cache.

## ◆ hitCount

int32_t Lucene::CachingWrapperFilter::hitCount

## ◆ missCount

int32_t Lucene::CachingWrapperFilter::missCount

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

- CachingWrapperFilter.h

clucene.sourceforge.net