org.apache.lucene.gdata.search.index
Class GDataIndexWriter

java.lang.Object
  extended by org.apache.lucene.index.IndexWriter
      extended by org.apache.lucene.gdata.search.index.GDataIndexWriter

public class GDataIndexWriter
extends IndexWriter

Configurable decorator for a lucene IndexWriter

Author:
Simon Willnauer

Field Summary
 
Fields inherited from class org.apache.lucene.index.IndexWriter
DEFAULT_MAX_BUFFERED_DELETE_TERMS, DEFAULT_MAX_BUFFERED_DOCS, DEFAULT_MAX_FIELD_LENGTH, DEFAULT_MAX_MERGE_DOCS, DEFAULT_MERGE_FACTOR, DEFAULT_TERM_INDEX_INTERVAL, WRITE_LOCK_NAME, WRITE_LOCK_TIMEOUT
 
Constructor Summary
protected GDataIndexWriter(Directory arg0, boolean arg1, IndexSchema arg2)
          Creates and configures a new GdataIndexWriter
 
Method Summary
 void close()
          Flushes all changes to an index and closes all associated files.
 
Methods inherited from class org.apache.lucene.index.IndexWriter
abort, addDocument, addDocument, addIndexes, addIndexes, addIndexesNoOptimize, deleteDocuments, deleteDocuments, docCount, ensureOpen, finalize, flush, flushRamSegments, getAnalyzer, getDefaultInfoStream, getDefaultWriteLockTimeout, getDirectory, getInfoStream, getMaxBufferedDeleteTerms, getMaxBufferedDocs, getMaxFieldLength, getMaxMergeDocs, getMergeFactor, getSimilarity, getTermIndexInterval, getUseCompoundFile, getWriteLockTimeout, maybeFlushRamSegments, numRamDocs, optimize, ramSizeInBytes, setDefaultInfoStream, setDefaultWriteLockTimeout, setInfoStream, setMaxBufferedDeleteTerms, setMaxBufferedDocs, setMaxFieldLength, setMaxMergeDocs, setMergeFactor, setSimilarity, setTermIndexInterval, setUseCompoundFile, setWriteLockTimeout, updateDocument, updateDocument
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GDataIndexWriter

protected GDataIndexWriter(Directory arg0,
                           boolean arg1,
                           IndexSchema arg2)
                    throws IOException
Creates and configures a new GdataIndexWriter

Parameters:
arg0 - - the index directory
arg1 - - create index
arg2 - - the index schema configuration including all parameter to set up the index writer
Throws:
IOException - -if the directory cannot be read/written to, or if it does not exist, and create is false
Method Detail

close

public void close()
           throws IOException
Description copied from class: IndexWriter
Flushes all changes to an index and closes all associated files.

If an Exception is hit during close, eg due to disk full or some other reason, then both the on-disk index and the internal state of the IndexWriter instance will be consistent. However, the close will not be complete even though part of it (flushing buffered documents) may have succeeded, so the write lock will still be held.

If you can correct the underlying cause (eg free up some disk space) then you can call close() again. Failing that, if you want to force the write lock to be released (dangerous, because you may then lose buffered docs in the IndexWriter instance) then you can do something like this:

 try {
   writer.close();
 } finally {
   if (IndexReader.isLocked(directory)) {
     IndexReader.unlock(directory);
   }
 }
 
after which, you must be certain not to use the writer instance anymore.

Overrides:
close in class IndexWriter
Throws:
CorruptIndexException - if the index is corrupt
IOException - if there is a low-level IO error
See Also:
IndexWriter.close()


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.