com.liferay.portal.search.lucene
Class IndexWriterFactory
java.lang.Object
com.liferay.portal.search.lucene.IndexWriterFactory
public class IndexWriterFactory
- extends java.lang.Object
View Source
Lucene only allows one IndexWriter to be open at a time. However, multiple
threads can use this single IndexWriter. This class manages a global
IndexWriter and uses reference counting to determine when it can be closed.
To delete documents, IndexReaders are used but cannot delete while another
IndexWriter or IndexReader has the write lock. A semaphore is used to
serialize delete and add operations. If the shared IndexWriter is open,
concurrent add operations are permitted.
- Author:
- Harry Mark, Brian Wing Shun Chan
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IndexWriterFactory
public IndexWriterFactory()
acquireLock
public void acquireLock(long companyId,
boolean needExclusive)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
deleteDocuments
public void deleteDocuments(long companyId,
org.apache.lucene.index.Term term)
throws java.lang.InterruptedException,
java.io.IOException
- Throws:
java.lang.InterruptedException
java.io.IOException
getWriter
public org.apache.lucene.index.IndexWriter getWriter(long companyId,
boolean create)
throws java.io.IOException
- Throws:
java.io.IOException
releaseLock
public void releaseLock(long companyId)
write
public void write(long companyId)
write
public void write(org.apache.lucene.index.IndexWriter writer)
throws java.io.IOException
- Throws:
java.io.IOException
decrement
protected void decrement(IndexWriterData writerData)
getReadOnlyIndexWriter
protected org.apache.lucene.index.IndexWriter getReadOnlyIndexWriter()
getReadOnlyLuceneDir
protected org.apache.lucene.store.Directory getReadOnlyLuceneDir()
throws java.io.IOException
- Throws:
java.io.IOException