lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r883685 - /lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
Date Tue, 24 Nov 2009 13:17:46 GMT
Author: mikemccand
Date: Tue Nov 24 13:17:45 2009
New Revision: 883685

URL: http://svn.apache.org/viewvc?rev=883685&view=rev
Log:
LUCENE-2086: add assert to verify we flush deleted terms in term sort order

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=883685&r1=883684&r2=883685&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 Tue Nov 24 13:17:45
2009
@@ -962,6 +962,18 @@
     return any;
   }
 
+  // used only by assert
+  private Term lastDeleteTerm;
+
+  // used only by assert
+  private boolean checkDeleteTerm(Term term) {
+    if (term != null) {
+      assert lastDeleteTerm == null || term.compareTo(lastDeleteTerm) > 0: "lastTerm="
+ lastDeleteTerm + " vs term=" + term;
+    }
+    lastDeleteTerm = term;
+    return true;
+  }
+
   // Apply buffered delete terms, queries and docIDs to the
   // provided reader
   private final synchronized boolean applyDeletes(IndexReader reader, int docIDStart)
@@ -970,11 +982,16 @@
     final int docEnd = docIDStart + reader.maxDoc();
     boolean any = false;
 
+    assert checkDeleteTerm(null);
+
     // Delete by term
     TermDocs docs = reader.termDocs();
     try {
       for (Entry<Term, BufferedDeletes.Num> entry: deletesFlushed.terms.entrySet())
{
         Term term = entry.getKey();
+        // LUCENE-2086: we should be iterating a TreeMap,
+        // here, so terms better be in order:
+        assert checkDeleteTerm(term);
         docs.seek(term);
         int limit = entry.getValue().getNum();
         while (docs.next()) {



Mime
View raw message