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


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

A MergeScheduler that runs each merge using a separate thread, up until a maximum number of threads (setMaxThreadCount) at which when a merge is needed, the thread(s) that are updating the index will pause until one or more merges completes. This is a simple way to use concurrency in the indexing process without having to create and manage application level threads. More...

#include <ConcurrentMergeScheduler.h>

+ Inheritance diagram for Lucene::ConcurrentMergeScheduler:

Public Member Functions

 ConcurrentMergeScheduler ()
virtual ~ConcurrentMergeScheduler ()
virtual String getClassName ()
boost::shared_ptr
< ConcurrentMergeScheduler
shared_from_this ()
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
virtual void setMaxThreadCount (int32_t count)
 Sets the max # simultaneous threads that may be running. If a merge is necessary yet we already have this many threads running, the incoming thread (that is calling add/updateDocument) will block until a merge thread has completed.
virtual int32_t getMaxThreadCount ()
 Get the max # simultaneous threads that may be running.
virtual int32_t getMergeThreadPriority ()
 Return the priority that merge threads run at. By default the priority is 1 plus the priority of (ie, slightly higher priority than) the first thread that calls merge.
virtual void setMergeThreadPriority (int32_t pri)
 Set the priority that merge threads run at.
virtual void close ()
 Close this MergeScheduler.
virtual void sync ()
virtual void merge (const IndexWriterPtr &writer)
 Run the merges provided by IndexWriter#getNextMerge().
void setSuppressExceptions ()
 Used for testing.
void clearSuppressExceptions ()
- Public Member Functions inherited from Lucene::MergeScheduler
virtual ~MergeScheduler ()
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Return clone of this object.
virtual int32_t hashCode ()
 Return hash code for this object.
virtual bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
virtual String toString ()
 Returns a string representation of the object.
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
virtual void unlock ()
 Unlock this object.
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
virtual void notifyAll ()
 Notify all threads waiting for signal.

Static Public Member Functions

static String _getClassName ()
static bool anyUnhandledExceptions ()
 Used for testing.
static void clearUnhandledExceptions ()
static void setTestMode ()
 Used for testing.

Protected Member Functions

virtual bool verbose ()
virtual void message (const String &message)
virtual void initMergeThreadPriority ()
virtual int32_t mergeThreadCount ()
virtual void doMerge (const OneMergePtr &merge)
 Does the actual merge, by calling IndexWriter#merge.
virtual MergeThreadPtr getMergeThread (const IndexWriterPtr &writer, const OneMergePtr &merge)
virtual void handleMergeException (const LuceneException &exc)
 Called when an exception is hit in a background merge thread.
virtual void addMyself ()

Protected Attributes

int32_t mergeThreadPriority
SetMergeThread mergeThreads
int32_t maxThreadCount
 Max number of threads allowed to be merging at once.
DirectoryPtr dir
bool closed
IndexWriterWeakPtr _writer
bool suppressExceptions

Static Protected Attributes

static Collection
< ConcurrentMergeSchedulerPtr
allInstances
static bool anyExceptions

Detailed Description

A MergeScheduler that runs each merge using a separate thread, up until a maximum number of threads (setMaxThreadCount) at which when a merge is needed, the thread(s) that are updating the index will pause until one or more merges completes. This is a simple way to use concurrency in the indexing process without having to create and manage application level threads.

Constructor & Destructor Documentation

Lucene::ConcurrentMergeScheduler::ConcurrentMergeScheduler ( )
virtual Lucene::ConcurrentMergeScheduler::~ConcurrentMergeScheduler ( )
virtual

Member Function Documentation

static String Lucene::ConcurrentMergeScheduler::_getClassName ( )
inlinestatic

Reimplemented from Lucene::MergeScheduler.

virtual void Lucene::ConcurrentMergeScheduler::addMyself ( )
protectedvirtual
static bool Lucene::ConcurrentMergeScheduler::anyUnhandledExceptions ( )
static

Used for testing.

void Lucene::ConcurrentMergeScheduler::clearSuppressExceptions ( )
static void Lucene::ConcurrentMergeScheduler::clearUnhandledExceptions ( )
static
virtual void Lucene::ConcurrentMergeScheduler::close ( )
virtual

Close this MergeScheduler.

Implements Lucene::MergeScheduler.

virtual void Lucene::ConcurrentMergeScheduler::doMerge ( const OneMergePtr merge)
protectedvirtual

Does the actual merge, by calling IndexWriter#merge.

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

Reimplemented from Lucene::MergeScheduler.

virtual int32_t Lucene::ConcurrentMergeScheduler::getMaxThreadCount ( )
virtual

Get the max # simultaneous threads that may be running.

See Also
setMaxThreadCount.
virtual MergeThreadPtr Lucene::ConcurrentMergeScheduler::getMergeThread ( const IndexWriterPtr writer,
const OneMergePtr merge 
)
protectedvirtual
virtual int32_t Lucene::ConcurrentMergeScheduler::getMergeThreadPriority ( )
virtual

Return the priority that merge threads run at. By default the priority is 1 plus the priority of (ie, slightly higher priority than) the first thread that calls merge.

virtual void Lucene::ConcurrentMergeScheduler::handleMergeException ( const LuceneException exc)
protectedvirtual

Called when an exception is hit in a background merge thread.

virtual void Lucene::ConcurrentMergeScheduler::initialize ( )
virtual

Called directly after instantiation to create objects that depend on this object being fully constructed.

Reimplemented from Lucene::LuceneObject.

virtual void Lucene::ConcurrentMergeScheduler::initMergeThreadPriority ( )
protectedvirtual
virtual void Lucene::ConcurrentMergeScheduler::merge ( const IndexWriterPtr writer)
virtual

Run the merges provided by IndexWriter#getNextMerge().

Implements Lucene::MergeScheduler.

virtual int32_t Lucene::ConcurrentMergeScheduler::mergeThreadCount ( )
protectedvirtual
virtual void Lucene::ConcurrentMergeScheduler::message ( const String &  message)
protectedvirtual
virtual void Lucene::ConcurrentMergeScheduler::setMaxThreadCount ( int32_t  count)
virtual

Sets the max # simultaneous threads that may be running. If a merge is necessary yet we already have this many threads running, the incoming thread (that is calling add/updateDocument) will block until a merge thread has completed.

virtual void Lucene::ConcurrentMergeScheduler::setMergeThreadPriority ( int32_t  pri)
virtual

Set the priority that merge threads run at.

void Lucene::ConcurrentMergeScheduler::setSuppressExceptions ( )

Used for testing.

static void Lucene::ConcurrentMergeScheduler::setTestMode ( )
static

Used for testing.

boost::shared_ptr< ConcurrentMergeScheduler > Lucene::ConcurrentMergeScheduler::shared_from_this ( )
inline

Reimplemented from Lucene::MergeScheduler.

virtual void Lucene::ConcurrentMergeScheduler::sync ( )
virtual
virtual bool Lucene::ConcurrentMergeScheduler::verbose ( )
protectedvirtual

Field Documentation

IndexWriterWeakPtr Lucene::ConcurrentMergeScheduler::_writer
protected
Collection<ConcurrentMergeSchedulerPtr> Lucene::ConcurrentMergeScheduler::allInstances
staticprotected
bool Lucene::ConcurrentMergeScheduler::anyExceptions
staticprotected
bool Lucene::ConcurrentMergeScheduler::closed
protected
DirectoryPtr Lucene::ConcurrentMergeScheduler::dir
protected
int32_t Lucene::ConcurrentMergeScheduler::maxThreadCount
protected

Max number of threads allowed to be merging at once.

int32_t Lucene::ConcurrentMergeScheduler::mergeThreadPriority
protected
SetMergeThread Lucene::ConcurrentMergeScheduler::mergeThreads
protected
bool Lucene::ConcurrentMergeScheduler::suppressExceptions
protected

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

clucene.sourceforge.net