com.atlassian.bonnie.index
Class OnlineMultiThreadedIndexer

java.lang.Object
  extended by com.atlassian.bonnie.index.BaseMultiThreadedIndexer
      extended by com.atlassian.bonnie.index.OnlineMultiThreadedIndexer
All Implemented Interfaces:
BatchOpIndexer, SingleObjectIndexer

public class OnlineMultiThreadedIndexer
extends BaseMultiThreadedIndexer
implements SingleObjectIndexer

Performs batch indexing in multiple threads.

This class is designed for:

Each thread writes to its own temporary index and when all threads finish, these are merged into the final index. This has the desirable effect where a few large files do not bottleneck the entire operation.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.bonnie.index.BatchOpIndexer
BatchOpIndexer.DocumentWritingScheme
 
Field Summary
protected  edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue reindexAddedQueue
           
protected  edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue reindexDeletedQueue
           
 
Fields inherited from class com.atlassian.bonnie.index.BaseMultiThreadedIndexer
log, luceneConnection
 
Constructor Summary
OnlineMultiThreadedIndexer()
           
 
Method Summary
protected  void allThreadsComplete(BatchOpIndexer.DocumentWritingScheme scheme, boolean truncate, com.atlassian.core.util.ProgressWrapper progress)
          Perform clean-up operations such as closing writers, optimizing, merging with original index, etc.
protected  void doAdd(java.lang.Object o, org.apache.lucene.index.IndexWriter writer)
          Performs the actual adding of the object to the index.
protected  void doDelete(java.lang.Object o, org.apache.lucene.index.IndexReader reader)
          Perform the actual deleting.
 org.apache.lucene.analysis.Analyzer getAnalyzer()
          Get analyzer used for indexing.
protected  BatchOpIndexer.DocumentWritingScheme getDocumentWritingScheme(boolean reindex)
          Creates a new instance of a DocumentWritingScheme.
protected  ObjectToDocumentConverter getObjectToDocumentConverter()
           
 void index(java.lang.Object o)
          Add an object to the index.
protected  void optimize(LuceneConnection conn)
          Optimize the index.
 void setLuceneConnection(LuceneConnection luceneConnection)
           
 void setObjectToDocumentConverter(ObjectToDocumentConverter objectToDocumentConverter)
           
protected  void setReindexingStatus(boolean status)
           
 void unindex(java.lang.Object o)
          Remove an object from the index.
 
Methods inherited from class com.atlassian.bonnie.index.BaseMultiThreadedIndexer
calculateNumberOfThreads, getQueueProcessingRunnable, isReindexing, reindex, setReindexing, truncateIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reindexAddedQueue

protected edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue reindexAddedQueue

reindexDeletedQueue

protected edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue reindexDeletedQueue
Constructor Detail

OnlineMultiThreadedIndexer

public OnlineMultiThreadedIndexer()
Method Detail

allThreadsComplete

protected void allThreadsComplete(BatchOpIndexer.DocumentWritingScheme scheme,
                                  boolean truncate,
                                  com.atlassian.core.util.ProgressWrapper progress)
Description copied from class: BaseMultiThreadedIndexer
Perform clean-up operations such as closing writers, optimizing, merging with original index, etc.

Specified by:
allThreadsComplete in class BaseMultiThreadedIndexer
Parameters:
scheme - scheme
truncate - should the original index be truncated

index

public void index(java.lang.Object o)
Description copied from interface: SingleObjectIndexer
Add an object to the index. Calls SingleObjectIndexer.unindex(java.lang.Object) before the object is added.

Specified by:
index in interface SingleObjectIndexer

doAdd

protected void doAdd(java.lang.Object o,
                     org.apache.lucene.index.IndexWriter writer)
              throws java.io.IOException
Performs the actual adding of the object to the index.

Parameters:
o -
writer -
Throws:
java.io.IOException

unindex

public void unindex(java.lang.Object o)
Description copied from interface: SingleObjectIndexer
Remove an object from the index.

Specified by:
unindex in interface SingleObjectIndexer

doDelete

protected void doDelete(java.lang.Object o,
                        org.apache.lucene.index.IndexReader reader)
                 throws java.io.IOException
Perform the actual deleting.

Parameters:
o - object to delete
reader - reader
Throws:
java.io.IOException

optimize

protected final void optimize(LuceneConnection conn)
Optimize the index.

Parameters:
conn -

getDocumentWritingScheme

protected BatchOpIndexer.DocumentWritingScheme getDocumentWritingScheme(boolean reindex)
Creates a new instance of a DocumentWritingScheme.

Parameters:
reindex - is this a reindex

setLuceneConnection

public void setLuceneConnection(LuceneConnection luceneConnection)
Specified by:
setLuceneConnection in interface SingleObjectIndexer

getObjectToDocumentConverter

protected ObjectToDocumentConverter getObjectToDocumentConverter()

setObjectToDocumentConverter

public void setObjectToDocumentConverter(ObjectToDocumentConverter objectToDocumentConverter)
Specified by:
setObjectToDocumentConverter in interface SingleObjectIndexer

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer()
Description copied from interface: BatchOpIndexer
Get analyzer used for indexing.

Specified by:
getAnalyzer in interface BatchOpIndexer

setReindexingStatus

protected void setReindexingStatus(boolean status)
                            throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2006-2008 Atlassian Software Systems Pty Ltd. All Rights Reserved.