add some missing methods to NRTMgr; add sugar ctor not taking ES

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1204009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-11-19 16:15:08 +00:00
parent 4dc8f2c8b1
commit df8ece84c2
1 changed files with 53 additions and 2 deletions

View File

@ -28,11 +28,13 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexReader; // javadocs
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.NRTManagerReopenThread;
import org.apache.lucene.search.IndexSearcher; // javadocs
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.ThreadInterruptedException;
@ -60,6 +62,25 @@ public class NRTManager implements Closeable {
private final ReentrantLock reopenLock = new ReentrantLock();
private final Condition newGeneration = reopenLock.newCondition();
/**
* Create new NRTManager.
*
* @param writer IndexWriter to open near-real-time
* readers
* @param warmer optional {@link SearcherWarmer}. Pass
* null if you don't require the searcher to warmed
* before going live. If this is non-null then a
* merged segment warmer is installed on the
* provided IndexWriter's config.
*
* <p><b>NOTE</b>: the provided {@link SearcherWarmer} is
* not invoked for the initial searcher; you should
* warm it yourself if necessary.
*/
public NRTManager(IndexWriter writer, SearcherWarmer warmer) throws IOException {
this(writer, null, warmer, true);
}
/**
* Create new NRTManager.
*
@ -152,12 +173,30 @@ public class NRTManager implements Closeable {
return indexingGen.get();
}
public long deleteDocuments(Term... terms) throws IOException {
writer.deleteDocuments(terms);
// Return gen as of when indexing finished:
return indexingGen.get();
}
public long deleteDocuments(Query q) throws IOException {
writer.deleteDocuments(q);
// Return gen as of when indexing finished:
return indexingGen.get();
}
public long deleteDocuments(Query... queries) throws IOException {
writer.deleteDocuments(queries);
// Return gen as of when indexing finished:
return indexingGen.get();
}
public long deleteAll() throws IOException {
writer.deleteAll();
// Return gen as of when indexing finished:
return indexingGen.get();
}
public long addDocument(Iterable<? extends IndexableField> d, Analyzer a) throws IOException {
writer.addDocument(d, a);
// Return gen as of when indexing finished:
@ -182,6 +221,18 @@ public class NRTManager implements Closeable {
return indexingGen.get();
}
public long addIndexes(Directory... dirs) throws CorruptIndexException, IOException {
writer.addIndexes(dirs);
// Return gen as of when indexing finished:
return indexingGen.get();
}
public long addIndexes(IndexReader... readers) throws CorruptIndexException, IOException {
writer.addIndexes(readers);
// Return gen as of when indexing finished:
return indexingGen.get();
}
/**
* Waits for a given {@link SearcherManager} target generation to be available
* via {@link #getSearcherManager(boolean)}. If the current generation is less