Random comment...
when applying deletes you can break out of the loop early.
+ while (docs.next()) {
+ int doc = docs.doc();
+ if (doc <=
(((DeleteTerm)deleteTerms.elementAt(i)).maxSegment)) {
+ reader.deleteDocument(doc);
+ }
+ }
can be changed to
while (docs.next()) {
int doc = docs.doc();
if (doc >
(((DeleteTerm)deleteTerms.elementAt(i)).maxSegment)) break;
reader.deleteDocument(doc);
}
An alternate implementation could use a HashMap to associate term with
maxSegment.
That would make deletions more efficient for multiple deletes on the
same term (this can easily happen if there are a set of frequently
updated documents).
Solr does much the same thing, except since it doesn't have access to
IndexWriter internals, it keeps track of the number of documents *not*
to delete for a certain term. An add increases the count, and a
delete resets the count to zero.
-Yonik
http://incubator.apache.org/solr Solr, the open-source Lucene search server
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]