lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <ysee...@gmail.com>
Subject Re: [jira] Commented: (LUCENE-565) Supporting deleteDocuments in IndexWriter (Code and Performance Results Provided)
Date Mon, 10 Jul 2006 21:34:28 GMT
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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message