|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.atlassian.bonnie.LuceneConnection
TODO reentrancy to/from reader/writer ... allow it? these operations can occur concurrently, using the same reader (writer closed beforehand): - withSearch - withReader
these operations will be serialized against all other operatons - withWriter (closes any readers closed beforehand) - withReaderAndDeletes (writers closed beforehand, reader+writer closed afterwards) - optimize (any readers closed beforehand) - flushWriter (closes readers and writers) also see: - "What are all possible concurrent Lucene requests?" http://www.jguru.com/faq/view.jsp?EID=913302
| Nested Class Summary | |
class |
LuceneConnection.TempIndexWriterData
|
| Nested classes inherited from class com.atlassian.bonnie.ILuceneConnection |
ILuceneConnection.BatchUpdateAction, ILuceneConnection.Configuration, ILuceneConnection.ReaderAction, ILuceneConnection.SearcherAction, ILuceneConnection.WriterAction |
| Field Summary | |
protected org.apache.lucene.analysis.Analyzer |
analyzerForIndexing
|
static org.apache.log4j.Category |
LOG
|
static java.lang.String |
REINDEXING_FILENAME
|
protected boolean |
searcherOpensNewReader
|
static int |
WRITER_BATCH
|
static int |
WRITER_DEFAULT
|
static int |
WRITER_INTERACTIVE
|
| Fields inherited from interface com.atlassian.bonnie.ILuceneConnection |
DEFAULT_CONFIGURATION |
| Constructor Summary | |
LuceneConnection()
Default constructor. |
|
LuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzerForIndexing)
Create a new lucene connection, setting the index directory to be the specified directory. |
|
LuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzerForIndexing,
ILuceneConnection.Configuration configuration)
Create a new lucene connection, setting the index directory to be the specified directory. |
|
LuceneConnection(java.io.File location,
org.apache.lucene.analysis.Analyzer analyzerForIndexing)
Create a new lucene connection, setting the index directory to be the specified location. |
|
LuceneConnection(java.io.File location,
org.apache.lucene.analysis.Analyzer analyzerForIndexing,
ILuceneConnection.Configuration configuration)
Create a new lucene connection, setting the index directory to be the specified location. |
|
| Method Summary | |
void |
close()
Closes the reader and the writer. |
void |
flushWriter()
|
protected org.apache.lucene.store.Directory |
getDirectory()
|
java.io.File |
getIndexDir()
|
int |
getNumDocs()
Returns the number of documents in the index. |
protected org.apache.lucene.index.IndexReader |
getReader()
|
protected org.apache.lucene.search.IndexSearcher |
getSearcher()
|
protected org.apache.lucene.index.IndexWriter |
getWriter()
|
protected org.apache.lucene.index.IndexWriter |
getWriter(int flags)
|
boolean |
isIndexCreated()
Returns true if the index has been created. |
boolean |
isReIndexing()
|
org.apache.lucene.search.IndexSearcher |
leakSearcher()
Get the current Searcher from the ILuceneConnection. |
void |
optimize()
Perform an optimize on the index. |
void |
recreateIndexDirectory()
Create or recreate the underlying directory the index is contained in. |
void |
setAlwaysUnlock(boolean alwaysUnlock)
|
void |
setIndexDir(java.lang.String location)
|
void |
setReIndexing(boolean b)
Sets reindexing flag. |
void |
setSearcherOpensNewReader(boolean searcherOpensNewReader)
|
protected boolean |
shouldCreateIndexDirectory()
Returns true if the index directory should be created. |
void |
truncateIndex()
|
void |
unlockIfNeeded()
|
void |
withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
Perform multiple writes to the index. |
void |
withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction,
ILuceneConnection.WriterAction writerAction)
Perform an Atomic delete and add. |
java.lang.Object |
withReader(ILuceneConnection.ReaderAction action)
Idempotent operation. |
void |
withReaderAndDeletes(ILuceneConnection.ReaderAction action)
Delete stuff in the index. |
void |
withSearch(ILuceneConnection.SearcherAction action)
|
void |
withWriter(ILuceneConnection.WriterAction action)
Add (write) documents to the index |
void |
withWriter(ILuceneConnection.WriterAction action,
int flags)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final org.apache.log4j.Category LOG
public static final int WRITER_DEFAULT
public static final int WRITER_INTERACTIVE
public static final int WRITER_BATCH
public static final java.lang.String REINDEXING_FILENAME
protected org.apache.lucene.analysis.Analyzer analyzerForIndexing
protected boolean searcherOpensNewReader
| Constructor Detail |
public LuceneConnection()
public LuceneConnection(java.io.File location,
org.apache.lucene.analysis.Analyzer analyzerForIndexing)
location - of the index directory.analyzerForIndexing -
public LuceneConnection(java.io.File location,
org.apache.lucene.analysis.Analyzer analyzerForIndexing,
ILuceneConnection.Configuration configuration)
location - of the index directory.analyzerForIndexing - configuration - of the Lucene IndexWriter settings
public LuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzerForIndexing)
directory - used for storing the lucene index.analyzerForIndexing -
public LuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzerForIndexing,
ILuceneConnection.Configuration configuration)
directory - used for storing the lucene index.analyzerForIndexing - configuration - of the Lucene IndexWriter settings| Method Detail |
public void withSearch(ILuceneConnection.SearcherAction action)
throws LuceneException
withSearch in interface ILuceneConnectionLuceneException
protected org.apache.lucene.search.IndexSearcher getSearcher()
throws java.io.IOException
java.io.IOException
public java.lang.Object withReader(ILuceneConnection.ReaderAction action)
throws LuceneException
ILuceneConnection#withReaderAndDeletes(ReaderAction) to perform
index deletes.
withReader in interface ILuceneConnectionLuceneException
public void withReaderAndDeletes(ILuceneConnection.ReaderAction action)
throws LuceneException
ILuceneConnection
withReaderAndDeletes in interface ILuceneConnectionLuceneException
public void withWriter(ILuceneConnection.WriterAction action)
throws LuceneException
ILuceneConnection
withWriter in interface ILuceneConnectionLuceneException
public void withWriter(ILuceneConnection.WriterAction action,
int flags)
throws LuceneException
LuceneException
public void withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction,
ILuceneConnection.WriterAction writerAction)
throws LuceneException
ILuceneConnectionILuceneConnection.withBatchUpdate(com.atlassian.bonnie.ILuceneConnection.BatchUpdateAction) as
it will use the batch mode configuration, speeding up the writes.
withDeleteAndWrites in interface ILuceneConnectionLuceneExceptionpublic void withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
ILuceneConnectionbatch configuration
settings.
withBatchUpdate in interface ILuceneConnection
public void optimize()
throws LuceneException
ILuceneConnection
optimize in interface ILuceneConnectionLuceneExceptionpublic void setSearcherOpensNewReader(boolean searcherOpensNewReader)
public void flushWriter()
throws LuceneException
LuceneException
protected final org.apache.lucene.index.IndexReader getReader()
throws LuceneException
LuceneException
protected org.apache.lucene.index.IndexWriter getWriter()
throws LuceneException
LuceneException
protected org.apache.lucene.index.IndexWriter getWriter(int flags)
throws LuceneException
LuceneExceptionpublic void close()
ILuceneConnection
close in interface ILuceneConnection
public boolean isReIndexing()
throws java.io.IOException
java.io.IOException
public void setReIndexing(boolean b)
throws java.io.IOException
b -
java.io.IOExceptionpublic void recreateIndexDirectory()
ILuceneConnection
recreateIndexDirectory in interface ILuceneConnectionpublic org.apache.lucene.search.IndexSearcher leakSearcher()
ILuceneConnection
leakSearcher in interface ILuceneConnection
protected boolean shouldCreateIndexDirectory()
throws java.io.IOException
java.io.IOException
public void truncateIndex()
throws java.io.IOException
java.io.IOException
protected org.apache.lucene.store.Directory getDirectory()
throws java.io.IOException
java.io.IOExceptionpublic java.io.File getIndexDir()
public void setIndexDir(java.lang.String location)
public int getNumDocs()
ILuceneConnectiondocuments in the index.
getNumDocs in interface ILuceneConnectionpublic boolean isIndexCreated()
ILuceneConnection
isIndexCreated in interface ILuceneConnection
public void unlockIfNeeded()
throws java.io.IOException
java.io.IOExceptionpublic void setAlwaysUnlock(boolean alwaysUnlock)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||