public class TrackingIndexWriter
extends java.lang.Object
ControlledRealTimeReopenThread
to ensure specific
changes are visible. Create this class (passing your
IndexWriter), and then pass this class to ControlledRealTimeReopenThread
.
Be sure to make all changes via the
TrackingIndexWriter, otherwise ControlledRealTimeReopenThread
won't know about the changes.Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicLong |
indexingGen |
private IndexWriter |
writer |
Constructor and Description |
---|
TrackingIndexWriter(IndexWriter writer)
Create a
TrackingIndexWriter wrapping the
provided IndexWriter . |
Modifier and Type | Method and Description |
---|---|
long |
addDocument(java.lang.Iterable<? extends IndexableField> d)
Calls
IndexWriter.addDocument(Iterable)
and returns the generation that reflects this change. |
long |
addDocuments(java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs)
Calls
IndexWriter.addDocuments(Iterable) and
returns the generation that reflects this change. |
long |
addIndexes(CodecReader... readers)
Calls
IndexWriter.addIndexes(CodecReader...)
and returns the generation that reflects this change. |
long |
addIndexes(Directory... dirs)
Calls
IndexWriter.addIndexes(Directory...) and
returns the generation that reflects this change. |
long |
deleteAll()
Calls
IndexWriter.deleteAll() and returns the
generation that reflects this change. |
long |
deleteDocuments(Query... queries)
Calls
IndexWriter.deleteDocuments(Query...)
and returns the generation that reflects this change. |
long |
deleteDocuments(Query q)
Calls
IndexWriter.deleteDocuments(Query...) and
returns the generation that reflects this change. |
long |
deleteDocuments(Term... terms)
Calls
IndexWriter.deleteDocuments(Term...) and
returns the generation that reflects this change. |
long |
deleteDocuments(Term t)
Calls
IndexWriter.deleteDocuments(Term...) and
returns the generation that reflects this change. |
long |
getAndIncrementGeneration()
Return and increment current gen.
|
long |
getGeneration()
Return the current generation being indexed.
|
IndexWriter |
getIndexWriter()
Return the wrapped
IndexWriter . |
long |
tryDeleteDocument(IndexReader reader,
int docID)
Cals
IndexWriter.tryDeleteDocument(IndexReader,int) and
returns the generation that reflects this change. |
long |
updateDocument(Term t,
java.lang.Iterable<? extends IndexableField> d)
Calls
IndexWriter.updateDocument(Term,Iterable) and
returns the generation that reflects this change. |
long |
updateDocuments(Term t,
java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs)
Calls
IndexWriter.updateDocuments(Term,Iterable) and returns
the generation that reflects this change. |
private final IndexWriter writer
private final java.util.concurrent.atomic.AtomicLong indexingGen
public TrackingIndexWriter(IndexWriter writer)
TrackingIndexWriter
wrapping the
provided IndexWriter
.public long updateDocument(Term t, java.lang.Iterable<? extends IndexableField> d) throws java.io.IOException
IndexWriter.updateDocument(Term,Iterable)
and
returns the generation that reflects this change.java.io.IOException
public long updateDocuments(Term t, java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) throws java.io.IOException
IndexWriter.updateDocuments(Term,Iterable)
and returns
the generation that reflects this change.java.io.IOException
public long deleteDocuments(Term t) throws java.io.IOException
IndexWriter.deleteDocuments(Term...)
and
returns the generation that reflects this change.java.io.IOException
public long deleteDocuments(Term... terms) throws java.io.IOException
IndexWriter.deleteDocuments(Term...)
and
returns the generation that reflects this change.java.io.IOException
public long deleteDocuments(Query q) throws java.io.IOException
IndexWriter.deleteDocuments(Query...)
and
returns the generation that reflects this change.java.io.IOException
public long deleteDocuments(Query... queries) throws java.io.IOException
IndexWriter.deleteDocuments(Query...)
and returns the generation that reflects this change.java.io.IOException
public long deleteAll() throws java.io.IOException
IndexWriter.deleteAll()
and returns the
generation that reflects this change.java.io.IOException
public long addDocument(java.lang.Iterable<? extends IndexableField> d) throws java.io.IOException
IndexWriter.addDocument(Iterable)
and returns the generation that reflects this change.java.io.IOException
public long addDocuments(java.lang.Iterable<? extends java.lang.Iterable<? extends IndexableField>> docs) throws java.io.IOException
IndexWriter.addDocuments(Iterable)
and
returns the generation that reflects this change.java.io.IOException
public long addIndexes(Directory... dirs) throws java.io.IOException
IndexWriter.addIndexes(Directory...)
and
returns the generation that reflects this change.java.io.IOException
public long addIndexes(CodecReader... readers) throws java.io.IOException
IndexWriter.addIndexes(CodecReader...)
and returns the generation that reflects this change.java.io.IOException
public long getGeneration()
public IndexWriter getIndexWriter()
IndexWriter
.public long getAndIncrementGeneration()
public long tryDeleteDocument(IndexReader reader, int docID) throws java.io.IOException
IndexWriter.tryDeleteDocument(IndexReader,int)
and
returns the generation that reflects this change.java.io.IOException