You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2011/07/06 23:16:57 UTC

svn commit: r1143567 [4/11] - in /lucene/dev/branches/solr2452: ./ dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/lucene/contrib/ dev-tools/idea/modules/analysis/morfologik/ dev-tools/idea/modules/common/ dev-tools/idea/modules/facet/ dev-tool...

Modified: lucene/dev/branches/solr2452/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java (original)
+++ lucene/dev/branches/solr2452/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java Wed Jul  6 21:16:33 2011
@@ -35,10 +35,6 @@ import org.apache.lucene.search.Sort;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.search.function.CustomScoreQuery;
-import org.apache.lucene.search.function.CustomScoreProvider;
-import org.apache.lucene.search.function.FieldScoreQuery;
-import org.apache.lucene.search.function.FieldScoreQuery.Type;
 import org.apache.lucene.spatial.DistanceUtils;
 import org.apache.lucene.spatial.geohash.GeoHashUtils;
 import org.apache.lucene.spatial.geometry.DistanceUnits;
@@ -216,33 +212,6 @@ public class TestCartesian extends Lucen
     if (VERBOSE) System.out.println(dq);
     //create a term query to search against all documents
     Query tq = new TermQuery(new Term("metafile", "doc"));
-
-    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
-
-    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){
-
-      @Override
-      protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context) {
-        return new CustomScoreProvider(context) {
-          @Override // TODO: broken, as reader is not used!
-          public float customScore(int doc, float subQueryScore, float valSrcScore){
-            if (VERBOSE) System.out.println(doc);
-            if (dq.distanceFilter.getDistance(doc) == null)
-              return 0;
-
-            double distance = dq.distanceFilter.getDistance(doc);
-            // boost score shouldn't exceed 1
-            if (distance < 1.0d)
-              distance = 1.0d;
-            //boost by distance is invertly proportional to
-            // to distance from center point to location
-            float score = (float) ((miles - distance) / miles );
-            return score * subQueryScore;
-          }
-        };
-      }
-      
-    };
     // Create a distance sort
     // As the radius filter has performed the distance calculations
     // already, pass in the filter to reuse the results.
@@ -252,7 +221,7 @@ public class TestCartesian extends Lucen
 
     // Perform the search, using the term query, the serial chain filter, and the
     // distance sort
-    TopDocs hits = searcher.search(customScore,null, 1000, sort);
+    TopDocs hits = searcher.search(dq.getQuery(tq),null, 1000, sort);
     int results = hits.totalHits;
     ScoreDoc[] scoreDocs = hits.scoreDocs; 
     
@@ -312,33 +281,6 @@ public class TestCartesian extends Lucen
     if (VERBOSE) System.out.println(dq);
     //create a term query to search against all documents
     Query tq = new TermQuery(new Term("metafile", "doc"));
-
-    FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
-
-    CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){
-
-      @Override
-      protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context) {
-        return new CustomScoreProvider(context) {
-          @Override // TODO: broken, as reader is not used!
-          public float customScore(int doc, float subQueryScore, float valSrcScore){
-            if (VERBOSE) System.out.println(doc);
-            if (dq.distanceFilter.getDistance(doc) == null)
-              return 0;
-
-            double distance = dq.distanceFilter.getDistance(doc);
-            // boost score shouldn't exceed 1
-            if (distance < 1.0d)
-              distance = 1.0d;
-            //boost by distance is invertly proportional to
-            // to distance from center point to location
-            float score = (float) ((miles - distance) / miles );
-            return score * subQueryScore;
-          }
-        };
-      }
-      
-    };
     // Create a distance sort
     // As the radius filter has performed the distance calculations
     // already, pass in the filter to reuse the results.
@@ -348,7 +290,7 @@ public class TestCartesian extends Lucen
 
     // Perform the search, using the term query, the serial chain filter, and the
     // distance sort
-    TopDocs hits = searcher.search(customScore,null, 1000, sort);
+    TopDocs hits = searcher.search(dq.getQuery(tq),null, 1000, sort);
     int results = hits.totalHits;
     ScoreDoc[] scoreDocs = hits.scoreDocs; 
 
@@ -410,31 +352,6 @@ public class TestCartesian extends Lucen
       if (VERBOSE) System.out.println(dq);
       //create a term query to search against all documents
       Query tq = new TermQuery(new Term("metafile", "doc"));
-    
-      FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
-    
-      CustomScoreQuery customScore = new CustomScoreQuery(dq.getQuery(tq),fsQuery){
-        @Override
-        protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context) {
-          return new CustomScoreProvider(context) {
-            @Override // TODO: broken, as reader is not used!
-            public float customScore(int doc, float subQueryScore, float valSrcScore){
-              if (VERBOSE) System.out.println(doc);
-              if (dq.distanceFilter.getDistance(doc) == null)
-                return 0;
-          
-              double distance = dq.distanceFilter.getDistance(doc);
-              // boost score shouldn't exceed 1
-              if (distance < 1.0d)
-                distance = 1.0d;
-              //boost by distance is invertly proportional to
-              // to distance from center point to location
-              float score = (float) ( (miles - distance) / miles );
-              return score * subQueryScore;
-            }
-          };
-        }
-      };
       // Create a distance sort
       // As the radius filter has performed the distance calculations
       // already, pass in the filter to reuse the results.
@@ -444,7 +361,7 @@ public class TestCartesian extends Lucen
     
       // Perform the search, using the term query, the serial chain filter, and the
       // distance sort
-      TopDocs hits = searcher.search(customScore,null, 1000, sort);
+      TopDocs hits = searcher.search(dq.getQuery(tq),null, 1000, sort);
       int results = hits.totalHits;
       ScoreDoc[] scoreDocs = hits.scoreDocs; 
     
@@ -506,30 +423,6 @@ public class TestCartesian extends Lucen
       if (VERBOSE) System.out.println(dq);
       //create a term query to search against all documents
       Query tq = new TermQuery(new Term("metafile", "doc"));
-	    
-      FieldScoreQuery fsQuery = new FieldScoreQuery("geo_distance", Type.FLOAT);
-      CustomScoreQuery customScore = new CustomScoreQuery(tq,fsQuery){
-        @Override
-        protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context) {
-          return new CustomScoreProvider(context) {
-              @Override // TODO: broken, as reader is not used!
-              public float customScore(int doc, float subQueryScore, float valSrcScore){
-              if (VERBOSE) System.out.println(doc);
-              if (dq.distanceFilter.getDistance(doc) == null)
-                return 0;
-            
-              double distance = dq.distanceFilter.getDistance(doc);
-              // boost score shouldn't exceed 1
-              if (distance < 1.0d)
-                distance = 1.0d;
-              //boost by distance is invertly proportional to
-              // to distance from center point to location
-              float score = (float) ( (miles - distance) / miles );
-              return score * subQueryScore;
-            }
-          };
-        }
-      };
       // Create a distance sort
       // As the radius filter has performed the distance calculations
       // already, pass in the filter to reuse the results.
@@ -539,7 +432,7 @@ public class TestCartesian extends Lucen
 	    
       // Perform the search, using the term query, the serial chain filter, and the
       // distance sort
-      TopDocs hits = searcher.search(customScore,dq.getFilter(), 1000); //,sort);
+      TopDocs hits = searcher.search(tq,dq.getFilter(), 1000); //,sort);
       int results = hits.totalHits;
       ScoreDoc[] scoreDocs = hits.scoreDocs; 
 	    

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletes.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletes.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletes.java Wed Jul  6 21:16:33 2011
@@ -196,7 +196,7 @@ class BufferedDeletes {
 
   public Iterable<Term> termsIterable() {
     return new Iterable<Term>() {
-      // @Override -- not until Java 1.6
+      @Override
       public Iterator<Term> iterator() {
         return terms.keySet().iterator();
       }
@@ -206,23 +206,23 @@ class BufferedDeletes {
   public Iterable<QueryAndLimit> queriesIterable() {
     return new Iterable<QueryAndLimit>() {
       
-      // @Override -- not until Java 1.6
+      @Override
       public Iterator<QueryAndLimit> iterator() {
         return new Iterator<QueryAndLimit>() {
           private final Iterator<Map.Entry<Query,Integer>> iter = queries.entrySet().iterator();
 
-          // @Override -- not until Java 1.6
+          @Override
           public boolean hasNext() {
             return iter.hasNext();
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public QueryAndLimit next() {
             final Map.Entry<Query,Integer> ent = iter.next();
             return new QueryAndLimit(ent.getKey(), ent.getValue());
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public void remove() {
             throw new UnsupportedOperationException();
           }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java Wed Jul  6 21:16:33 2011
@@ -143,7 +143,7 @@ class BufferedDeletesStream {
 
   // Sorts SegmentInfos from smallest to biggest bufferedDelGen:
   private static final Comparator<SegmentInfo> sortSegInfoByDelGen = new Comparator<SegmentInfo>() {
-    // @Override -- not until Java 1.6
+    @Override
     public int compare(SegmentInfo si1, SegmentInfo si2) {
       final long cmp = si1.getBufferedDeletesGen() - si2.getBufferedDeletesGen();
       if (cmp > 0) {
@@ -162,7 +162,7 @@ class BufferedDeletesStream {
   };
   
   /** Resolves the buffered deleted Term/Query/docIDs, into
-   *  actual deleted docIDs in the deletedDocs BitVector for
+   *  actual deleted docIDs in the liveDocs BitVector for
    *  each SegmentReader. */
   public synchronized ApplyDeletesResult applyDeletes(IndexWriter.ReaderPool readerPool, List<SegmentInfo> infos) throws IOException {
     final long t0 = System.currentTimeMillis();
@@ -399,7 +399,7 @@ class BufferedDeletesStream {
       // System.out.println("  term=" + term);
 
       if (termsEnum.seekExact(term.bytes(), false)) {
-        DocsEnum docsEnum = termsEnum.docs(reader.getDeletedDocs(), docs);
+        DocsEnum docsEnum = termsEnum.docs(reader.getLiveDocs(), docs);
 
         if (docsEnum != null) {
           while (true) {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/CheckIndex.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/CheckIndex.java Wed Jul  6 21:16:33 2011
@@ -17,12 +17,16 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.FSDirectory;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IndexInput;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.lucene.document.AbstractField;  // for javadocs
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.codecs.CodecProvider;
@@ -30,20 +34,16 @@ import org.apache.lucene.index.codecs.De
 import org.apache.lucene.index.codecs.PerDocValues;
 import org.apache.lucene.index.values.IndexDocValues;
 import org.apache.lucene.index.values.ValuesEnum;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.StringHelper;
 
-import java.text.NumberFormat;
-import java.io.PrintStream;
-import java.io.IOException;
-import java.io.File;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-
 /**
  * Basic tool and API to check the health of an index and
  * write a new segments file that removes reference to
@@ -520,13 +520,13 @@ public class CheckIndex {
         final int numDocs = reader.numDocs();
         toLoseDocCount = numDocs;
         if (reader.hasDeletions()) {
-          if (reader.deletedDocs.count() != info.getDelCount()) {
-            throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs deletedDocs.count()=" + reader.deletedDocs.count());
+          if (reader.liveDocs.count() != info.docCount - info.getDelCount()) {
+            throw new RuntimeException("delete count mismatch: info=" + (info.docCount - info.getDelCount()) + " vs reader=" + reader.liveDocs.count());
           }
-          if (reader.deletedDocs.count() > reader.maxDoc()) {
-            throw new RuntimeException("too many deleted docs: maxDoc()=" + reader.maxDoc() + " vs deletedDocs.count()=" + reader.deletedDocs.count());
+          if ((info.docCount-reader.liveDocs.count()) > reader.maxDoc()) {
+            throw new RuntimeException("too many deleted docs: maxDoc()=" + reader.maxDoc() + " vs del count=" + (info.docCount-reader.liveDocs.count()));
           }
-          if (info.docCount - numDocs != info.getDelCount()){
+          if (info.docCount - numDocs != info.getDelCount()) {
             throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.docCount - numDocs));
           }
           segInfoStat.numDeleted = info.docCount - numDocs;
@@ -654,7 +654,7 @@ public class CheckIndex {
     final Status.TermIndexStatus status = new Status.TermIndexStatus();
 
     final int maxDoc = reader.maxDoc();
-    final Bits delDocs = reader.getDeletedDocs();
+    final Bits liveDocs = reader.getLiveDocs();
 
     final IndexSearcher is = new IndexSearcher(reader);
 
@@ -712,8 +712,8 @@ public class CheckIndex {
           final int docFreq = terms.docFreq();
           status.totFreq += docFreq;
 
-          docs = terms.docs(delDocs, docs);
-          postings = terms.docsAndPositions(delDocs, postings);
+          docs = terms.docs(liveDocs, docs);
+          postings = terms.docsAndPositions(liveDocs, postings);
 
           if (hasOrd) {
             long ord = -1;
@@ -815,7 +815,7 @@ public class CheckIndex {
             if (hasPositions) {
               for(int idx=0;idx<7;idx++) {
                 final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
-                postings = terms.docsAndPositions(delDocs, postings);
+                postings = terms.docsAndPositions(liveDocs, postings);
                 final int docID = postings.advance(skipDocID);
                 if (docID == DocsEnum.NO_MORE_DOCS) {
                   break;
@@ -851,7 +851,7 @@ public class CheckIndex {
             } else {
               for(int idx=0;idx<7;idx++) {
                 final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
-                docs = terms.docs(delDocs, docs);
+                docs = terms.docs(liveDocs, docs);
                 final int docID = docs.advance(skipDocID);
                 if (docID == DocsEnum.NO_MORE_DOCS) {
                   break;
@@ -919,7 +919,7 @@ public class CheckIndex {
                 throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
               }
               
-              docs = terms.docs(delDocs, docs);
+              docs = terms.docs(liveDocs, docs);
               if (docs == null) {
                 throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
               }
@@ -967,9 +967,9 @@ public class CheckIndex {
       }
 
       // Scan stored fields for all documents
-      final Bits delDocs = reader.getDeletedDocs();
+      final Bits liveDocs = reader.getLiveDocs();
       for (int j = 0; j < info.docCount; ++j) {
-        if (delDocs == null || !delDocs.get(j)) {
+        if (liveDocs == null || liveDocs.get(j)) {
           status.docCount++;
           Document doc = reader.document(j);
           status.totFields += doc.getFields().size();
@@ -1063,9 +1063,9 @@ public class CheckIndex {
         infoStream.print("    test: term vectors........");
       }
 
-      final Bits delDocs = reader.getDeletedDocs();
+      final Bits liveDocs = reader.getLiveDocs();
       for (int j = 0; j < info.docCount; ++j) {
-        if (delDocs == null || !delDocs.get(j)) {
+        if (liveDocs == null || liveDocs.get(j)) {
           status.docCount++;
           TermFreqVector[] tfv = reader.getTermFreqVectors(j);
           if (tfv != null) {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DirectoryReader.java Wed Jul  6 21:16:33 2011
@@ -350,8 +350,8 @@ class DirectoryReader extends IndexReade
   }
 
   @Override
-  public Bits getDeletedDocs() {
-    throw new UnsupportedOperationException("please use MultiFields.getDeletedDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Bits deletedDocs");
+  public Bits getLiveDocs() {
+    throw new UnsupportedOperationException("please use MultiFields.getLiveDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Bits liveDocs");
   }
 
   @Override

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocTermOrds.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocTermOrds.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocTermOrds.java Wed Jul  6 21:16:33 2011
@@ -249,7 +249,7 @@ public class DocTermOrds {
 
     boolean testedOrd = false;
 
-    final Bits delDocs = MultiFields.getDeletedDocs(reader);
+    final Bits liveDocs = MultiFields.getLiveDocs(reader);
 
     // we need a minimum of 9 bytes, but round up to 12 since the space would
     // be wasted with most allocators anyway.
@@ -312,7 +312,7 @@ public class DocTermOrds {
       final int df = te.docFreq();
       if (df <= maxTermDocFreq) {
 
-        docsEnum = te.docs(delDocs, docsEnum);
+        docsEnum = te.docs(liveDocs, docsEnum);
 
         final DocsEnum.BulkReadResult bulkResult = docsEnum.getBulkResult();
 
@@ -653,13 +653,13 @@ public class DocTermOrds {
     }
 
     @Override    
-    public DocsEnum docs(Bits skipDocs, DocsEnum reuse) throws IOException {
-      return termsEnum.docs(skipDocs, reuse);
+    public DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException {
+      return termsEnum.docs(liveDocs, reuse);
     }
 
     @Override    
-    public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException {
-      return termsEnum.docsAndPositions(skipDocs, reuse);
+    public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException {
+      return termsEnum.docsAndPositions(liveDocs, reuse);
     }
 
     @Override

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java Wed Jul  6 21:16:33 2011
@@ -111,13 +111,13 @@ public class DocumentsWriterPerThread {
   static class FlushedSegment {
     final SegmentInfo segmentInfo;
     final BufferedDeletes segmentDeletes;
-    final BitVector deletedDocuments;
+    final BitVector liveDocs;
 
     private FlushedSegment(SegmentInfo segmentInfo,
-        BufferedDeletes segmentDeletes, BitVector deletedDocuments) {
+        BufferedDeletes segmentDeletes, BitVector liveDocs) {
       this.segmentInfo = segmentInfo;
       this.segmentDeletes = segmentDeletes;
-      this.deletedDocuments = deletedDocuments;
+      this.liveDocs = liveDocs;
     }
   }
 
@@ -434,9 +434,10 @@ public class DocumentsWriterPerThread {
     // happens when an exception is hit processing that
     // doc, eg if analyzer has some problem w/ the text):
     if (pendingDeletes.docIDs.size() > 0) {
-      flushState.deletedDocs = new BitVector(numDocsInRAM);
+      flushState.liveDocs = new BitVector(numDocsInRAM);
+      flushState.liveDocs.invertAll();
       for(int delDocID : pendingDeletes.docIDs) {
-        flushState.deletedDocs.set(delDocID);
+        flushState.liveDocs.clear(delDocID);
       }
       pendingDeletes.bytesUsed.addAndGet(-pendingDeletes.docIDs.size() * BufferedDeletes.BYTES_PER_DEL_DOCID);
       pendingDeletes.docIDs.clear();
@@ -460,7 +461,7 @@ public class DocumentsWriterPerThread {
       pendingDeletes.terms.clear();
       final SegmentInfo newSegment = new SegmentInfo(segment, flushState.numDocs, directory, false, flushState.segmentCodecs, fieldInfos.asReadOnly());
       if (infoStream != null) {
-        message("new segment has " + (flushState.deletedDocs == null ? 0 : flushState.deletedDocs.count()) + " deleted docs");
+        message("new segment has " + (flushState.liveDocs == null ? 0 : (flushState.numDocs - flushState.liveDocs.count())) + " deleted docs");
         message("new segment has " + (newSegment.getHasVectors() ? "vectors" : "no vectors"));
         message("flushedFiles=" + newSegment.files());
         message("flushed codecs=" + newSegment.getSegmentCodecs());
@@ -489,7 +490,7 @@ public class DocumentsWriterPerThread {
       doAfterFlush();
       success = true;
 
-      return new FlushedSegment(newSegment, segmentDeletes, flushState.deletedDocs);
+      return new FlushedSegment(newSegment, segmentDeletes, flushState.liveDocs);
     } finally {
       if (!success) {
         if (segment != null) {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FilterIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FilterIndexReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FilterIndexReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FilterIndexReader.java Wed Jul  6 21:16:33 2011
@@ -87,13 +87,13 @@ public class FilterIndexReader extends I
     }
 
     @Override
-    public DocsEnum docs(Bits skipDocs, BytesRef text, DocsEnum reuse) throws IOException {
-      return in.docs(skipDocs, text, reuse);
+    public DocsEnum docs(Bits liveDocs, BytesRef text, DocsEnum reuse) throws IOException {
+      return in.docs(liveDocs, text, reuse);
     }
 
     @Override
-    public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, BytesRef text, DocsAndPositionsEnum reuse) throws IOException {
-      return in.docsAndPositions(skipDocs, text, reuse);
+    public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, BytesRef text, DocsAndPositionsEnum reuse) throws IOException {
+      return in.docsAndPositions(liveDocs, text, reuse);
     }
 
     @Override
@@ -172,13 +172,13 @@ public class FilterIndexReader extends I
     }
 
     @Override
-    public DocsEnum docs(Bits skipDocs, DocsEnum reuse) throws IOException {
-      return in.docs(skipDocs, reuse);
+    public DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException {
+      return in.docs(liveDocs, reuse);
     }
 
     @Override
-    public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException {
-      return in.docsAndPositions(skipDocs, reuse);
+    public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException {
+      return in.docsAndPositions(liveDocs, reuse);
     }
 
     @Override
@@ -301,8 +301,8 @@ public class FilterIndexReader extends I
   }
   
   @Override
-  public Bits getDeletedDocs() {
-    return in.getDeletedDocs();
+  public Bits getLiveDocs() {
+    return in.getLiveDocs();
   }
   
   @Override

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java Wed Jul  6 21:16:33 2011
@@ -339,10 +339,11 @@ final class FreqProxTermsWriterPerField 
           // Mark it deleted.  TODO: we could also skip
           // writing its postings; this would be
           // deterministic (just for this Term's docs).
-          if (state.deletedDocs == null) {
-            state.deletedDocs = new BitVector(state.numDocs);
+          if (state.liveDocs == null) {
+            state.liveDocs = new BitVector(state.numDocs);
+            state.liveDocs.invertAll();
           }
-          state.deletedDocs.set(docID);
+          state.liveDocs.clear(docID);
         }
 
         // Carefully copy over the prox + payload info,

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java Wed Jul  6 21:16:33 2011
@@ -93,22 +93,22 @@ class FrozenBufferedDeletes {
 
   public Iterable<Term> termsIterable() {
     return new Iterable<Term>() {
-      // @Override -- not until Java 1.6
+      @Override
       public Iterator<Term> iterator() {
         return new Iterator<Term>() {
           private int upto;
 
-          // @Override -- not until Java 1.6
+          @Override
           public boolean hasNext() {
             return upto < terms.length;
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public Term next() {
             return terms[upto++];
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public void remove() {
             throw new UnsupportedOperationException();
           }
@@ -119,24 +119,24 @@ class FrozenBufferedDeletes {
 
   public Iterable<QueryAndLimit> queriesIterable() {
     return new Iterable<QueryAndLimit>() {
-      // @Override -- not until Java 1.6
+      @Override
       public Iterator<QueryAndLimit> iterator() {
         return new Iterator<QueryAndLimit>() {
           private int upto;
 
-          // @Override -- not until Java 1.6
+          @Override
           public boolean hasNext() {
             return upto < queries.length;
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public QueryAndLimit next() {
             QueryAndLimit ret = new QueryAndLimit(queries[upto], queryLimits[upto]);
             upto++;
             return ret;
           }
 
-          // @Override -- not until Java 1.6
+          @Override
           public void remove() {
             throw new UnsupportedOperationException();
           }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexReader.java Wed Jul  6 21:16:33 2011
@@ -962,7 +962,7 @@ public abstract class IndexReader implem
    * requested document is deleted, and therefore asking for a deleted document
    * may yield unspecified results. Usually this is not required, however you
    * can test if the doc is deleted by checking the {@link
-   * Bits} returned from {@link MultiFields#getDeletedDocs}.
+   * Bits} returned from {@link MultiFields#getLiveDocs}.
    * 
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
@@ -987,7 +987,7 @@ public abstract class IndexReader implem
    * requested document is deleted, and therefore asking for a deleted document
    * may yield unspecified results. Usually this is not required, however you
    * can test if the doc is deleted by checking the {@link
-   * Bits} returned from {@link MultiFields#getDeletedDocs}.
+   * Bits} returned from {@link MultiFields#getLiveDocs}.
    * 
    * @param n Get the document at the <code>n</code><sup>th</sup> position
    * @param fieldSelector The {@link FieldSelector} to use to determine what
@@ -1136,7 +1136,7 @@ public abstract class IndexReader implem
   /** Returns {@link DocsEnum} for the specified field &
    *  term.  This may return null, if either the field or
    *  term does not exist. */
-  public DocsEnum termDocsEnum(Bits skipDocs, String field, BytesRef term) throws IOException {
+  public DocsEnum termDocsEnum(Bits liveDocs, String field, BytesRef term) throws IOException {
     assert field != null;
     assert term != null;
     final Fields fields = fields();
@@ -1145,7 +1145,7 @@ public abstract class IndexReader implem
     }
     final Terms terms = fields.terms(field);
     if (terms != null) {
-      return terms.docs(skipDocs, term, null);
+      return terms.docs(liveDocs, term, null);
     } else {
       return null;
     }
@@ -1155,7 +1155,7 @@ public abstract class IndexReader implem
    *  field & term.  This may return null, if either the
    *  field or term does not exist, or, positions were not
    *  stored for this term. */
-  public DocsAndPositionsEnum termPositionsEnum(Bits skipDocs, String field, BytesRef term) throws IOException {
+  public DocsAndPositionsEnum termPositionsEnum(Bits liveDocs, String field, BytesRef term) throws IOException {
     assert field != null;
     assert term != null;
     final Fields fields = fields();
@@ -1164,7 +1164,7 @@ public abstract class IndexReader implem
     }
     final Terms terms = fields.terms(field);
     if (terms != null) {
-      return terms.docsAndPositions(skipDocs, term, null);
+      return terms.docsAndPositions(liveDocs, term, null);
     } else {
       return null;
     }
@@ -1175,7 +1175,7 @@ public abstract class IndexReader implem
    * {@link TermState}. This may return null, if either the field or the term
    * does not exists or the {@link TermState} is invalid for the underlying
    * implementation.*/
-  public DocsEnum termDocsEnum(Bits skipDocs, String field, BytesRef term, TermState state) throws IOException {
+  public DocsEnum termDocsEnum(Bits liveDocs, String field, BytesRef term, TermState state) throws IOException {
     assert state != null;
     assert field != null;
     final Fields fields = fields();
@@ -1184,7 +1184,7 @@ public abstract class IndexReader implem
     }
     final Terms terms = fields.terms(field);
     if (terms != null) {
-      return terms.docs(skipDocs, term, state, null);
+      return terms.docs(liveDocs, term, state, null);
     } else {
       return null;
     }
@@ -1195,7 +1195,7 @@ public abstract class IndexReader implem
    * {@link TermState}. This may return null, if either the field or the term
    * does not exists, the {@link TermState} is invalid for the underlying
    * implementation, or positions were not stored for this term.*/
-  public DocsAndPositionsEnum termPositionsEnum(Bits skipDocs, String field, BytesRef term, TermState state) throws IOException {
+  public DocsAndPositionsEnum termPositionsEnum(Bits liveDocs, String field, BytesRef term, TermState state) throws IOException {
     assert state != null;
     assert field != null;
     final Fields fields = fields();
@@ -1204,7 +1204,7 @@ public abstract class IndexReader implem
     }
     final Terms terms = fields.terms(field);
     if (terms != null) {
-      return terms.docsAndPositions(skipDocs, term, state, null);
+      return terms.docsAndPositions(liveDocs, term, state, null);
     } else {
       return null;
     }
@@ -1260,7 +1260,7 @@ public abstract class IndexReader implem
   public int deleteDocuments(Term term) throws StaleReaderException, CorruptIndexException, LockObtainFailedException, IOException {
     ensureOpen();
     DocsEnum docs = MultiFields.getTermDocsEnum(this,
-                                                MultiFields.getDeletedDocs(this),
+                                                MultiFields.getLiveDocs(this),
                                                 term.field(),
                                                 term.bytes());
     if (docs == null) return 0;
@@ -1385,15 +1385,17 @@ public abstract class IndexReader implem
    */
   public abstract Collection<String> getFieldNames(FieldOption fldOption);
 
-  /** Returns the {@link Bits} representing deleted docs.  A
-   *  set bit indicates the doc ID has been deleted.  This
-   *  method should return null when there are no deleted
-   *  docs.
-   *
-   *  The returned instance has been safely published for use by
-   *  multiple threads without additional synchronization.
+  /** Returns the {@link Bits} representing live (not
+   *  deleted) docs.  A set bit indicates the doc ID has not
+   *  been deleted.  If this method returns null it means
+   *  there are no deleted documents (all documents are
+   *  live).
+   *
+   *  The returned instance has been safely published for
+   *  use by multiple threads without additional
+   *  synchronization.
    * @lucene.experimental */
-  public abstract Bits getDeletedDocs();
+  public abstract Bits getLiveDocs();
 
   /**
    * Expert: return the IndexCommit that this reader has

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/IndexWriter.java Wed Jul  6 21:16:33 2011
@@ -2214,8 +2214,8 @@ public class IndexWriter implements Clos
 
       // Must write deleted docs after the CFS so we don't
       // slurp the del file into CFS:
-      if (flushedSegment.deletedDocuments != null) {
-        final int delCount = flushedSegment.deletedDocuments.count();
+      if (flushedSegment.liveDocs != null) {
+        final int delCount = flushedSegment.segmentInfo.docCount - flushedSegment.liveDocs.count();
         assert delCount > 0;
         newSegment.setDelCount(delCount);
         newSegment.advanceDelGen();
@@ -2230,7 +2230,7 @@ public class IndexWriter implements Clos
           // shortly-to-be-opened SegmentReader and let it
           // carry the changes; there's no reason to use
           // filesystem as intermediary here.
-          flushedSegment.deletedDocuments.write(directory, delFileName);
+          flushedSegment.liveDocs.write(directory, delFileName);
           success2 = true;
         } finally {
           if (!success2) {
@@ -2931,9 +2931,9 @@ public class IndexWriter implements Clos
         // Reader was skipped because it was 100% deletions
         continue;
       }
-      final Bits prevDelDocs = previousReader.getDeletedDocs();
+      final Bits prevLiveDocs = previousReader.getLiveDocs();
       final SegmentReader currentReader = merge.readers.get(i);
-      final Bits currentDelDocs = currentReader.getDeletedDocs();
+      final Bits currentLiveDocs = currentReader.getLiveDocs();
       if (previousReader.hasDeletions()) {
 
         // There were deletes on this segment when the merge
@@ -2948,10 +2948,10 @@ public class IndexWriter implements Clos
           // committed since we started the merge, so we
           // must merge them:
           for(int j=0;j<docCount;j++) {
-            if (prevDelDocs.get(j))
-              assert currentDelDocs.get(j);
+            if (!prevLiveDocs.get(j))
+              assert !currentLiveDocs.get(j);
             else {
-              if (currentDelDocs.get(j)) {
+              if (!currentLiveDocs.get(j)) {
                 mergedReader.doDelete(docUpto);
                 delCount++;
               }
@@ -2965,7 +2965,7 @@ public class IndexWriter implements Clos
         // This segment had no deletes before but now it
         // does:
         for(int j=0; j<docCount; j++) {
-          if (currentDelDocs.get(j)) {
+          if (!currentLiveDocs.get(j)) {
             mergedReader.doDelete(docUpto);
             delCount++;
           }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsAndPositionsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsAndPositionsEnum.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsAndPositionsEnum.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsAndPositionsEnum.java Wed Jul  6 21:16:33 2011
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.ReaderUtil;
 import org.apache.lucene.util.BytesRef;
 
@@ -35,7 +34,6 @@ public final class MultiDocsAndPositions
   int upto;
   DocsAndPositionsEnum current;
   int currentBase;
-  Bits skipDocs;
   int doc = -1;
 
   MultiDocsAndPositionsEnum reset(final EnumWithSlice[] subs, final int numSubs) throws IOException {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsEnum.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsEnum.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiDocsEnum.java Wed Jul  6 21:16:33 2011
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.ReaderUtil;
 import java.io.IOException;
 
@@ -33,7 +32,6 @@ public final class MultiDocsEnum extends
   int upto;
   DocsEnum current;
   int currentBase;
-  Bits skipDocs;
   int doc = -1;
 
   MultiDocsEnum reset(final EnumWithSlice[] subs, final int numSubs) throws IOException {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiFields.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiFields.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiFields.java Wed Jul  6 21:16:33 2011
@@ -100,19 +100,19 @@ public final class MultiFields extends F
     }
   }
 
-  public static Bits getDeletedDocs(IndexReader r) {
+  public static Bits getLiveDocs(IndexReader r) {
     Bits result;
     if (r.hasDeletions()) {
 
-      final List<Bits> delDocs = new ArrayList<Bits>();
+      final List<Bits> liveDocs = new ArrayList<Bits>();
       final List<Integer> starts = new ArrayList<Integer>();
 
       try {
         final int maxDoc = new ReaderUtil.Gather(r) {
             @Override
             protected void add(int base, IndexReader r) throws IOException {
-              // record all delDocs, even if they are null
-              delDocs.add(r.getDeletedDocs());
+              // record all liveDocs, even if they are null
+              liveDocs.add(r.getLiveDocs());
               starts.add(base);
             }
           }.run();
@@ -122,12 +122,12 @@ public final class MultiFields extends F
         throw new RuntimeException(ioe);
       }
 
-      assert delDocs.size() > 0;
-      if (delDocs.size() == 1) {
+      assert liveDocs.size() > 0;
+      if (liveDocs.size() == 1) {
         // Only one actual sub reader -- optimize this case
-        result = delDocs.get(0);
+        result = liveDocs.get(0);
       } else {
-        result = new MultiBits(delDocs, starts);
+        result = new MultiBits(liveDocs, starts, true);
       }
 
     } else {
@@ -150,12 +150,12 @@ public final class MultiFields extends F
   /** Returns {@link DocsEnum} for the specified field &
    *  term.  This may return null if the term does not
    *  exist. */
-  public static DocsEnum getTermDocsEnum(IndexReader r, Bits skipDocs, String field, BytesRef term) throws IOException {
+  public static DocsEnum getTermDocsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term) throws IOException {
     assert field != null;
     assert term != null;
     final Terms terms = getTerms(r, field);
     if (terms != null) {
-      return terms.docs(skipDocs, term, null);
+      return terms.docs(liveDocs, term, null);
     } else {
       return null;
     }
@@ -164,12 +164,12 @@ public final class MultiFields extends F
   /** Returns {@link DocsAndPositionsEnum} for the specified
    *  field & term.  This may return null if the term does
    *  not exist or positions were not indexed. */
-  public static DocsAndPositionsEnum getTermPositionsEnum(IndexReader r, Bits skipDocs, String field, BytesRef term) throws IOException {
+  public static DocsAndPositionsEnum getTermPositionsEnum(IndexReader r, Bits liveDocs, String field, BytesRef term) throws IOException {
     assert field != null;
     assert term != null;
     final Terms terms = getTerms(r, field);
     if (terms != null) {
-      return terms.docsAndPositions(skipDocs, term, null);
+      return terms.docsAndPositions(liveDocs, term, null);
     } else {
       return null;
     }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiReader.java Wed Jul  6 21:16:33 2011
@@ -141,8 +141,8 @@ public class MultiReader extends IndexRe
   }
   
   @Override
-  public Bits getDeletedDocs() {
-    throw new UnsupportedOperationException("please use MultiFields.getDeletedDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Bits deletedDocs");
+  public Bits getLiveDocs() {
+    throw new UnsupportedOperationException("please use MultiFields.getLiveDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Bits liveDocs");
   }
 
   /**

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiTermsEnum.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiTermsEnum.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/MultiTermsEnum.java Wed Jul  6 21:16:33 2011
@@ -43,6 +43,7 @@ public final class MultiTermsEnum extend
   private final MultiDocsAndPositionsEnum.EnumWithSlice[] subDocsAndPositions;
 
   private BytesRef lastSeek;
+  private boolean lastSeekExact;
   private final BytesRef lastSeekScratch = new BytesRef();
 
   private int numTop;
@@ -149,6 +150,7 @@ public final class MultiTermsEnum extend
     }
 
     lastSeek = null;
+    lastSeekExact = true;
 
     for(int i=0;i<numSubs;i++) {
       final boolean status;
@@ -179,6 +181,7 @@ public final class MultiTermsEnum extend
       if (status) {
         top[numTop++] = currentSubs[i];
         current = currentSubs[i].current = currentSubs[i].terms.term();
+        assert term.equals(currentSubs[i].current);
       }
     }
 
@@ -191,6 +194,7 @@ public final class MultiTermsEnum extend
   public SeekStatus seekCeil(BytesRef term, boolean useCache) throws IOException {
     queue.clear();
     numTop = 0;
+    lastSeekExact = false;
 
     boolean seekOpt = false;
     if (lastSeek != null && termComp.compare(lastSeek, term) <= 0) {
@@ -293,6 +297,17 @@ public final class MultiTermsEnum extend
 
   @Override
   public BytesRef next() throws IOException {
+    if (lastSeekExact) {
+      // Must seekCeil at this point, so those subs that
+      // didn't have the term can find the following term.
+      // NOTE: we could save some CPU by only seekCeil the
+      // subs that didn't match the last exact seek... but
+      // most impls short-circuit if you seekCeil to term
+      // they are already on.
+      final SeekStatus status = seekCeil(current);
+      assert status == SeekStatus.FOUND;
+      lastSeekExact = false;
+    }
     lastSeek = null;
 
     // restore queue
@@ -331,7 +346,7 @@ public final class MultiTermsEnum extend
   }
 
   @Override
-  public DocsEnum docs(Bits skipDocs, DocsEnum reuse) throws IOException {
+  public DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException {
     final MultiDocsEnum docsEnum;
     if (reuse != null) {
       docsEnum = (MultiDocsEnum) reuse;
@@ -339,11 +354,11 @@ public final class MultiTermsEnum extend
       docsEnum = new MultiDocsEnum();
     }
     
-    final MultiBits multiSkipDocs;
-    if (skipDocs instanceof MultiBits) {
-      multiSkipDocs = (MultiBits) skipDocs;
+    final MultiBits multiLiveDocs;
+    if (liveDocs instanceof MultiBits) {
+      multiLiveDocs = (MultiBits) liveDocs;
     } else {
-      multiSkipDocs = null;
+      multiLiveDocs = null;
     }
 
     int upto = 0;
@@ -354,22 +369,22 @@ public final class MultiTermsEnum extend
 
       final Bits b;
 
-      if (multiSkipDocs != null) {
+      if (multiLiveDocs != null) {
         // optimize for common case: requested skip docs is a
         // congruent sub-slice of MultiBits: in this case, we
-        // just pull the skipDocs from the sub reader, rather
+        // just pull the liveDocs from the sub reader, rather
         // than making the inefficient
         // Slice(Multi(sub-readers)):
-        final MultiBits.SubResult sub = multiSkipDocs.getMatchingSub(entry.subSlice);
+        final MultiBits.SubResult sub = multiLiveDocs.getMatchingSub(entry.subSlice);
         if (sub.matches) {
           b = sub.result;
         } else {
           // custom case: requested skip docs is foreign:
           // must slice it on every access
-          b = new BitsSlice(skipDocs, entry.subSlice);
+          b = new BitsSlice(liveDocs, entry.subSlice);
         }
-      } else if (skipDocs != null) {
-        b = new BitsSlice(skipDocs, entry.subSlice);
+      } else if (liveDocs != null) {
+        b = new BitsSlice(liveDocs, entry.subSlice);
       } else {
         // no deletions
         b = null;
@@ -392,7 +407,7 @@ public final class MultiTermsEnum extend
   }
 
   @Override
-  public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException {
+  public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException {
     final MultiDocsAndPositionsEnum docsAndPositionsEnum;
     if (reuse != null) {
       docsAndPositionsEnum = (MultiDocsAndPositionsEnum) reuse;
@@ -400,11 +415,11 @@ public final class MultiTermsEnum extend
       docsAndPositionsEnum = new MultiDocsAndPositionsEnum();
     }
     
-    final MultiBits multiSkipDocs;
-    if (skipDocs instanceof MultiBits) {
-      multiSkipDocs = (MultiBits) skipDocs;
+    final MultiBits multiLiveDocs;
+    if (liveDocs instanceof MultiBits) {
+      multiLiveDocs = (MultiBits) liveDocs;
     } else {
-      multiSkipDocs = null;
+      multiLiveDocs = null;
     }
 
     int upto = 0;
@@ -415,23 +430,23 @@ public final class MultiTermsEnum extend
 
       final Bits b;
 
-      if (multiSkipDocs != null) {
+      if (multiLiveDocs != null) {
         // Optimize for common case: requested skip docs is a
         // congruent sub-slice of MultiBits: in this case, we
-        // just pull the skipDocs from the sub reader, rather
+        // just pull the liveDocs from the sub reader, rather
         // than making the inefficient
         // Slice(Multi(sub-readers)):
-        final MultiBits.SubResult sub = multiSkipDocs.getMatchingSub(top[i].subSlice);
+        final MultiBits.SubResult sub = multiLiveDocs.getMatchingSub(top[i].subSlice);
         if (sub.matches) {
           b = sub.result;
         } else {
           // custom case: requested skip docs is foreign:
           // must slice it on every access (very
           // inefficient)
-          b = new BitsSlice(skipDocs, top[i].subSlice);
+          b = new BitsSlice(liveDocs, top[i].subSlice);
         }
-      } else if (skipDocs != null) {
-        b = new BitsSlice(skipDocs, top[i].subSlice);
+      } else if (liveDocs != null) {
+        b = new BitsSlice(liveDocs, top[i].subSlice);
       } else {
         // no deletions
         b = null;

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/ParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/ParallelReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/ParallelReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/ParallelReader.java Wed Jul  6 21:16:33 2011
@@ -206,9 +206,9 @@ public class ParallelReader extends Inde
     }
   }
   
-   @Override
-  public Bits getDeletedDocs() {
-    return MultiFields.getDeletedDocs(readers.get(0));
+  @Override
+  public Bits getLiveDocs() {
+    return MultiFields.getLiveDocs(readers.get(0));
   }
 
   @Override
@@ -584,7 +584,7 @@ public class ParallelReader extends Inde
       fields.put(field, perDocs.docValues(field));
     }
 
-    //@Override -- not until Java 1.6
+    @Override
     public void close() throws IOException {
       // nothing to do here
     }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java Wed Jul  6 21:16:33 2011
@@ -199,4 +199,9 @@ final class SegmentCoreReaders {
       }
     }
   }
+
+  @Override
+  public String toString() {
+    return "SegmentCoreReader(owner=" + owner + ")";
+  }
 }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentMerger.java Wed Jul  6 21:16:33 2011
@@ -282,11 +282,12 @@ final class SegmentMerger {
     throws IOException, MergeAbortedException, CorruptIndexException {
     int docCount = 0;
     final int maxDoc = reader.maxDoc();
-    final Bits delDocs = reader.getDeletedDocs();
+    final Bits liveDocs = reader.getLiveDocs();
+    assert liveDocs != null;
     if (matchingFieldsReader != null) {
       // We can bulk-copy because the fieldInfos are "congruent"
       for (int j = 0; j < maxDoc;) {
-        if (delDocs.get(j)) {
+        if (!liveDocs.get(j)) {
           // skip deleted docs
           ++j;
           continue;
@@ -298,7 +299,7 @@ final class SegmentMerger {
           j++;
           numDocs++;
           if (j >= maxDoc) break;
-          if (delDocs.get(j)) {
+          if (!liveDocs.get(j)) {
             j++;
             break;
           }
@@ -311,7 +312,7 @@ final class SegmentMerger {
       }
     } else {
       for (int j = 0; j < maxDoc; j++) {
-        if (delDocs.get(j)) {
+        if (!liveDocs.get(j)) {
           // skip deleted docs
           continue;
         }
@@ -401,11 +402,11 @@ final class SegmentMerger {
                                         final IndexReader reader)
     throws IOException, MergeAbortedException {
     final int maxDoc = reader.maxDoc();
-    final Bits delDocs = reader.getDeletedDocs();
+    final Bits liveDocs = reader.getLiveDocs();
     if (matchingVectorsReader != null) {
       // We can bulk-copy because the fieldInfos are "congruent"
       for (int docNum = 0; docNum < maxDoc;) {
-        if (delDocs.get(docNum)) {
+        if (!liveDocs.get(docNum)) {
           // skip deleted docs
           ++docNum;
           continue;
@@ -417,7 +418,7 @@ final class SegmentMerger {
           docNum++;
           numDocs++;
           if (docNum >= maxDoc) break;
-          if (delDocs.get(docNum)) {
+          if (!liveDocs.get(docNum)) {
             docNum++;
             break;
           }
@@ -429,7 +430,7 @@ final class SegmentMerger {
       }
     } else {
       for (int docNum = 0; docNum < maxDoc; docNum++) {
-        if (delDocs.get(docNum)) {
+        if (!liveDocs.get(docNum)) {
           // skip deleted docs
           continue;
         }
@@ -499,14 +500,14 @@ final class SegmentMerger {
       if (f != null) {
         slices.add(new ReaderUtil.Slice(docBase, maxDoc, fields.size()));
         fields.add(f);
-        bits.add(r.getDeletedDocs());
+        bits.add(r.getLiveDocs());
         bitsStarts.add(docBase);
       }
       final PerDocValues producer = r.perDocValues();
       if (producer != null) {
         perDocSlices.add(new ReaderUtil.Slice(docBase, maxDoc, fields.size()));
         perDocProducers.add(producer);
-        perDocBits.add(r.getDeletedDocs());
+        perDocBits.add(r.getLiveDocs());
         perDocBitsStarts.add(docBase);
       }
       docBase += maxDoc;
@@ -544,13 +545,13 @@ final class SegmentMerger {
       inputDocBase += reader.maxDoc();
       if (mergeState.delCounts[i] != 0) {
         int delCount = 0;
-        final Bits delDocs = reader.getDeletedDocs();
-        assert delDocs != null;
+        final Bits liveDocs = reader.getLiveDocs();
+        assert liveDocs != null;
         final int maxDoc = reader.maxDoc();
         final int[] docMap = mergeState.docMaps[i] = new int[maxDoc];
         int newDocID = 0;
         for(int j=0;j<maxDoc;j++) {
-          if (delDocs.get(j)) {
+          if (!liveDocs.get(j)) {
             docMap[j] = -1;
             delCount++;  // only for assert
           } else {
@@ -571,7 +572,7 @@ final class SegmentMerger {
       // MultiBits as our skip docs only to have it broken
       // apart when we step through the docs enums in
       // MultiDocsEnum.
-      mergeState.multiDeletedDocs = new MultiBits(bits, bitsStarts);
+      mergeState.multiLiveDocs = new MultiBits(bits, bitsStarts, true);
       
       consumer.merge(mergeState,
                      new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
@@ -580,7 +581,7 @@ final class SegmentMerger {
       consumer.close();
     }
     if (!perDocSlices.isEmpty()) {
-      mergeState.multiDeletedDocs = new MultiBits(perDocBits, perDocBitsStarts);
+      mergeState.multiLiveDocs = new MultiBits(perDocBits, perDocBitsStarts, true);
       final PerDocConsumer docsConsumer = codec
           .docsConsumer(new PerDocWriteState(segmentWriteState));
       try {
@@ -592,7 +593,6 @@ final class SegmentMerger {
         docsConsumer.close();
       }
     }
-    
   }
 
   private MergeState mergeState;
@@ -635,9 +635,9 @@ final class SegmentMerger {
             } else {
               // this segment has deleted docs, so we have to
               // check for every doc if it is deleted or not
-              final Bits delDocs = reader.getDeletedDocs();
+              final Bits liveDocs = reader.getLiveDocs();
               for (int k = 0; k < maxDoc; k++) {
-                if (!delDocs.get(k)) {
+                if (liveDocs.get(k)) {
                   output.writeByte(normBuffer[k]);
                 }
               }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentReader.java Wed Jul  6 21:16:33 2011
@@ -51,9 +51,9 @@ public class SegmentReader extends Index
   CloseableThreadLocal<FieldsReader> fieldsReaderLocal = new FieldsReaderLocal();
   CloseableThreadLocal<TermVectorsReader> termVectorsLocal = new CloseableThreadLocal<TermVectorsReader>();
 
-  volatile BitVector deletedDocs;
-  AtomicInteger deletedDocsRef = null;
-  private boolean deletedDocsDirty = false;
+  volatile BitVector liveDocs;
+  AtomicInteger liveDocsRef = null;
+  private boolean liveDocsDirty = false;
   private boolean normsDirty = false;
 
   // TODO: we should move this tracking into SegmentInfo;
@@ -116,7 +116,7 @@ public class SegmentReader extends Index
       if (doOpenStores) {
         instance.core.openDocStores(si);
       }
-      instance.loadDeletedDocs();
+      instance.loadLiveDocs();
       instance.openNorms(instance.core.cfsDir, readBufferSize);
       success = true;
     } finally {
@@ -138,34 +138,37 @@ public class SegmentReader extends Index
   }
 
   @Override
-  public Bits getDeletedDocs() {
-    return deletedDocs;
+  public Bits getLiveDocs() {
+    return liveDocs;
   }
 
-  private boolean checkDeletedCounts() throws IOException {
-    final int recomputedCount = deletedDocs.getRecomputedCount();
-     
-    assert deletedDocs.count() == recomputedCount : "deleted count=" + deletedDocs.count() + " vs recomputed count=" + recomputedCount;
+  private boolean checkLiveCounts() throws IOException {
+    final int recomputedCount = liveDocs.getRecomputedCount();
+    // First verify BitVector is self consistent:
+    assert liveDocs.count() == recomputedCount : "live count=" + liveDocs.count() + " vs recomputed count=" + recomputedCount;
 
-    assert si.getDelCount() == recomputedCount : 
-    "delete count mismatch: info=" + si.getDelCount() + " vs BitVector=" + recomputedCount;
+    assert si.getDelCount() == si.docCount - recomputedCount :
+      "delete count mismatch: info=" + si.getDelCount() + " vs BitVector=" + (si.docCount-recomputedCount);
 
     // Verify # deletes does not exceed maxDoc for this
     // segment:
     assert si.getDelCount() <= maxDoc() : 
-    "delete count mismatch: " + recomputedCount + ") exceeds max doc (" + maxDoc() + ") for segment " + si.name;
+      "delete count mismatch: " + recomputedCount + ") exceeds max doc (" + maxDoc() + ") for segment " + si.name;
 
     return true;
   }
 
-  private void loadDeletedDocs() throws IOException {
+  private void loadLiveDocs() throws IOException {
     // NOTE: the bitvector is stored using the regular directory, not cfs
     if (hasDeletions(si)) {
-      deletedDocs = new BitVector(directory(), si.getDelFileName());
-      deletedDocsRef = new AtomicInteger(1);
-      assert checkDeletedCounts();
-      if (deletedDocs.size() != si.docCount) {
-        throw new CorruptIndexException("document count mismatch: deleted docs count " + deletedDocs.size() + " vs segment doc count " + si.docCount + " segment=" + si.name);
+      liveDocs = new BitVector(directory(), si.getDelFileName());
+      if (liveDocs.getVersion() < BitVector.VERSION_DGAPS_CLEARED) {
+        liveDocs.invertAll();
+      }
+      liveDocsRef = new AtomicInteger(1);
+      assert checkLiveCounts();
+      if (liveDocs.size() != si.docCount) {
+        throw new CorruptIndexException("document count mismatch: deleted docs count " + liveDocs.size() + " vs segment doc count " + si.docCount + " segment=" + si.name);
       }
     } else
       assert si.getDelCount() == 0;
@@ -256,27 +259,27 @@ public class SegmentReader extends Index
 
       if (!openReadOnly && hasChanges) {
         // My pending changes transfer to the new reader
-        clone.deletedDocsDirty = deletedDocsDirty;
+        clone.liveDocsDirty = liveDocsDirty;
         clone.normsDirty = normsDirty;
         clone.hasChanges = hasChanges;
         hasChanges = false;
       }
       
       if (doClone) {
-        if (deletedDocs != null) {
-          deletedDocsRef.incrementAndGet();
-          clone.deletedDocs = deletedDocs;
-          clone.deletedDocsRef = deletedDocsRef;
+        if (liveDocs != null) {
+          liveDocsRef.incrementAndGet();
+          clone.liveDocs = liveDocs;
+          clone.liveDocsRef = liveDocsRef;
         }
       } else {
         if (!deletionsUpToDate) {
           // load deleted docs
-          assert clone.deletedDocs == null;
-          clone.loadDeletedDocs();
-        } else if (deletedDocs != null) {
-          deletedDocsRef.incrementAndGet();
-          clone.deletedDocs = deletedDocs;
-          clone.deletedDocsRef = deletedDocsRef;
+          assert clone.liveDocs == null;
+          clone.loadLiveDocs();
+        } else if (liveDocs != null) {
+          liveDocsRef.incrementAndGet();
+          clone.liveDocs = liveDocs;
+          clone.liveDocsRef = liveDocsRef;
         }
       }
 
@@ -326,10 +329,10 @@ public class SegmentReader extends Index
   }
 
   private synchronized void commitChanges(Map<String,String> commitUserData) throws IOException {
-    if (deletedDocsDirty) {               // re-write deleted
+    if (liveDocsDirty) {               // re-write deleted
       si.advanceDelGen();
 
-      assert deletedDocs.length() == si.docCount;
+      assert liveDocs.length() == si.docCount;
 
       // We can write directly to the actual name (vs to a
       // .tmp & renaming it) because the file is not live
@@ -337,7 +340,7 @@ public class SegmentReader extends Index
       final String delFileName = si.getDelFileName();
       boolean success = false;
       try {
-        deletedDocs.write(directory(), delFileName);
+        liveDocs.write(directory(), delFileName);
         success = true;
       } finally {
         if (!success) {
@@ -349,10 +352,9 @@ public class SegmentReader extends Index
           }
         }
       }
-
       si.setDelCount(si.getDelCount()+pendingDeleteCount);
       pendingDeleteCount = 0;
-      assert deletedDocs.count() == si.getDelCount(): "delete count mismatch during commit: info=" + si.getDelCount() + " vs BitVector=" + deletedDocs.count();
+      assert (maxDoc()-liveDocs.count()) == si.getDelCount(): "delete count mismatch during commit: info=" + si.getDelCount() + " vs BitVector=" + (maxDoc()-liveDocs.count());
     } else {
       assert pendingDeleteCount == 0;
     }
@@ -365,7 +367,7 @@ public class SegmentReader extends Index
         }
       }
     }
-    deletedDocsDirty = false;
+    liveDocsDirty = false;
     normsDirty = false;
     hasChanges = false;
   }
@@ -379,10 +381,10 @@ public class SegmentReader extends Index
     termVectorsLocal.close();
     fieldsReaderLocal.close();
     
-    if (deletedDocs != null) {
-      deletedDocsRef.decrementAndGet();
+    if (liveDocs != null) {
+      liveDocsRef.decrementAndGet();
       // null so if an app hangs on to us we still free most ram
-      deletedDocs = null;
+      liveDocs = null;
     }
 
     for (final SegmentNorms norm : norms.values()) {
@@ -401,7 +403,7 @@ public class SegmentReader extends Index
   @Override
   public boolean hasDeletions() {
     // Don't call ensureOpen() here (it could affect performance)
-    return deletedDocs != null;
+    return liveDocs != null;
   }
 
   static boolean usesCompoundFile(SegmentInfo si) throws IOException {
@@ -414,38 +416,39 @@ public class SegmentReader extends Index
 
   @Override
   protected void doDelete(int docNum) {
-    if (deletedDocs == null) {
-      deletedDocs = new BitVector(maxDoc());
-      deletedDocsRef = new AtomicInteger(1);
+    if (liveDocs == null) {
+      liveDocs = new BitVector(maxDoc());
+      liveDocs.setAll();
+      liveDocsRef = new AtomicInteger(1);
     }
     // there is more than 1 SegmentReader with a reference to this
-    // deletedDocs BitVector so decRef the current deletedDocsRef,
-    // clone the BitVector, create a new deletedDocsRef
-    if (deletedDocsRef.get() > 1) {
-      AtomicInteger oldRef = deletedDocsRef;
-      deletedDocs = cloneDeletedDocs(deletedDocs);
-      deletedDocsRef = new AtomicInteger(1);
+    // liveDocs BitVector so decRef the current liveDocsRef,
+    // clone the BitVector, create a new liveDocsRef
+    if (liveDocsRef.get() > 1) {
+      AtomicInteger oldRef = liveDocsRef;
+      liveDocs = cloneDeletedDocs(liveDocs);
+      liveDocsRef = new AtomicInteger(1);
       oldRef.decrementAndGet();
     }
-    deletedDocsDirty = true;
-    if (!deletedDocs.getAndSet(docNum)) {
+    liveDocsDirty = true;
+    if (liveDocs.getAndClear(docNum)) {
       pendingDeleteCount++;
     }
   }
 
   @Override
   protected void doUndeleteAll() {
-    deletedDocsDirty = false;
-    if (deletedDocs != null) {
-      assert deletedDocsRef != null;
-      deletedDocsRef.decrementAndGet();
-      deletedDocs = null;
-      deletedDocsRef = null;
+    liveDocsDirty = false;
+    if (liveDocs != null) {
+      assert liveDocsRef != null;
+      liveDocsRef.decrementAndGet();
+      liveDocs = null;
+      liveDocsRef = null;
       pendingDeleteCount = 0;
       si.clearDelGen();
       si.setDelCount(0);
     } else {
-      assert deletedDocsRef == null;
+      assert liveDocsRef == null;
       assert pendingDeleteCount == 0;
     }
   }
@@ -484,10 +487,11 @@ public class SegmentReader extends Index
   @Override
   public int numDocs() {
     // Don't call ensureOpen() here (it could affect performance)
-    int n = maxDoc();
-    if (deletedDocs != null)
-      n -= deletedDocs.count();
-    return n;
+    if (liveDocs != null) {
+      return liveDocs.count();
+    } else {
+      return maxDoc();
+    }
   }
 
   @Override
@@ -790,7 +794,7 @@ public class SegmentReader extends Index
   void startCommit() {
     rollbackSegmentInfo = (SegmentInfo) si.clone();
     rollbackHasChanges = hasChanges;
-    rollbackDeletedDocsDirty = deletedDocsDirty;
+    rollbackDeletedDocsDirty = liveDocsDirty;
     rollbackNormsDirty = normsDirty;
     rollbackPendingDeleteCount = pendingDeleteCount;
     for (SegmentNorms norm : norms.values()) {
@@ -801,7 +805,7 @@ public class SegmentReader extends Index
   void rollbackCommit() {
     si.reset(rollbackSegmentInfo);
     hasChanges = rollbackHasChanges;
-    deletedDocsDirty = rollbackDeletedDocsDirty;
+    liveDocsDirty = rollbackDeletedDocsDirty;
     normsDirty = rollbackNormsDirty;
     pendingDeleteCount = rollbackPendingDeleteCount;
     for (SegmentNorms norm : norms.values()) {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentWriteState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentWriteState.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentWriteState.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SegmentWriteState.java Wed Jul  6 21:16:33 2011
@@ -40,7 +40,7 @@ public class SegmentWriteState {
   public final BufferedDeletes segDeletes;
 
   // Lazily created:
-  public BitVector deletedDocs;
+  public BitVector liveDocs;
 
   final SegmentCodecs segmentCodecs;
   public final int codecId;

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SlowMultiReaderWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SlowMultiReaderWrapper.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SlowMultiReaderWrapper.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/SlowMultiReaderWrapper.java Wed Jul  6 21:16:33 2011
@@ -76,10 +76,9 @@ public final class SlowMultiReaderWrappe
   }
 
   @Override
-  public Bits getDeletedDocs() {
-    return MultiFields.getDeletedDocs(in);
+  public Bits getLiveDocs() {
+    return MultiFields.getLiveDocs(in);
   }
-
   
   @Override
   public IndexReader[] getSequentialSubReaders() {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/Terms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/Terms.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/Terms.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/Terms.java Wed Jul  6 21:16:33 2011
@@ -57,9 +57,12 @@ public abstract class Terms {
     }
   }
 
-  /** Returns the number of documents containing the
-   *  specified term text.  Returns 0 if the term does not
-   *  exist. */
+  /** Returns the total number of occurrences of this term
+   *  across all documents (the sum of the freq() for each
+   *  doc that has this term).  This will be -1 if the
+   *  codec doesn't support this measure.  Note that, like
+   *  other term measures, this measure does not take
+   *  deleted documents into account. */
   public long totalTermFreq(BytesRef text) throws IOException {
     final TermsEnum termsEnum = getThreadTermsEnum();
     if (termsEnum.seekExact(text, true)) {
@@ -71,10 +74,10 @@ public abstract class Terms {
 
   /** Get {@link DocsEnum} for the specified term.  This
    *  method may return null if the term does not exist. */
-  public DocsEnum docs(Bits skipDocs, BytesRef text, DocsEnum reuse) throws IOException {
+  public DocsEnum docs(Bits liveDocs, BytesRef text, DocsEnum reuse) throws IOException {
     final TermsEnum termsEnum = getThreadTermsEnum();
     if (termsEnum.seekExact(text, true)) {
-      return termsEnum.docs(skipDocs, reuse);
+      return termsEnum.docs(liveDocs, reuse);
     } else {
       return null;
     }
@@ -83,10 +86,10 @@ public abstract class Terms {
   /** Get {@link DocsEnum} for the specified term.  This
    *  method will may return null if the term does not
    *  exists, or positions were not indexed. */ 
-  public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, BytesRef text, DocsAndPositionsEnum reuse) throws IOException {
+  public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, BytesRef text, DocsAndPositionsEnum reuse) throws IOException {
     final TermsEnum termsEnum = getThreadTermsEnum();
     if (termsEnum.seekExact(text, true)) {
-      return termsEnum.docsAndPositions(skipDocs, reuse);
+      return termsEnum.docsAndPositions(liveDocs, reuse);
     } else {
       return null;
     }
@@ -98,10 +101,10 @@ public abstract class Terms {
    * 
    * @see TermsEnum#termState()
    * @see TermsEnum#seekExact(BytesRef, TermState) */
-  public DocsEnum docs(Bits skipDocs, BytesRef term, TermState termState, DocsEnum reuse) throws IOException {
+  public DocsEnum docs(Bits liveDocs, BytesRef term, TermState termState, DocsEnum reuse) throws IOException {
     final TermsEnum termsEnum = getThreadTermsEnum();
     termsEnum.seekExact(term, termState);
-    return termsEnum.docs(skipDocs, reuse);
+    return termsEnum.docs(liveDocs, reuse);
   }
 
   /**
@@ -111,10 +114,10 @@ public abstract class Terms {
    * 
    * @see TermsEnum#termState()
    * @see TermsEnum#seekExact(BytesRef, TermState) */
-  public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, BytesRef term, TermState termState, DocsAndPositionsEnum reuse) throws IOException {
+  public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, BytesRef term, TermState termState, DocsAndPositionsEnum reuse) throws IOException {
     final TermsEnum termsEnum = getThreadTermsEnum();
     termsEnum.seekExact(term, termState);
-    return termsEnum.docsAndPositions(skipDocs, reuse);
+    return termsEnum.docsAndPositions(liveDocs, reuse);
   }
 
   public long getUniqueTermCount() throws IOException {

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/TermsEnum.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/TermsEnum.java Wed Jul  6 21:16:33 2011
@@ -147,16 +147,16 @@ public abstract class TermsEnum {
    *  call this when the enum is unpositioned.  This method
    *  will not return null.
    *  
-   * @param skipDocs set bits are documents that should not
+   * @param liveDocs set bits are documents that should not
    * be returned
    * @param reuse pass a prior DocsEnum for possible reuse */
-  public abstract DocsEnum docs(Bits skipDocs, DocsEnum reuse) throws IOException;
+  public abstract DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException;
 
   /** Get {@link DocsAndPositionsEnum} for the current term.
    *  Do not call this when the enum is unpositioned.
    *  This method will only return null if positions were
    *  not indexed into the postings by this codec. */
-  public abstract DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException;
+  public abstract DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException;
 
   /**
    * Expert: Returns the TermsEnums internal state to position the TermsEnum
@@ -224,12 +224,12 @@ public abstract class TermsEnum {
     }
 
     @Override
-    public DocsEnum docs(Bits bits, DocsEnum reuse) {
+    public DocsEnum docs(Bits liveDocs, DocsEnum reuse) {
       throw new IllegalStateException("this method should never be called");
     }
       
     @Override
-    public DocsAndPositionsEnum docsAndPositions(Bits bits, DocsAndPositionsEnum reuse) {
+    public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) {
       throw new IllegalStateException("this method should never be called");
     }
       

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java Wed Jul  6 21:16:33 2011
@@ -688,23 +688,23 @@ public class BlockTermsReader extends Fi
       }
 
       @Override
-      public DocsEnum docs(Bits skipDocs, DocsEnum reuse) throws IOException {
+      public DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException {
         //System.out.println("BTR.docs this=" + this);
         decodeMetaData();
         //System.out.println("  state.docFreq=" + state.docFreq);
-        final DocsEnum docsEnum = postingsReader.docs(fieldInfo, state, skipDocs, reuse);
+        final DocsEnum docsEnum = postingsReader.docs(fieldInfo, state, liveDocs, reuse);
         assert docsEnum != null;
         return docsEnum;
       }
 
       @Override
-      public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException {
+      public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException {
         //System.out.println("BTR.d&p this=" + this);
         decodeMetaData();
         if (fieldInfo.omitTermFreqAndPositions) {
           return null;
         } else {
-          DocsAndPositionsEnum dpe = postingsReader.docsAndPositions(fieldInfo, state, skipDocs, reuse);
+          DocsAndPositionsEnum dpe = postingsReader.docsAndPositions(fieldInfo, state, liveDocs, reuse);
           //System.out.println("  return d&pe=" + dpe);
           return dpe;
         }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java Wed Jul  6 21:16:33 2011
@@ -114,8 +114,8 @@ public abstract class DocValuesConsumer 
       final IndexDocValues r = reader.docValues(mergeState.fieldInfo.name);
       if (r != null) {
         merged = true;
-        merge(new Writer.MergeState(r, docBase, reader.maxDoc(), reader
-            .getDeletedDocs()));
+        merge(new Writer.MergeState(r, docBase, reader.maxDoc(),
+                                    reader.getLiveDocs()));
       }
       docBase += reader.numDocs();
     }
@@ -152,15 +152,15 @@ public abstract class DocValuesConsumer 
     public final int docBase;
     /** the number of documents in this MergeState */
     public final int docCount;
-    /** the deleted bits for this MergeState */
-    public final Bits bits;
+    /** the not deleted bits for this MergeState */
+    public final Bits liveDocs;
 
-    public MergeState(IndexDocValues reader, int docBase, int docCount, Bits bits) {
+    public MergeState(IndexDocValues reader, int docBase, int docCount, Bits liveDocs) {
       assert reader != null;
       this.reader = reader;
       this.docBase = docBase;
       this.docCount = docCount;
-      this.bits = bits;
+      this.liveDocs = liveDocs;
     }
   }
 }

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/MergeState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/MergeState.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/MergeState.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/MergeState.java Wed Jul  6 21:16:33 2011
@@ -39,7 +39,7 @@ public class MergeState {
   public int[] delCounts;                         // Deletion count per reader
   public int[] docBase;                           // New docID base per reader
   public int mergedDocCount;                      // Total # merged docs
-  public Bits multiDeletedDocs;
+  public Bits multiLiveDocs;
   public CheckAbort checkAbort;
 
   // Updated per field;

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/PostingsReaderBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/PostingsReaderBase.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/PostingsReaderBase.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/PostingsReaderBase.java Wed Jul  6 21:16:33 2011
@@ -49,11 +49,11 @@ public abstract class PostingsReaderBase
 
   /** Must fully consume state, since after this call that
    *  TermState may be reused. */
-  public abstract DocsEnum docs(FieldInfo fieldInfo, BlockTermState state, Bits skipDocs, DocsEnum reuse) throws IOException;
+  public abstract DocsEnum docs(FieldInfo fieldInfo, BlockTermState state, Bits liveDocs, DocsEnum reuse) throws IOException;
 
   /** Must fully consume state, since after this call that
    *  TermState may be reused. */
-  public abstract DocsAndPositionsEnum docsAndPositions(FieldInfo fieldInfo, BlockTermState state, Bits skipDocs, DocsAndPositionsEnum reuse) throws IOException;
+  public abstract DocsAndPositionsEnum docsAndPositions(FieldInfo fieldInfo, BlockTermState state, Bits liveDocs, DocsAndPositionsEnum reuse) throws IOException;
 
   public abstract void close() throws IOException;
 

Modified: lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/TermsConsumer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/TermsConsumer.java?rev=1143567&r1=1143566&r2=1143567&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/TermsConsumer.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/java/org/apache/lucene/index/codecs/TermsConsumer.java Wed Jul  6 21:16:33 2011
@@ -67,7 +67,7 @@ public abstract class TermsConsumer {
       MultiDocsEnum docsEnumIn = null;
 
       while((term = termsEnum.next()) != null) {
-        docsEnumIn = (MultiDocsEnum) termsEnum.docs(mergeState.multiDeletedDocs, docsEnumIn);
+        docsEnumIn = (MultiDocsEnum) termsEnum.docs(mergeState.multiLiveDocs, docsEnumIn);
         if (docsEnumIn != null) {
           docsEnum.reset(docsEnumIn);
           final PostingsConsumer postingsConsumer = startTerm(term);
@@ -89,7 +89,7 @@ public abstract class TermsConsumer {
       postingsEnum.setMergeState(mergeState);
       MultiDocsAndPositionsEnum postingsEnumIn = null;
       while((term = termsEnum.next()) != null) {
-        postingsEnumIn = (MultiDocsAndPositionsEnum) termsEnum.docsAndPositions(mergeState.multiDeletedDocs, postingsEnumIn);
+        postingsEnumIn = (MultiDocsAndPositionsEnum) termsEnum.docsAndPositions(mergeState.multiLiveDocs, postingsEnumIn);
         if (postingsEnumIn != null) {
           postingsEnum.reset(postingsEnumIn);
           // set PayloadProcessor