From 55046c8d74ed33a43fb2af416114d31ca2e28e21 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 24 Nov 2009 13:17:45 +0000 Subject: [PATCH] LUCENE-2086: add assert to verify we flush deleted terms in term sort order git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@883685 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/DocumentsWriter.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/java/org/apache/lucene/index/DocumentsWriter.java b/src/java/org/apache/lucene/index/DocumentsWriter.java index f954d5b32e4..8a7525c7bcc 100644 --- a/src/java/org/apache/lucene/index/DocumentsWriter.java +++ b/src/java/org/apache/lucene/index/DocumentsWriter.java @@ -962,6 +962,18 @@ final class DocumentsWriter { 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 class DocumentsWriter { final int docEnd = docIDStart + reader.maxDoc(); boolean any = false; + assert checkDeleteTerm(null); + // Delete by term TermDocs docs = reader.termDocs(); try { for (Entry 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()) {