|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.gdata.search.index.GDataIndexer
public class GDataIndexer
A GDataIndexer encapsulates every writing access to the search index.
Insert, updates and deletes to the index happens inside this class. All
modification will be base on an instance of
IndexDocument
which contains all
informations and command for the indexer.
Although this class provides methods to add, remove and update document in
the index all IndexDocument instances should be added to the task
queue via the addIndexableDocumentTask(Future)
method.
Inside this class runs an instance of
IndexTask
listening on this
queue. The analysis of the actual documents happens inside the
com.sun.corba.se.impl.orbutil.closure.Future
object added to the
queue. This enables the indexer to do his actual work. Documents will be
build / analyzed concurrently while already finished tasks can be added to
the index.
Field Summary | |
---|---|
protected java.util.concurrent.atomic.AtomicInteger |
committed
|
protected java.util.concurrent.atomic.AtomicInteger |
docsAdded
|
protected java.util.concurrent.atomic.AtomicInteger |
docsDeleted
|
protected java.util.concurrent.atomic.AtomicInteger |
docsUpdated
|
protected java.util.concurrent.BlockingQueue<java.util.concurrent.Future<IndexDocument>> |
futurQueue
|
protected org.apache.lucene.gdata.search.index.IndexTask |
indexTask
|
protected java.util.concurrent.atomic.AtomicInteger |
optimized
|
protected IndexSearcher |
searcher
|
protected IndexWriter |
writer
|
Constructor Summary | |
---|---|
protected |
GDataIndexer(IndexSchema schema,
Directory dir,
boolean create)
|
Method Summary | |
---|---|
protected void |
addDocument(IndexDocument indexable)
|
void |
addIndexableDocumentTask(java.util.concurrent.Future<IndexDocument> task)
Adds the given future task to the queue, and waits if the queue is full. |
protected void |
closeSearcher()
|
protected void |
closeWriter()
|
protected void |
commit(boolean optimize)
This method commits all changes to the index and closes all open resources (e.g. |
static GDataIndexer |
createGdataIndexer(IndexSchema config,
Directory dir,
boolean create)
This factory method creates a new GDataIndexer using a instance of IndexTask |
static GDataIndexer |
createTimedGdataIndexer(IndexSchema config,
Directory dir,
boolean create,
long commitTimeout)
This factory method creates a new GDataIndexer using a instance of TimedIndexTask . |
protected void |
deleteDocument(IndexDocument indexable)
|
protected void |
destroy()
|
protected void |
doDeltete()
|
protected void |
doWrite(IndexDocument document)
|
protected void |
init()
|
protected void |
notifyCommitListeners(String serviceId)
|
protected void |
openSearcher()
|
protected void |
openWriter()
|
void |
registerIndexEventListener(IndexEventListener listener)
Registers a new IndexEventListener. |
void |
removeIndexEventListener(IndexEventListener listener)
Removes a registered IndexEventListener |
protected void |
setIndexTask(org.apache.lucene.gdata.search.index.IndexTask task)
|
protected void |
updateDocument(IndexDocument indexable)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected IndexWriter writer
protected IndexSearcher searcher
protected java.util.concurrent.atomic.AtomicInteger committed
protected java.util.concurrent.atomic.AtomicInteger optimized
protected java.util.concurrent.atomic.AtomicInteger docsAdded
protected java.util.concurrent.atomic.AtomicInteger docsUpdated
protected java.util.concurrent.atomic.AtomicInteger docsDeleted
protected final java.util.concurrent.BlockingQueue<java.util.concurrent.Future<IndexDocument>> futurQueue
protected org.apache.lucene.gdata.search.index.IndexTask indexTask
Constructor Detail |
---|
protected GDataIndexer(IndexSchema schema, Directory dir, boolean create) throws IOException
IOException
Method Detail |
---|
protected void setIndexTask(org.apache.lucene.gdata.search.index.IndexTask task)
protected void init()
public void addIndexableDocumentTask(java.util.concurrent.Future<IndexDocument> task) throws InterruptedException
task
- -
the task to be scheduled
InterruptedException
- -
if the queue is interruptedprotected void addDocument(IndexDocument indexable) throws IOException
IOException
protected void updateDocument(IndexDocument indexable) throws IOException
IOException
protected void deleteDocument(IndexDocument indexable)
protected void commit(boolean optimize) throws IOException
optimize
- -
true
if the index should be optimized on this
commit
IOException
- -
if an IOException occurspublic void registerIndexEventListener(IndexEventListener listener)
listener
- -
the listener to registerpublic void removeIndexEventListener(IndexEventListener listener)
listener
- -
the listener to removeprotected void notifyCommitListeners(String serviceId)
protected void closeWriter() throws IOException
IOException
protected void closeSearcher() throws IOException
IOException
protected void openSearcher() throws IOException
IOException
protected void openWriter() throws IOException
IOException
protected void doWrite(IndexDocument document) throws IOException
IOException
protected void doDeltete() throws IOException
IOException
protected void destroy() throws IOException
IOException
public static GDataIndexer createGdataIndexer(IndexSchema config, Directory dir, boolean create) throws IOException
IndexTask
config
- -
the config to be used to configure the indexerdir
- -
the directory to index tocreate
- -
true
to create a new index, false
to use the existing one.
IOException
- -
if an IOException occurs while initializing the indexerpublic static GDataIndexer createTimedGdataIndexer(IndexSchema config, Directory dir, boolean create, long commitTimeout) throws IOException
TimedIndexTask
. This indexer will automatically commit the index
if no modification to the index occur for the given time. The used time
unit is TimeUnit.SECONDS
. Values less than the default value
will be ignored. For the default value see TimedIndexTask
.
config
- -
the config to be used to configure the indexerdir
- -
the directory to index tocreate
- -
true
to create a new index, false
to use the existing one.commitTimeout
- -
the amount of seconds to wait until a commit should be
scheduled
IOException
- -
if an IOException occurs while initializing the indexer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |