lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r761000 - /lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
Date Wed, 01 Apr 2009 18:25:19 GMT
Author: mikemccand
Date: Wed Apr  1 18:25:18 2009
New Revision: 761000

URL: http://svn.apache.org/viewvc?rev=761000&view=rev
Log:
small optimization: re-use a single TermDocs instance when deleting-by-Term

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=761000&r1=760999&r2=761000&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Wed Apr  1 18:25:18
2009
@@ -952,25 +952,24 @@
 
     // Delete by term
     Iterator iter = deletesFlushed.terms.entrySet().iterator();
-    while (iter.hasNext()) {
-      Entry entry = (Entry) iter.next();
-      Term term = (Term) entry.getKey();
+    TermDocs docs = reader.termDocs();
+    try {
+      while (iter.hasNext()) {
+        Entry entry = (Entry) iter.next();
+        Term term = (Term) entry.getKey();
 
-      TermDocs docs = reader.termDocs(term);
-      if (docs != null) {
+        docs.seek(term);
         int limit = ((BufferedDeletes.Num) entry.getValue()).getNum();
-        try {
-          while (docs.next()) {
-            int docID = docs.doc();
-            if (docIDStart+docID >= limit)
-              break;
-            reader.deleteDocument(docID);
-            any = true;
-          }
-        } finally {
-          docs.close();
+        while (docs.next()) {
+          int docID = docs.doc();
+          if (docIDStart+docID >= limit)
+            break;
+          reader.deleteDocument(docID);
+          any = true;
         }
       }
+    } finally {
+      docs.close();
     }
 
     // Delete by docID



Mime
View raw message