lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1210184 [2/3] - in /lucene/dev/branches/lucene3606: ./ lucene/ lucene/contrib/memory/src/java/org/apache/lucene/index/memory/ lucene/contrib/memory/src/test/org/apache/lucene/index/memory/ lucene/contrib/misc/src/java/org/apache/lucene/mis...
Date Sun, 04 Dec 2011 19:18:20 GMT
Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java Sun Dec  4 19:18:17 2011
@@ -259,8 +259,8 @@ public final class FuzzyTermsEnum extend
   }
   
   @Override
-  public DocsEnum docs(Bits liveDocs, DocsEnum reuse) throws IOException {
-    return actualEnum.docs(liveDocs, reuse);
+  public DocsEnum docs(Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
+    return actualEnum.docs(liveDocs, reuse, needsFreqs);
   }
   
   @Override

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sun Dec  4 19:18:17 2011
@@ -229,7 +229,7 @@ public class MultiPhraseQuery extends Qu
 
           if (postingsEnum == null) {
             // term does exist, but has no positions
-            assert termsEnum.docs(liveDocs, null) != null: "termstate found but no term exists in reader";
+            assert termsEnum.docs(liveDocs, null, false) != null: "termstate found but no term exists in reader";
             throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
           }
 

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java Sun Dec  4 19:18:17 2011
@@ -105,7 +105,7 @@ public class MultiTermQueryWrapperFilter
       do {
         // System.out.println("  iter termCount=" + termCount + " term=" +
         // enumerator.term().toBytesString());
-        docsEnum = termsEnum.docs(acceptDocs, docsEnum);
+        docsEnum = termsEnum.docs(acceptDocs, docsEnum, false);
         int docid;
         while ((docid = docsEnum.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
           bitSet.set(docid);

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/PhraseQuery.java Sun Dec  4 19:18:17 2011
@@ -244,7 +244,7 @@ public class PhraseQuery extends Query {
         // PhraseQuery on a field that did not index
         // positions.
         if (postingsEnum == null) {
-          assert reader.termDocsEnum(liveDocs, t.field(), t.bytes(), state) != null: "termstate found but no term exists in reader";
+          assert reader.termDocsEnum(liveDocs, t.field(), t.bytes(), state, false) != null: "termstate found but no term exists in reader";
           // term does exist, but has no positions
           throw new IllegalStateException("field \"" + t.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + t.text() + ")");
         }

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/TermQuery.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/search/TermQuery.java Sun Dec  4 19:18:17 2011
@@ -21,18 +21,18 @@ import java.io.IOException;
 import java.util.Set;
 
 import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.TermState;
-import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader.ReaderContext;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.index.TermState;
+import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.search.similarities.Similarity.ExactDocScorer;
+import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ReaderUtil;
+import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents containing a term.
@@ -83,10 +83,15 @@ public class TermQuery extends Query {
       if (termsEnum == null) {
         return null;
       }
-      // TODO should we reuse the DocsEnum here? 
-      final DocsEnum docs = termsEnum.docs(acceptDocs, null);
-      assert docs != null;
-      return new TermScorer(this, docs, createDocScorer(context));
+      DocsEnum docs = termsEnum.docs(acceptDocs, null, true);
+      if (docs != null) {
+        return new TermScorer(this, docs, createDocScorer(context));
+      } else {
+        // Index does not store freq info
+        docs = termsEnum.docs(acceptDocs, null, false);
+        assert docs != null;
+        return new MatchOnlyTermScorer(this, docs, createDocScorer(context));
+      }
     }
     
     /**
@@ -120,12 +125,11 @@ public class TermQuery extends Query {
     
     @Override
     public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
-      IndexReader reader = context.reader;
-      DocsEnum docs = reader.termDocsEnum(context.reader.getLiveDocs(), term.field(), term.bytes());
-      if (docs != null) {
-        int newDoc = docs.advance(doc);
+      Scorer scorer = scorer(context, true, false, context.reader.getLiveDocs());
+      if (scorer != null) {
+        int newDoc = scorer.advance(doc);
         if (newDoc == doc) {
-          int freq = docs.freq();
+          float freq = scorer.freq();
           ExactDocScorer docScorer = similarity.exactDocScorer(stats, term.field(), context);
           ComplexExplanation result = new ComplexExplanation();
           result.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
@@ -136,8 +140,7 @@ public class TermQuery extends Query {
           return result;
         }
       }
-      
-      return new ComplexExplanation(false, 0.0f, "no matching term");
+      return new ComplexExplanation(false, 0.0f, "no matching term");      
     }
   }
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/index/codecs/ramonly/RAMOnlyPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/index/codecs/ramonly/RAMOnlyPostingsFormat.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/index/codecs/ramonly/RAMOnlyPostingsFormat.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/index/codecs/ramonly/RAMOnlyPostingsFormat.java Sun Dec  4 19:18:17 2011
@@ -383,7 +383,7 @@ public class RAMOnlyPostingsFormat exten
     }
 
     @Override
-    public DocsEnum docs(Bits liveDocs, DocsEnum reuse) {
+    public DocsEnum docs(Bits liveDocs, DocsEnum reuse, boolean needsFreqs) {
       return new RAMDocsEnum(ramField.termToDocs.get(current), liveDocs);
     }
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/util/_TestUtil.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test-framework/java/org/apache/lucene/util/_TestUtil.java Sun Dec  4 19:18:17 2011
@@ -37,12 +37,18 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CheckIndex;
 import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.LogMergePolicy;
 import org.apache.lucene.index.MergePolicy;
 import org.apache.lucene.index.MergeScheduler;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.TieredMergePolicy;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.PostingsFormat;
@@ -520,4 +526,51 @@ public class _TestUtil {
 
     return doc2;
   }
+
+  // Returns a DocsEnum, but randomly sometimes uses a
+  // DocsAndFreqsEnum, DocsAndPositionsEnum.  Returns null
+  // if field/term doesn't exist:
+  public static DocsEnum docs(Random random, IndexReader r, String field, BytesRef term, Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
+    final Terms terms = MultiFields.getTerms(r, field);
+    if (terms == null) {
+      return null;
+    }
+    final TermsEnum termsEnum = terms.iterator(null);
+    if (!termsEnum.seekExact(term, random.nextBoolean())) {
+      return null;
+    }
+    if (random.nextBoolean()) {
+      if (random.nextBoolean()) {
+        // TODO: cast re-use to D&PE if we can...?
+        final DocsAndPositionsEnum docsAndPositions = termsEnum.docsAndPositions(liveDocs, null);
+        if (docsAndPositions != null) {
+          return docsAndPositions;
+        }
+      }
+      final DocsEnum docsAndFreqs = termsEnum.docs(liveDocs, reuse, true);
+      if (docsAndFreqs != null) {
+        return docsAndFreqs;
+      }
+    }
+    return termsEnum.docs(liveDocs, reuse, needsFreqs);
+  }
+
+  // Returns a DocsEnum from a positioned TermsEnum, but
+  // randomly sometimes uses a DocsAndFreqsEnum, DocsAndPositionsEnum.
+  public static DocsEnum docs(Random random, TermsEnum termsEnum, Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
+    if (random.nextBoolean()) {
+      if (random.nextBoolean()) {
+        // TODO: cast re-use to D&PE if we can...?
+        final DocsAndPositionsEnum docsAndPositions = termsEnum.docsAndPositions(liveDocs, null);
+        if (docsAndPositions != null) {
+          return docsAndPositions;
+        }
+      }
+      final DocsEnum docsAndFreqs = termsEnum.docs(liveDocs, null, true);
+      if (docsAndFreqs != null) {
+        return docsAndFreqs;
+      }
+    }
+    return termsEnum.docs(liveDocs, null, needsFreqs);
+  }
 }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java Sun Dec  4 19:18:17 2011
@@ -532,7 +532,7 @@ public class TestAddIndexes extends Luce
   private void verifyTermDocs(Directory dir, Term term, int numDocs)
       throws IOException {
     IndexReader reader = IndexReader.open(dir, true);
-    DocsEnum docsEnum = MultiFields.getTermDocsEnum(reader, null, term.field, term.bytes);
+    DocsEnum docsEnum = _TestUtil.docs(random, reader, term.field, term.bytes, null, null, false);
     int count = 0;
     while (docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)
       count++;

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Sun Dec  4 19:18:17 2011
@@ -599,7 +599,7 @@ public class TestBackwardsCompatibility 
       // should be found exactly
       assertEquals(TermsEnum.SeekStatus.FOUND,
                    terms.seekCeil(aaaTerm));
-      assertEquals(35, countDocs(terms.docs(null, null)));
+      assertEquals(35, countDocs(_TestUtil.docs(random, terms, null, null, false)));
       assertNull(terms.next());
 
       // should hit end of field
@@ -611,12 +611,12 @@ public class TestBackwardsCompatibility 
       assertEquals(TermsEnum.SeekStatus.NOT_FOUND,
                    terms.seekCeil(new BytesRef("a")));
       assertTrue(terms.term().bytesEquals(aaaTerm));
-      assertEquals(35, countDocs(terms.docs(null, null)));
+      assertEquals(35, countDocs(_TestUtil.docs(random, terms, null, null, false)));
       assertNull(terms.next());
 
       assertEquals(TermsEnum.SeekStatus.FOUND,
                    terms.seekCeil(aaaTerm));
-      assertEquals(35, countDocs(terms.docs(null, null)));
+      assertEquals(35, countDocs(_TestUtil.docs(random, terms,null, null, false)));
       assertNull(terms.next());
 
       r.close();

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestCodecs.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestCodecs.java Sun Dec  4 19:18:17 2011
@@ -279,7 +279,7 @@ public class TestCodecs extends LuceneTe
       // make sure it properly fully resets (rewinds) its
       // internal state:
       for(int iter=0;iter<2;iter++) {
-        docsEnum = termsEnum.docs(null,  docsEnum);
+        docsEnum = _TestUtil.docs(random, termsEnum, null,  docsEnum, false);
         assertEquals(terms[i].docs[0], docsEnum.nextDoc());
         assertEquals(DocsEnum.NO_MORE_DOCS, docsEnum.nextDoc());
       }
@@ -479,7 +479,7 @@ public class TestCodecs extends LuceneTe
         assertEquals(status, TermsEnum.SeekStatus.FOUND);
         assertEquals(term.docs.length, termsEnum.docFreq());
         if (field.omitTF) {
-          this.verifyDocs(term.docs, term.positions, termsEnum.docs(null, null), false);
+          this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random, termsEnum, null, null, false), false);
         } else {
           this.verifyDocs(term.docs, term.positions, termsEnum.docsAndPositions(null, null), true);
         }
@@ -499,7 +499,7 @@ public class TestCodecs extends LuceneTe
           assertTrue(termsEnum.term().bytesEquals(new BytesRef(term.text2)));
           assertEquals(term.docs.length, termsEnum.docFreq());
           if (field.omitTF) {
-            this.verifyDocs(term.docs, term.positions, termsEnum.docs(null, null), false);
+            this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random, termsEnum, null, null, false), false);
           } else {
             this.verifyDocs(term.docs, term.positions, termsEnum.docsAndPositions(null, null), true);
           }
@@ -549,15 +549,22 @@ public class TestCodecs extends LuceneTe
         do {
           term = field.terms[upto];
           if (TestCodecs.random.nextInt(3) == 1) {
-            final DocsEnum docs = termsEnum.docs(null, null);
-            final DocsAndPositionsEnum postings = termsEnum.docsAndPositions(null, null);
-
-            final DocsEnum docsEnum;
-            if (postings != null) {
-              docsEnum = postings;
+            final DocsEnum docs;
+            final DocsEnum docsAndFreqs;
+            final DocsAndPositionsEnum postings;
+            if (!field.omitTF) {
+              postings = termsEnum.docsAndPositions(null, null);
+              if (postings != null) {
+                docs = docsAndFreqs = postings;
+              } else {
+                docs = docsAndFreqs = _TestUtil.docs(random, termsEnum, null, null, true);
+              }
             } else {
-              docsEnum = docs;
+              postings = null;
+              docsAndFreqs = null;
+              docs = _TestUtil.docs(random, termsEnum, null, null, false);
             }
+            assertNotNull(docs);
             int upto2 = -1;
             while(upto2 < term.docs.length-1) {
               // Maybe skip:
@@ -567,10 +574,10 @@ public class TestCodecs extends LuceneTe
                 final int inc = 1+TestCodecs.random.nextInt(left-1);
                 upto2 += inc;
                 if (TestCodecs.random.nextInt(2) == 1) {
-                  doc = docsEnum.advance(term.docs[upto2]);
+                  doc = docs.advance(term.docs[upto2]);
                   assertEquals(term.docs[upto2], doc);
                 } else {
-                  doc = docsEnum.advance(1+term.docs[upto2]);
+                  doc = docs.advance(1+term.docs[upto2]);
                   if (doc == DocIdSetIterator.NO_MORE_DOCS) {
                     // skipped past last doc
                     assert upto2 == term.docs.length-1;
@@ -584,20 +591,20 @@ public class TestCodecs extends LuceneTe
                   }
                 }
               } else {
-                doc = docsEnum.nextDoc();
+                doc = docs.nextDoc();
                 assertTrue(doc != -1);
                 upto2++;
               }
               assertEquals(term.docs[upto2], doc);
               if (!field.omitTF) {
-                assertEquals(term.positions[upto2].length, docsEnum.freq());
+                assertEquals(term.positions[upto2].length, postings.freq());
                 if (TestCodecs.random.nextInt(2) == 1) {
                   this.verifyPositions(term.positions[upto2], postings);
                 }
               }
             }
 
-            assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
+            assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
           }
           upto++;
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java Sun Dec  4 19:18:17 2011
@@ -17,7 +17,8 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
+import java.io.IOException;
+import java.util.Random;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
@@ -25,9 +26,8 @@ import org.apache.lucene.document.TextFi
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-
-import java.io.IOException;
-import java.util.Random;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestDirectoryReader extends LuceneTestCase {
   protected Directory dir;
@@ -129,15 +129,18 @@ public class TestDirectoryReader extends
     // test mixing up TermDocs and TermEnums from different readers.
     TermsEnum te2 = MultiFields.getTerms(mr2, "body").iterator(null);
     te2.seekCeil(new BytesRef("wow"));
-    DocsEnum td = MultiFields.getTermDocsEnum(mr2,
-                                              MultiFields.getLiveDocs(mr2),
-                                              "body",
-                                              te2.term());
+    DocsEnum td = _TestUtil.docs(random, mr2,
+                                 "body",
+                                 te2.term(),
+                                 MultiFields.getLiveDocs(mr2),
+                                 null,
+                                 false);
 
     TermsEnum te3 = MultiFields.getTerms(mr3, "body").iterator(null);
     te3.seekCeil(new BytesRef("wow"));
-    td = te3.docs(MultiFields.getLiveDocs(mr3),
-                  td);
+    td = _TestUtil.docs(random, te3, MultiFields.getLiveDocs(mr3),
+                        td,
+                        false);
     
     int ret = 0;
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocCount.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocCount.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocCount.java Sun Dec  4 19:18:17 2011
@@ -68,11 +68,14 @@ public class TestDocCount extends Lucene
     String field;
     while ((field = e.next()) != null) {
       Terms terms = fields.terms(field);
+      if (terms == null) {
+        continue;
+      }
       int docCount = terms.getDocCount();
       FixedBitSet visited = new FixedBitSet(ir.maxDoc());
       TermsEnum te = terms.iterator(null);
       while (te.next() != null) {
-        DocsEnum de = te.docs(null, null);
+        DocsEnum de = _TestUtil.docs(random, te, null, null, false);
         while (de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
           visited.set(de.docID());
         }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java Sun Dec  4 19:18:17 2011
@@ -22,7 +22,6 @@ import java.util.Arrays;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
@@ -34,6 +33,7 @@ import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ReaderUtil;
+import org.apache.lucene.util._TestUtil;
 
 public class TestDocsAndPositions extends LuceneTestCase {
   private String fieldName;
@@ -99,16 +99,6 @@ public class TestDocsAndPositions extend
       return reader.termPositionsEnum(null, fieldName, bytes);
   }
 
-  public DocsEnum getDocsEnum(IndexReader reader, BytesRef bytes,
-      boolean freqs, Bits liveDocs) throws IOException {
-    int randInt = random.nextInt(10);
-    if (randInt == 0) { // once in a while throw in a positions enum
-      return getDocsAndPositions(reader, bytes, liveDocs);
-    } else {
-      return reader.termDocsEnum(liveDocs, fieldName, bytes);
-    } 
-  }
-
   /**
    * this test indexes random numbers within a range into a field and checks
    * their occurrences by searching for a number from that range selected at
@@ -232,31 +222,31 @@ public class TestDocsAndPositions extend
       AtomicReaderContext[] leaves = ReaderUtil.leaves(topReaderContext);
       for (AtomicReaderContext context : leaves) {
         int maxDoc = context.reader.maxDoc();
-        DocsEnum docsAndPosEnum = getDocsEnum(context.reader, bytes, true, null);
+        DocsEnum docsEnum = _TestUtil.docs(random, context.reader, fieldName, bytes, null, null, true);
         if (findNext(freqInDoc, context.docBase, context.docBase + maxDoc) == Integer.MAX_VALUE) {
-          assertNull(docsAndPosEnum);
+          assertNull(docsEnum);
           continue;
         }
-        assertNotNull(docsAndPosEnum);
-        docsAndPosEnum.nextDoc();
+        assertNotNull(docsEnum);
+        docsEnum.nextDoc();
         for (int j = 0; j < maxDoc; j++) {
           if (freqInDoc[context.docBase + j] != 0) {
-            assertEquals(j, docsAndPosEnum.docID());
-            assertEquals(docsAndPosEnum.freq(), freqInDoc[context.docBase +j]);
+            assertEquals(j, docsEnum.docID());
+            assertEquals(docsEnum.freq(), freqInDoc[context.docBase +j]);
             if (i % 2 == 0 && random.nextInt(10) == 0) {
               int next = findNext(freqInDoc, context.docBase+j+1, context.docBase + maxDoc) - context.docBase;
-              int advancedTo = docsAndPosEnum.advance(next);
+              int advancedTo = docsEnum.advance(next);
               if (next >= maxDoc) {
                 assertEquals(DocsEnum.NO_MORE_DOCS, advancedTo);
               } else {
                 assertTrue("advanced to: " +advancedTo + " but should be <= " + next, next >= advancedTo);  
               }
             } else {
-              docsAndPosEnum.nextDoc();
+              docsEnum.nextDoc();
             }
           } 
         }
-        assertEquals("docBase: " + context.docBase + " maxDoc: " + maxDoc + " " + docsAndPosEnum.getClass(), DocsEnum.NO_MORE_DOCS, docsAndPosEnum.docID());
+        assertEquals("docBase: " + context.docBase + " maxDoc: " + maxDoc + " " + docsEnum.getClass(), DocsEnum.NO_MORE_DOCS, docsEnum.docID());
       }
       
     }
@@ -343,7 +333,7 @@ public class TestDocsAndPositions extend
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
     IndexReader r = getOnlySegmentReader(reader);
-    DocsEnum disi = r.termDocsEnum(null, "foo", new BytesRef("bar"));
+    DocsEnum disi = _TestUtil.docs(random, r, "foo", new BytesRef("bar"), null, null, false);
     int docid = disi.docID();
     assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
     assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -351,7 +341,7 @@ public class TestDocsAndPositions extend
     // now reuse and check again
     TermsEnum te = r.terms("foo").iterator(null);
     assertTrue(te.seekExact(new BytesRef("bar"), true));
-    disi = te.docs(null, disi);
+    disi = _TestUtil.docs(random, te, null, disi, false);
     docid = disi.docID();
     assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
     assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java Sun Dec  4 19:18:17 2011
@@ -270,18 +270,42 @@ public class TestDuelingCodecs extends L
         assertPositionsSkipping(leftTermsEnum.docFreq(), 
             leftPositions = leftTermsEnum.docsAndPositions(randomBits, leftPositions),
             rightPositions = rightTermsEnum.docsAndPositions(randomBits, rightPositions));
+
+        // with freqs:
+        assertDocsEnum(leftDocs = leftTermsEnum.docs(null, leftDocs, true),
+            rightDocs = rightTermsEnum.docs(null, rightDocs, true),
+            true);
+        assertDocsEnum(leftDocs = leftTermsEnum.docs(randomBits, leftDocs, true),
+            rightDocs = rightTermsEnum.docs(randomBits, rightDocs, true),
+            true);
+
+        // w/o freqs:
+        assertDocsEnum(leftDocs = leftTermsEnum.docs(null, leftDocs, false),
+            rightDocs = rightTermsEnum.docs(null, rightDocs, false),
+            false);
+        assertDocsEnum(leftDocs = leftTermsEnum.docs(randomBits, leftDocs, false),
+            rightDocs = rightTermsEnum.docs(randomBits, rightDocs, false),
+            false);
         
-        assertDocsEnum(leftDocs = leftTermsEnum.docs(null, leftDocs),
-            rightDocs = rightTermsEnum.docs(null, rightDocs));
-        assertDocsEnum(leftDocs = leftTermsEnum.docs(randomBits, leftDocs),
-            rightDocs = rightTermsEnum.docs(randomBits, rightDocs));
-        
+        // with freqs:
         assertDocsSkipping(leftTermsEnum.docFreq(), 
-            leftDocs = leftTermsEnum.docs(null, leftDocs),
-            rightDocs = rightTermsEnum.docs(null, rightDocs));
+            leftDocs = leftTermsEnum.docs(null, leftDocs, true),
+            rightDocs = rightTermsEnum.docs(null, rightDocs, true),
+            true);
         assertDocsSkipping(leftTermsEnum.docFreq(), 
-            leftDocs = leftTermsEnum.docs(randomBits, leftDocs),
-            rightDocs = rightTermsEnum.docs(randomBits, rightDocs));
+            leftDocs = leftTermsEnum.docs(randomBits, leftDocs, true),
+            rightDocs = rightTermsEnum.docs(randomBits, rightDocs, true),
+            true);
+
+        // w/o freqs:
+        assertDocsSkipping(leftTermsEnum.docFreq(), 
+            leftDocs = leftTermsEnum.docs(null, leftDocs, false),
+            rightDocs = rightTermsEnum.docs(null, rightDocs, false),
+            false);
+        assertDocsSkipping(leftTermsEnum.docFreq(), 
+            leftDocs = leftTermsEnum.docs(randomBits, leftDocs, false),
+            rightDocs = rightTermsEnum.docs(randomBits, rightDocs, false),
+            false);
       }
     }
     assertNull(info, rightTermsEnum.next());
@@ -327,13 +351,19 @@ public class TestDuelingCodecs extends L
   /**
    * checks docs + freqs, sequentially
    */
-  public void assertDocsEnum(DocsEnum leftDocs, DocsEnum rightDocs) throws Exception {
+  public void assertDocsEnum(DocsEnum leftDocs, DocsEnum rightDocs, boolean hasFreqs) throws Exception {
+    if (leftDocs == null) {
+      assertNull(rightDocs);
+      return;
+    }
     assertTrue(info, leftDocs.docID() == -1 || leftDocs.docID() == DocIdSetIterator.NO_MORE_DOCS);
     assertTrue(info, rightDocs.docID() == -1 || rightDocs.docID() == DocIdSetIterator.NO_MORE_DOCS);
     int docid;
     while ((docid = leftDocs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
       assertEquals(info, docid, rightDocs.nextDoc());
-      assertEquals(info, leftDocs.freq(), rightDocs.freq());
+      if (hasFreqs) {
+        assertEquals(info, leftDocs.freq(), rightDocs.freq());
+      }
     }
     assertEquals(info, DocIdSetIterator.NO_MORE_DOCS, rightDocs.nextDoc());
   }
@@ -341,7 +371,11 @@ public class TestDuelingCodecs extends L
   /**
    * checks advancing docs
    */
-  public void assertDocsSkipping(int docFreq, DocsEnum leftDocs, DocsEnum rightDocs) throws Exception {
+  public void assertDocsSkipping(int docFreq, DocsEnum leftDocs, DocsEnum rightDocs, boolean hasFreqs) throws Exception {
+    if (leftDocs == null) {
+      assertNull(rightDocs);
+      return;
+    }
     int docid = -1;
     int averageGap = leftReader.maxDoc() / (1+docFreq);
     int skipInterval = 16;
@@ -361,7 +395,9 @@ public class TestDuelingCodecs extends L
       if (docid == DocIdSetIterator.NO_MORE_DOCS) {
         return;
       }
-      assertEquals(info, leftDocs.freq(), rightDocs.freq());
+      if (hasFreqs) {
+        assertEquals(info, leftDocs.freq(), rightDocs.freq());
+      }
     }
   }
   

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexReader.java Sun Dec  4 19:18:17 2011
@@ -264,18 +264,20 @@ public class TestIndexReader extends Luc
                                      Term term,
                                      int expected)
     throws IOException {
-        DocsEnum tdocs = MultiFields.getTermDocsEnum(reader,
-                                                     MultiFields.getLiveDocs(reader),
-                                                     term.field(),
-                                                     new BytesRef(term.text()));
-        int count = 0;
-        if (tdocs != null) {
-          while(tdocs.nextDoc()!= DocIdSetIterator.NO_MORE_DOCS) {
-            count++;
-          }
-        }
-        assertEquals(msg + ", count mismatch", expected, count);
+    DocsEnum tdocs = _TestUtil.docs(random, reader,
+                                    term.field(),
+                                    new BytesRef(term.text()),
+                                    MultiFields.getLiveDocs(reader),
+                                    null,
+                                    false);
+    int count = 0;
+    if (tdocs != null) {
+      while(tdocs.nextDoc()!= DocIdSetIterator.NO_MORE_DOCS) {
+        count++;
+      }
     }
+    assertEquals(msg + ", count mismatch", expected, count);
+  }
 
     
     public void testBinaryFields() throws IOException {

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Sun Dec  4 19:18:17 2011
@@ -546,10 +546,12 @@ public class TestIndexWriter extends Luc
       assertEquals(1, reader.numDocs());
       Term t = new Term("field", "a");
       assertEquals(1, reader.docFreq(t));
-      DocsEnum td = MultiFields.getTermDocsEnum(reader,
-                                                MultiFields.getLiveDocs(reader),
-                                                "field",
-                                                new BytesRef("a"));
+      DocsEnum td = _TestUtil.docs(random, reader,
+                                   "field",
+                                   new BytesRef("a"),
+                                   MultiFields.getLiveDocs(reader),
+                                   null,
+                                   true);
       td.nextDoc();
       assertEquals(128*1024, td.freq());
       reader.close();
@@ -1334,12 +1336,12 @@ public class TestIndexWriter extends Luc
 
 
     // test that the terms were indexed.
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "binary", new BytesRef("doc1field1")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "binary", new BytesRef("doc2field1")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "binary", new BytesRef("doc3field1")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "string", new BytesRef("doc1field2")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "string", new BytesRef("doc2field2")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
-    assertTrue(MultiFields.getTermDocsEnum(ir, null, "string", new BytesRef("doc3field2")).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "binary", new BytesRef("doc1field1"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "binary", new BytesRef("doc2field1"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "binary", new BytesRef("doc3field1"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "string", new BytesRef("doc1field2"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "string", new BytesRef("doc2field2"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+    assertTrue(_TestUtil.docs(random, ir, "string", new BytesRef("doc3field2"), null, null, false).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
 
     ir.close();
     dir.close();
@@ -1411,7 +1413,7 @@ public class TestIndexWriter extends Luc
     TermsEnum t = r.fields().terms("field").iterator(null);
     int count = 0;
     while(t.next() != null) {
-      final DocsEnum docs = t.docs(null, null);
+      final DocsEnum docs = _TestUtil.docs(random, t, null, null, false);
       assertEquals(0, docs.nextDoc());
       assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
       count++;

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Sun Dec  4 19:18:17 2011
@@ -500,10 +500,12 @@ public class TestIndexWriterExceptions e
 
     // Make sure the doc that hit the exception was marked
     // as deleted:
-    DocsEnum tdocs = MultiFields.getTermDocsEnum(reader,
-                                              MultiFields.getLiveDocs(reader),
-                                              t.field(),
-                                              new BytesRef(t.text()));
+    DocsEnum tdocs = _TestUtil.docs(random, reader,
+                                    t.field(),
+                                    new BytesRef(t.text()),
+                                    MultiFields.getLiveDocs(reader),
+                                    null,
+                                    false);
 
     int count = 0;
     while(tdocs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java Sun Dec  4 19:18:17 2011
@@ -49,9 +49,11 @@ public class TestIndexWriterReader exten
   
   public static int count(Term t, IndexReader r) throws IOException {
     int count = 0;
-    DocsEnum td = MultiFields.getTermDocsEnum(r,
-                                              MultiFields.getLiveDocs(r),
-                                              t.field(), new BytesRef(t.text()));
+    DocsEnum td = _TestUtil.docs(random, r,
+                                 t.field(), new BytesRef(t.text()),
+                                 MultiFields.getLiveDocs(r),
+                                 null,
+                                 false);
 
     if (td != null) {
       while (td.nextDoc() != DocsEnum.NO_MORE_DOCS) {
@@ -990,7 +992,7 @@ public class TestIndexWriterReader exten
     w.addDocument(doc);
     IndexReader r = IndexReader.open(w, true).getSequentialSubReaders()[0];
     try {
-      r.termDocsEnum(null, "f", new BytesRef("val"));
+      _TestUtil.docs(random, r, "f", new BytesRef("val"), null, null, false);
       fail("should have failed to seek since terms index was not loaded.");
     } catch (IllegalStateException e) {
       // expected - we didn't load the term index

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java Sun Dec  4 19:18:17 2011
@@ -32,6 +32,7 @@ import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.apache.lucene.util._TestUtil;
 
 /**
  * MultiThreaded IndexWriter tests
@@ -209,10 +210,12 @@ public class TestIndexWriterWithThreads 
 
       // Quick test to make sure index is not corrupt:
       IndexReader reader = IndexReader.open(dir, true);
-      DocsEnum tdocs = MultiFields.getTermDocsEnum(reader,
-                                                  MultiFields.getLiveDocs(reader),
-                                                  "field",
-                                                  new BytesRef("aaa"));
+      DocsEnum tdocs = _TestUtil.docs(random, reader,
+                                      "field",
+                                      new BytesRef("aaa"),
+                                      MultiFields.getLiveDocs(reader),
+                                      null,
+                                      false);
       int count = 0;
       while(tdocs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
         count++;

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestLongPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestLongPostings.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestLongPostings.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestLongPostings.java Sun Dec  4 19:18:17 2011
@@ -367,7 +367,17 @@ public class TestLongPostings extends Lu
         System.out.println("\nTEST: iter=" + iter + " doS1=" + doS1 + " term=" + term);
       }
         
-      final DocsEnum postings = MultiFields.getTermDocsEnum(r, null, "field", new BytesRef(term));
+      final DocsEnum docs;
+      final DocsEnum postings;
+
+      if (options == IndexOptions.DOCS_ONLY) {
+        docs = _TestUtil.docs(random, r, "field", new BytesRef(term), null, null, false);
+        postings = null;
+      } else {
+        docs = postings = _TestUtil.docs(random, r, "field", new BytesRef(term), null, null, true);
+        assert postings != null;
+      }
+      assert docs != null;
 
       int docID = -1;
       while(docID < DocsEnum.NO_MORE_DOCS) {
@@ -388,7 +398,7 @@ public class TestLongPostings extends Lu
               expected++;
             }
           }
-          docID = postings.nextDoc();
+          docID = docs.nextDoc();
           if (VERBOSE) {
             System.out.println("  got docID=" + docID);
           }
@@ -397,7 +407,7 @@ public class TestLongPostings extends Lu
             break;
           }
 
-          if (random.nextInt(6) == 3) {
+          if (random.nextInt(6) == 3 && postings != null) {
             final int freq = postings.freq();
             assertTrue(freq >=1 && freq <= 4);
           }
@@ -424,7 +434,7 @@ public class TestLongPostings extends Lu
             }
           }
           
-          docID = postings.advance(targetDocID);
+          docID = docs.advance(targetDocID);
           if (VERBOSE) {
             System.out.println("  got docID=" + docID);
           }
@@ -433,7 +443,7 @@ public class TestLongPostings extends Lu
             break;
           }
           
-          if (random.nextInt(6) == 3) {
+          if (random.nextInt(6) == 3 && postings != null) {
             final int freq = postings.freq();
             assertTrue("got invalid freq=" + freq, freq >=1 && freq <= 4);
           }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestMultiFields.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestMultiFields.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestMultiFields.java Sun Dec  4 19:18:17 2011
@@ -120,7 +120,7 @@ public class TestMultiFields extends Luc
           System.out.println("TEST: seek term="+ UnicodeUtil.toHexString(term.utf8ToString()) + " " + term);
         }
         
-        DocsEnum docsEnum = MultiFields.getTermDocsEnum(reader, liveDocs, "field", term);
+        DocsEnum docsEnum = _TestUtil.docs(random, reader, "field", term, liveDocs, null, false);
         assertNotNull(docsEnum);
 
         for(int docID : docs.get(term)) {
@@ -138,11 +138,12 @@ public class TestMultiFields extends Luc
 
   /*
   private void verify(IndexReader r, String term, List<Integer> expected) throws Exception {
-    DocsEnum docs = MultiFields.getTermDocsEnum(r,
-                                                MultiFields.getLiveDocs(r),
-                                                "field",
-                                                new BytesRef(term));
-
+    DocsEnum docs = _TestUtil.docs(random, r,
+                                   "field",
+                                   new BytesRef(term),
+                                   MultiFields.getLiveDocs(r),
+                                   null,
+                                   false);
     for(int docID : expected) {
       assertEquals(docID, docs.nextDoc());
     }
@@ -160,8 +161,8 @@ public class TestMultiFields extends Luc
     w.addDocument(d);
     IndexReader r = w.getReader();
     w.close();
-    DocsEnum d1 = MultiFields.getTermDocsEnum(r, null, "f", new BytesRef("j"));
-    DocsEnum d2 = MultiFields.getTermDocsEnum(r, null, "f", new BytesRef("j"));
+    DocsEnum d1 = _TestUtil.docs(random, r, "f", new BytesRef("j"), null, null, false);
+    DocsEnum d2 = _TestUtil.docs(random, r, "f", new BytesRef("j"), null, null, false);
     assertEquals(0, d1.nextDoc());
     assertEquals(0, d2.nextDoc());
     r.close();

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java Sun Dec  4 19:18:17 2011
@@ -28,6 +28,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 /**
  * 
@@ -52,7 +53,7 @@ public class TestOmitPositions extends L
     
     assertNull(MultiFields.getTermPositionsEnum(reader, null, "foo", new BytesRef("test")));
     
-    DocsEnum de = MultiFields.getTermDocsEnum(reader, null, "foo", new BytesRef("test"));
+    DocsEnum de = _TestUtil.docs(random, reader, "foo", new BytesRef("test"), null, null, true);
     while (de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
       assertEquals(2, de.freq());
     }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java Sun Dec  4 19:18:17 2011
@@ -19,12 +19,13 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 
-import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestParallelTermEnum extends LuceneTestCase {
     private IndexReader ir1;
@@ -88,31 +89,31 @@ public class TestParallelTermEnum extend
         TermsEnum te = terms.iterator(null);
 
         assertEquals("brown", te.next().utf8ToString());
-        DocsEnum td = te.docs(liveDocs, null);
+        DocsEnum td = _TestUtil.docs(random, te, liveDocs, null, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("fox", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("jumps", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("quick", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("the", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
@@ -125,31 +126,31 @@ public class TestParallelTermEnum extend
         te = terms.iterator(null);
 
         assertEquals("brown", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("fox", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("jumps", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("quick", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("the", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
@@ -162,37 +163,37 @@ public class TestParallelTermEnum extend
         te = terms.iterator(null);
 
         assertEquals("dog", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("fox", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("jumps", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("lazy", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("over", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);
 
         assertEquals("the", te.next().utf8ToString());
-        td = te.docs(liveDocs, td);
+        td = _TestUtil.docs(random, te, liveDocs, td, false);
         assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
         assertEquals(0, td.docID());
         assertEquals(td.nextDoc(), DocsEnum.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java Sun Dec  4 19:18:17 2011
@@ -20,8 +20,8 @@ package org.apache.lucene.index;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Random;
 import java.util.Map;
+import java.util.Random;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.store.Directory;
@@ -31,6 +31,7 @@ import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestPerSegmentDeletes extends LuceneTestCase {
   public void testDeletes1() throws Exception {
@@ -224,7 +225,7 @@ public class TestPerSegmentDeletes exten
     Terms cterms = fields.terms(term.field);
     TermsEnum ctermsEnum = cterms.iterator(null);
     if (ctermsEnum.seekExact(new BytesRef(term.text()), false)) {
-      DocsEnum docsEnum = ctermsEnum.docs(bits, null);
+      DocsEnum docsEnum = _TestUtil.docs(random, ctermsEnum, bits, null, false);
       return toArray(docsEnum);
     }
     return null;

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java Sun Dec  4 19:18:17 2011
@@ -17,18 +17,19 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.InfoStream;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.Directory;
+import java.io.IOException;
+import java.util.Collection;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-
-import java.io.IOException;
-import java.util.Collection;
+import org.apache.lucene.util.InfoStream;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestSegmentMerger extends LuceneTestCase {
   //The variables for the new merged segment
@@ -98,10 +99,12 @@ public class TestSegmentMerger extends L
     assertTrue(newDoc2 != null);
     assertTrue(DocHelper.numFields(newDoc2) == DocHelper.numFields(doc2) - DocHelper.unstored.size());
 
-    DocsEnum termDocs = MultiFields.getTermDocsEnum(mergedReader,
-                                                    MultiFields.getLiveDocs(mergedReader),
-                                                    DocHelper.TEXT_FIELD_2_KEY,
-                                                    new BytesRef("field"));
+    DocsEnum termDocs = _TestUtil.docs(random, mergedReader,
+                                       DocHelper.TEXT_FIELD_2_KEY,
+                                       new BytesRef("field"),
+                                       MultiFields.getLiveDocs(mergedReader),
+                                       null,
+                                       false);
     assertTrue(termDocs != null);
     assertTrue(termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java Sun Dec  4 19:18:17 2011
@@ -22,12 +22,12 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.BytesRef;
-
 import org.apache.lucene.document.Document;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestSegmentReader extends LuceneTestCase {
   private Directory dir;
@@ -132,16 +132,20 @@ public class TestSegmentReader extends L
       }
     }
     
-    DocsEnum termDocs = MultiFields.getTermDocsEnum(reader,
-                                                    MultiFields.getLiveDocs(reader),
-                                                    DocHelper.TEXT_FIELD_1_KEY,
-                                                    new BytesRef("field"));
+    DocsEnum termDocs = _TestUtil.docs(random, reader,
+                                       DocHelper.TEXT_FIELD_1_KEY,
+                                       new BytesRef("field"),
+                                       MultiFields.getLiveDocs(reader),
+                                       null,
+                                       false);
     assertTrue(termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
 
-    termDocs = MultiFields.getTermDocsEnum(reader,
-                                           MultiFields.getLiveDocs(reader),
-                                           DocHelper.NO_NORMS_KEY,
-                                           new BytesRef(DocHelper.NO_NORMS_TEXT));
+    termDocs = _TestUtil.docs(random, reader,
+                              DocHelper.NO_NORMS_KEY,
+                              new BytesRef(DocHelper.NO_NORMS_TEXT),
+                              MultiFields.getLiveDocs(reader),
+                              null,
+                              false);
 
     assertTrue(termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java Sun Dec  4 19:18:17 2011
@@ -17,14 +17,15 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.Directory;
+import java.io.IOException;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-
-import java.io.IOException;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestSegmentTermDocs extends LuceneTestCase {
   private Document testDoc = new Document();
@@ -61,7 +62,7 @@ public class TestSegmentTermDocs extends
 
     TermsEnum terms = reader.fields().terms(DocHelper.TEXT_FIELD_2_KEY).iterator(null);
     terms.seekCeil(new BytesRef("field"));
-    DocsEnum termDocs = terms.docs(reader.getLiveDocs(), null);
+    DocsEnum termDocs = _TestUtil.docs(random, terms, reader.getLiveDocs(), null, true);
     if (termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS)    {
       int docId = termDocs.docID();
       assertTrue(docId == 0);
@@ -80,9 +81,12 @@ public class TestSegmentTermDocs extends
       //After adding the document, we should be able to read it back in
       SegmentReader reader = SegmentReader.get(true, info, indexDivisor, newIOContext(random));
       assertTrue(reader != null);
-      DocsEnum termDocs = reader.termDocsEnum(reader.getLiveDocs(),
-                                              "textField2",
-                                              new BytesRef("bad"));
+      DocsEnum termDocs = _TestUtil.docs(random, reader,
+                                         "textField2",
+                                         new BytesRef("bad"),
+                                         reader.getLiveDocs(),
+                                         null,
+                                         false);
 
       assertNull(termDocs);
       reader.close();
@@ -91,9 +95,12 @@ public class TestSegmentTermDocs extends
       //After adding the document, we should be able to read it back in
       SegmentReader reader = SegmentReader.get(true, info, indexDivisor, newIOContext(random));
       assertTrue(reader != null);
-      DocsEnum termDocs = reader.termDocsEnum(reader.getLiveDocs(),
-                                              "junk",
-                                              new BytesRef("bad"));
+      DocsEnum termDocs = _TestUtil.docs(random, reader,
+                                         "junk",
+                                         new BytesRef("bad"),
+                                         reader.getLiveDocs(),
+                                         null,
+                                         false);
       assertNull(termDocs);
       reader.close();
     }
@@ -125,10 +132,12 @@ public class TestSegmentTermDocs extends
     
     IndexReader reader = IndexReader.open(dir, null, true, indexDivisor);
 
-    DocsEnum tdocs = MultiFields.getTermDocsEnum(reader,
-                                                 MultiFields.getLiveDocs(reader),
-                                                 ta.field(),
-                                                 new BytesRef(ta.text()));
+    DocsEnum tdocs = _TestUtil.docs(random, reader,
+                                    ta.field(),
+                                    new BytesRef(ta.text()),
+                                    MultiFields.getLiveDocs(reader),
+                                    null,
+                                    true);
     
     // without optimization (assumption skipInterval == 16)
     
@@ -148,10 +157,12 @@ public class TestSegmentTermDocs extends
     assertFalse(tdocs.advance(10) != DocsEnum.NO_MORE_DOCS);
     
     // without next
-    tdocs = MultiFields.getTermDocsEnum(reader,
-                                        MultiFields.getLiveDocs(reader),
-                                        ta.field(),
-                                        new BytesRef(ta.text()));
+    tdocs = _TestUtil.docs(random, reader,
+                           ta.field(),
+                           new BytesRef(ta.text()),
+                           MultiFields.getLiveDocs(reader),
+                           null,
+                           false);
     
     assertTrue(tdocs.advance(0) != DocsEnum.NO_MORE_DOCS);
     assertEquals(0, tdocs.docID());
@@ -164,10 +175,12 @@ public class TestSegmentTermDocs extends
     // exactly skipInterval documents and therefore with optimization
     
     // with next
-    tdocs = MultiFields.getTermDocsEnum(reader,
-                                        MultiFields.getLiveDocs(reader),
-                                        tb.field(),
-                                        new BytesRef(tb.text()));
+    tdocs = _TestUtil.docs(random, reader,
+                           tb.field(),
+                           new BytesRef(tb.text()),
+                           MultiFields.getLiveDocs(reader),
+                           null,
+                           true);
 
     assertTrue(tdocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
     assertEquals(10, tdocs.docID());
@@ -186,10 +199,12 @@ public class TestSegmentTermDocs extends
     assertFalse(tdocs.advance(26) != DocsEnum.NO_MORE_DOCS);
     
     // without next
-    tdocs = MultiFields.getTermDocsEnum(reader,
-                                        MultiFields.getLiveDocs(reader),
-                                        tb.field(),
-                                        new BytesRef(tb.text()));
+    tdocs = _TestUtil.docs(random, reader,
+                           tb.field(),
+                           new BytesRef(tb.text()),
+                           MultiFields.getLiveDocs(reader),
+                           null,
+                           true);
     
     assertTrue(tdocs.advance(5) != DocsEnum.NO_MORE_DOCS);
     assertEquals(10, tdocs.docID());
@@ -204,10 +219,12 @@ public class TestSegmentTermDocs extends
     // much more than skipInterval documents and therefore with optimization
     
     // with next
-    tdocs = MultiFields.getTermDocsEnum(reader,
-                                        MultiFields.getLiveDocs(reader),
-                                        tc.field(),
-                                        new BytesRef(tc.text()));
+    tdocs = _TestUtil.docs(random, reader,
+                           tc.field(),
+                           new BytesRef(tc.text()),
+                           MultiFields.getLiveDocs(reader),
+                           null,
+                           true);
 
     assertTrue(tdocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
     assertEquals(26, tdocs.docID());
@@ -228,10 +245,12 @@ public class TestSegmentTermDocs extends
     assertFalse(tdocs.advance(76) != DocsEnum.NO_MORE_DOCS);
     
     //without next
-    tdocs = MultiFields.getTermDocsEnum(reader,
-                                        MultiFields.getLiveDocs(reader),
-                                        tc.field(),
-                                        new BytesRef(tc.text()));
+    tdocs = _TestUtil.docs(random, reader,
+                           tc.field(),
+                           new BytesRef(tc.text()),
+                           MultiFields.getLiveDocs(reader),
+                           null,
+                           false);
     assertTrue(tdocs.advance(5) != DocsEnum.NO_MORE_DOCS);
     assertEquals(26, tdocs.docID());
     assertTrue(tdocs.advance(40) != DocsEnum.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java Sun Dec  4 19:18:17 2011
@@ -75,11 +75,11 @@ public class TestStressAdvance extends L
           System.out.println("\nTEST: iter=" + iter + " iter2=" + iter2);
         }
         assertEquals(TermsEnum.SeekStatus.FOUND, te.seekCeil(new BytesRef("a")));
-        de = te.docs(null, de);
+        de = _TestUtil.docs(random, te, null, de, false);
         testOne(de, aDocIDs);
 
         assertEquals(TermsEnum.SeekStatus.FOUND, te.seekCeil(new BytesRef("b")));
-        de = te.docs(null, de);
+        de = _TestUtil.docs(random, te, null, de, false);
         testOne(de, bDocIDs);
       }
 

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java Sun Dec  4 19:18:17 2011
@@ -334,7 +334,7 @@ public class TestStressIndexing2 extends
       // deleted docs):
       DocsEnum docs = null;
       while(termsEnum.next() != null) {
-        docs = termsEnum.docs(liveDocs1, docs);
+        docs = _TestUtil.docs(random, termsEnum, null, docs, false);
         while(docs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
           fail("r1 is not empty but r2 is");
         }
@@ -354,9 +354,9 @@ public class TestStressIndexing2 extends
         break;
       }
 
-      termDocs1 = termsEnum.docs(liveDocs1, termDocs1);
+      termDocs1 = _TestUtil.docs(random, termsEnum, liveDocs1, termDocs1, false);
       if (termsEnum2.seekExact(term, false)) {
-        termDocs2 = termsEnum2.docs(liveDocs2, termDocs2);
+        termDocs2 = _TestUtil.docs(random, termsEnum2, liveDocs2, termDocs2, false);
       } else {
         termDocs2 = null;
       }
@@ -415,7 +415,7 @@ public class TestStressIndexing2 extends
                   System.out.println("          pos=" + dpEnum.nextPosition());
                 }
               } else {
-                dEnum = termsEnum3.docs(null, dEnum);
+                dEnum = _TestUtil.docs(random, termsEnum3, null, dEnum, true);
                 assertNotNull(dEnum);
                 assertTrue(dEnum.nextDoc() != DocsEnum.NO_MORE_DOCS);
                 final int freq = dEnum.freq();
@@ -449,7 +449,7 @@ public class TestStressIndexing2 extends
                   System.out.println("          pos=" + dpEnum.nextPosition());
                 }
               } else {
-                dEnum = termsEnum3.docs(null, dEnum);
+                dEnum = _TestUtil.docs(random, termsEnum3, null, dEnum, true);
                 assertNotNull(dEnum);
                 assertTrue(dEnum.nextDoc() != DocsEnum.NO_MORE_DOCS);
                 final int freq = dEnum.freq();
@@ -506,7 +506,7 @@ public class TestStressIndexing2 extends
         }
         
         //System.out.println("TEST: term1=" + term1);
-        docs1 = termsEnum1.docs(liveDocs1, docs1);
+        docs1 = _TestUtil.docs(random, termsEnum1, liveDocs1, docs1, true);
         while (docs1.nextDoc() != DocsEnum.NO_MORE_DOCS) {
           int d = docs1.docID();
           int f = docs1.freq();
@@ -540,7 +540,7 @@ public class TestStressIndexing2 extends
         }
         
         //System.out.println("TEST: term1=" + term1);
-        docs2 = termsEnum2.docs(liveDocs2, docs2);
+        docs2 = _TestUtil.docs(random, termsEnum2, liveDocs2, docs2, true);
         while (docs2.nextDoc() != DocsEnum.NO_MORE_DOCS) {
           int d = r2r1[docs2.docID()];
           int f = docs2.freq();
@@ -667,8 +667,8 @@ public class TestStressIndexing2 extends
           assertEquals(DocsEnum.NO_MORE_DOCS, dpEnum1.nextDoc());
           assertEquals(DocsEnum.NO_MORE_DOCS, dpEnum2.nextDoc());
         } else {
-          dEnum1 = termsEnum1.docs(null, dEnum1);
-          dEnum2 = termsEnum2.docs(null, dEnum2);
+          dEnum1 = _TestUtil.docs(random, termsEnum1, null, dEnum1, true);
+          dEnum2 = _TestUtil.docs(random, termsEnum2, null, dEnum2, true);
           assertNotNull(dEnum1);
           assertNotNull(dEnum2);
           int docID1 = dEnum1.nextDoc();

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java Sun Dec  4 19:18:17 2011
@@ -24,9 +24,9 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.lucene.analysis.*;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
@@ -37,6 +37,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestTermVectorsReader extends LuceneTestCase {
   //Must be lexicographically sorted, will do in setup, versus trying to maintain here
@@ -231,7 +232,7 @@ public class TestTermVectorsReader exten
         //System.out.println("Term: " + term);
         assertEquals(testTerms[i], term);
         
-        docsEnum = termsEnum.docs(null, docsEnum);
+        docsEnum = _TestUtil.docs(random, termsEnum, null, docsEnum, false);
         assertNotNull(docsEnum);
         int doc = docsEnum.docID();
         assertTrue(doc == -1 || doc == DocIdSetIterator.NO_MORE_DOCS);

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java Sun Dec  4 19:18:17 2011
@@ -28,8 +28,9 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 class RepeatingTokenStream extends Tokenizer {
   
@@ -121,7 +122,7 @@ public class TestTermdocPerf extends Luc
     DocsEnum tdocs = null;
     for (int i=0; i<iter; i++) {
       tenum.seekCeil(new BytesRef("val"));
-      tdocs = tenum.docs(MultiFields.getLiveDocs(reader), tdocs);
+      tdocs = _TestUtil.docs(random, tenum, MultiFields.getLiveDocs(reader), tdocs, false);
       while (tdocs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
         ret += tdocs.docID();
       }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermsEnum.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermsEnum.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/TestTermsEnum.java Sun Dec  4 19:18:17 2011
@@ -331,7 +331,7 @@ public class TestTermsEnum extends Lucen
           }
           assertEquals(expected, actual);
           assertEquals(1, te.docFreq());
-          docsEnum = te.docs(null, docsEnum);
+          docsEnum = _TestUtil.docs(random, te, null, docsEnum, false);
           final int docID = docsEnum.nextDoc();
           assertTrue(docID != DocsEnum.NO_MORE_DOCS);
           assertEquals(docIDToID[docID], termToID.get(expected).intValue());

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java Sun Dec  4 19:18:17 2011
@@ -85,7 +85,7 @@ public class Test10KPulsings extends Luc
     for (int i = 0; i < 10050; i++) {
       String expected = df.format(i);
       assertEquals(expected, te.next().utf8ToString());
-      de = te.docs(null, de);
+      de = _TestUtil.docs(random, te, null, de, false);
       assertTrue(de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
       assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.nextDoc());
     }
@@ -143,7 +143,7 @@ public class Test10KPulsings extends Luc
     for (int i = 0; i < 10050; i++) {
       String expected = df.format(i);
       assertEquals(expected, te.next().utf8ToString());
-      de = te.docs(null, de);
+      de = _TestUtil.docs(random, te, null, de, false);
       assertTrue(de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
       assertEquals(DocIdSetIterator.NO_MORE_DOCS, de.nextDoc());
     }

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java Sun Dec  4 19:18:17 2011
@@ -59,7 +59,7 @@ public class TestPulsingReuse extends Lu
     Map<DocsEnum,Boolean> allEnums = new IdentityHashMap<DocsEnum,Boolean>();
     TermsEnum te = segment.terms("foo").iterator(null);
     while (te.next() != null) {
-      reuse = te.docs(null, reuse);
+      reuse = te.docs(null, reuse, false);
       allEnums.put(reuse, true);
     }
     
@@ -101,7 +101,7 @@ public class TestPulsingReuse extends Lu
     Map<DocsEnum,Boolean> allEnums = new IdentityHashMap<DocsEnum,Boolean>();
     TermsEnum te = segment.terms("foo").iterator(null);
     while (te.next() != null) {
-      reuse = te.docs(null, reuse);
+      reuse = te.docs(null, reuse, false);
       allEnums.put(reuse, true);
     }
     

Modified: lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Sun Dec  4 19:18:17 2011
@@ -35,6 +35,7 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.English;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestTermVectors extends LuceneTestCase {
   private IndexSearcher searcher;
@@ -269,7 +270,7 @@ public class TestTermVectors extends Luc
 
       while (termsEnum.next() != null) {
         String text = termsEnum.term().utf8ToString();
-        docs = termsEnum.docs(MultiFields.getLiveDocs(knownSearcher.reader), docs);
+        docs = _TestUtil.docs(random, termsEnum, MultiFields.getLiveDocs(knownSearcher.reader), docs, true);
         
         while (docs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
           int docId = docs.docID();

Modified: lucene/dev/branches/lucene3606/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java?rev=1210184&r1=1210183&r2=1210184&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java (original)
+++ lucene/dev/branches/lucene3606/modules/analysis/common/src/test/org/apache/lucene/analysis/core/TestKeywordAnalyzer.java Sun Dec  4 19:18:17 2011
@@ -26,15 +26,16 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util._TestUtil;
 
 public class TestKeywordAnalyzer extends BaseTokenStreamTestCase {
   
@@ -95,15 +96,21 @@ public class TestKeywordAnalyzer extends
     writer.close();
 
     IndexReader reader = IndexReader.open(dir, true);
-    DocsEnum td = MultiFields.getTermDocsEnum(reader,
-                                              MultiFields.getLiveDocs(reader),
-                                              "partnum",
-                                              new BytesRef("Q36"));
+    DocsEnum td = _TestUtil.docs(random,
+                                 reader,
+                                 "partnum",
+                                 new BytesRef("Q36"),
+                                 MultiFields.getLiveDocs(reader),
+                                 null,
+                                 false);
     assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
-    td = MultiFields.getTermDocsEnum(reader,
-                                     MultiFields.getLiveDocs(reader),
-                                     "partnum",
-                                     new BytesRef("Q37"));
+    td = _TestUtil.docs(random,
+                        reader,
+                        "partnum",
+                        new BytesRef("Q37"),
+                        MultiFields.getLiveDocs(reader),
+                        null,
+                        false);
     assertTrue(td.nextDoc() != DocsEnum.NO_MORE_DOCS);
   }
 



Mime
View raw message