org.compass.core.lucene.engine.transaction
Class ReadCommittedTransaction

java.lang.Object
  extended by org.compass.core.lucene.engine.transaction.AbstractTransaction
      extended by org.compass.core.lucene.engine.transaction.ReadCommittedTransaction
All Implemented Interfaces:
LuceneSearchEngineTransaction
Direct Known Subclasses:
SerialableTransaction

public class ReadCommittedTransaction
extends AbstractTransaction

A better implementation of the read committed transaction support. Uses the TransIndex as the transactional index, which means that it does not uses Lucene public API's, as well as Lucene segments management (must use a SearchEngineOptimizer implementation) when using this transaction.

The transactional data is saved (by the TransIndex) in a RAM based engine, and is used when performing find operations with the actual index using Lucene "Multi" readers and searchers support. Deleted resources are save in memory and filtered out from the search results using lucene filtering mechanism. The commit operation adds the transactional data to the original index, and deletes the marked resources for deletions.

By using the TransIndex, the transaction support two phase commits (see the TransIndex documentation).

The transaction allows paralell searching, and single delete/create threads/processess to happen (Using different transaction instances). Note that even when performing dirty operations (delete/create), other thread/processess can perform searchers.

There is no performance penalty when performing pure find operations, the implementation is samrt enough and only creates the transactional supprot when needed (i.e, when using dirty operations - create / delete).

Author:
kimchy

Nested Class Summary
 class ReadCommittedTransaction.TransIndexManager
           
static class ReadCommittedTransaction.TransIndexWrapper
           
 
Field Summary
protected  ReadCommittedTransaction.TransIndexManager transIndexManager
           
 
Fields inherited from class org.compass.core.lucene.engine.transaction.AbstractTransaction
analyzerManager, dirty, indexManager, mapping, searchEngine
 
Constructor Summary
ReadCommittedTransaction()
           
 
Method Summary
protected  void doBegin()
           
protected  void doCommit(boolean onePhase)
           
protected  void doCreate(InternalResource resource)
           
protected  void doDelete(ResourceKey resourceKey)
           
protected  SearchEngineHits doFind(LuceneSearchEngineQuery query)
           
protected  SearchEngineInternalSearch doInternalSearch(String[] subIndexes, String[] aliases)
           
protected  void doPrepare()
           
protected  void doRollback()
           
 Resource[] find(ResourceKey resourceKey)
           
 void flush()
          Supported only in batch insert transacitons.
 
Methods inherited from class org.compass.core.lucene.engine.transaction.AbstractTransaction
begin, closeDelegateClosed, commit, configure, create, delete, find, getResourceMapping, internalSearch, isDirty, prepare, rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transIndexManager

protected ReadCommittedTransaction.TransIndexManager transIndexManager
Constructor Detail

ReadCommittedTransaction

public ReadCommittedTransaction()
Method Detail

doBegin

protected void doBegin()
                throws SearchEngineException
Specified by:
doBegin in class AbstractTransaction
Throws:
SearchEngineException

doPrepare

protected void doPrepare()
                  throws SearchEngineException
Specified by:
doPrepare in class AbstractTransaction
Throws:
SearchEngineException

doCommit

protected void doCommit(boolean onePhase)
                 throws SearchEngineException
Specified by:
doCommit in class AbstractTransaction
Throws:
SearchEngineException

doRollback

protected void doRollback()
                   throws SearchEngineException
Specified by:
doRollback in class AbstractTransaction
Throws:
SearchEngineException

flush

public void flush()
           throws SearchEngineException
Description copied from interface: LuceneSearchEngineTransaction
Supported only in batch insert transacitons.

Throws:
SearchEngineException

doCreate

protected void doCreate(InternalResource resource)
                 throws SearchEngineException
Specified by:
doCreate in class AbstractTransaction
Throws:
SearchEngineException

doDelete

protected void doDelete(ResourceKey resourceKey)
                 throws SearchEngineException
Specified by:
doDelete in class AbstractTransaction
Throws:
SearchEngineException

find

public Resource[] find(ResourceKey resourceKey)
                throws SearchEngineException
Throws:
SearchEngineException

doInternalSearch

protected SearchEngineInternalSearch doInternalSearch(String[] subIndexes,
                                                      String[] aliases)
                                               throws SearchEngineException
Specified by:
doInternalSearch in class AbstractTransaction
Throws:
SearchEngineException

doFind

protected SearchEngineHits doFind(LuceneSearchEngineQuery query)
                           throws SearchEngineException
Specified by:
doFind in class AbstractTransaction
Throws:
SearchEngineException


Copyright (c) 2004-2006 The Compass Project.