lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1058390 [8/16] - in /lucene/dev/branches/bulkpostings: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/ dev-tools/idea/.idea/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/ dev-tools/idea/lucene/contrib/ dev-tools/idea/lucene/contr...
Date Thu, 13 Jan 2011 02:09:56 GMT
Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/CheckHits.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/CheckHits.java Thu Jan 13 02:09:33 2011
@@ -42,7 +42,7 @@ public class CheckHits {
    * (ie: Explanation value of 0.0f)
    */
   public static void checkNoMatchExplanations(Query q, String defaultFieldName,
-                                              Searcher searcher, int[] results)
+                                              IndexSearcher searcher, int[] results)
     throws IOException {
 
     String d = q.toString(defaultFieldName);
@@ -81,7 +81,7 @@ public class CheckHits {
    * @see #checkHits
    */
   public static void checkHitCollector(Random random, Query query, String defaultFieldName,
-                                       Searcher searcher, int[] results)
+                                       IndexSearcher searcher, int[] results)
     throws IOException {
 
     QueryUtils.check(random,query,searcher);
@@ -99,18 +99,8 @@ public class CheckHits {
 
     for (int i = -1; i < 2; i++) {
       actual.clear();
-      QueryUtils.wrapSearcher(random, searcher, i).search(query, c);
-      Assert.assertEquals("Wrap Searcher " + i + ": " +
-                          query.toString(defaultFieldName),
-                          correct, actual);
-    }
-                        
-    if ( ! ( searcher instanceof IndexSearcher ) ) return;
-
-    for (int i = -1; i < 2; i++) {
-      actual.clear();
       QueryUtils.wrapUnderlyingReader
-        (random, (IndexSearcher)searcher, i).search(query, c);
+        (random, searcher, i).search(query, c);
       Assert.assertEquals("Wrap Reader " + i + ": " +
                           query.toString(defaultFieldName),
                           correct, actual);
@@ -157,7 +147,7 @@ public class CheckHits {
         Random random,
         Query query,
         String defaultFieldName,
-        Searcher searcher,
+        IndexSearcher searcher,
         int[] results)
           throws IOException {
 
@@ -284,7 +274,7 @@ public class CheckHits {
    */
   public static void checkExplanations(Query query,
                                        String defaultFieldName,
-                                       Searcher searcher) throws IOException {
+                                       IndexSearcher searcher) throws IOException {
     checkExplanations(query, defaultFieldName, searcher, false);
   }
 
@@ -301,7 +291,7 @@ public class CheckHits {
    */
   public static void checkExplanations(Query query,
                                        String defaultFieldName,
-                                       Searcher searcher, 
+                                       IndexSearcher searcher, 
                                        boolean deep) throws IOException {
 
     searcher.search(query,
@@ -455,7 +445,7 @@ public class CheckHits {
   public static class ExplanationAsserter extends Collector {
 
     Query q;
-    Searcher s;
+    IndexSearcher s;
     String d;
     boolean deep;
     
@@ -463,10 +453,10 @@ public class CheckHits {
     private int base = 0;
 
     /** Constructs an instance which does shallow tests on the Explanation */
-    public ExplanationAsserter(Query q, String defaultFieldName, Searcher s) {
+    public ExplanationAsserter(Query q, String defaultFieldName, IndexSearcher s) {
       this(q,defaultFieldName,s,false);
     }      
-    public ExplanationAsserter(Query q, String defaultFieldName, Searcher s, boolean deep) {
+    public ExplanationAsserter(Query q, String defaultFieldName, IndexSearcher s, boolean deep) {
       this.q=q;
       this.s=s;
       this.d = q.toString(defaultFieldName);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java Thu Jan 13 02:09:33 2011
@@ -19,12 +19,10 @@ package org.apache.lucene.search;
 
 import java.io.IOException;
 
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.FieldSelector;
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.util.PriorityQueue;
 
 /**
@@ -38,116 +36,6 @@ final class JustCompileSearch {
 
   private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
 
-  static final class JustCompileSearcher extends Searcher {
-
-    @Override
-    protected Weight createWeight(Query query) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-    @Override
-    public void close() throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Document doc(int i) throws CorruptIndexException, IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public int[] docFreqs(Term[] terms) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Explanation explain(Query query, int doc) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Similarity getSimilarity() {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public void search(Query query, Collector results) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public void search(Query query, Filter filter, Collector results)
-        throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public TopDocs search(Query query, Filter filter, int n) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-    @Override
-    public TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
-        throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-    @Override
-    public TopDocs search(Query query, int n) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-    @Override
-    public void setSimilarity(Similarity similarity) {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-    @Override
-    public int docFreq(Term term) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Explanation explain(Weight weight, int doc) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public int maxDoc() throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Query rewrite(Query query) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public void search(Weight weight, Filter filter, Collector results)
-        throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public TopDocs search(Weight weight, Filter filter, int n)
-        throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
-        throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
-    @Override
-    public Document doc(int n, FieldSelector fieldSelector)
-        throws CorruptIndexException, IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-    
-  }
-  
   static final class JustCompileCollector extends Collector {
 
     @Override
@@ -266,7 +154,7 @@ final class JustCompileSearch {
     // still added here in case someone will add abstract methods in the future.
     
     @Override
-    public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+    public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {
       return null;
     }
   }
@@ -327,7 +215,7 @@ final class JustCompileSearch {
     }
 
     @Override
-    protected boolean score(Collector collector, int max, int firstDocID)
+    public boolean score(Collector collector, int max, int firstDocID)
         throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
@@ -366,7 +254,7 @@ final class JustCompileSearch {
     }
 
     @Override
-    public float lengthNorm(String fieldName, int numTokens) {
+    public float computeNorm(String fieldName, FieldInvertState state) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 
@@ -395,7 +283,7 @@ final class JustCompileSearch {
     }
     
     @Override
-    public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+    public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {
       return null;
     }    
   }
@@ -447,7 +335,7 @@ final class JustCompileSearch {
   static final class JustCompileWeight extends Weight {
 
     @Override
-    public Explanation explain(IndexReader reader, int doc) throws IOException {
+    public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 
@@ -472,7 +360,7 @@ final class JustCompileSearch {
     }
 
     @Override
-    public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
+    public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer)
         throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/MockFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/MockFilter.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/MockFilter.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/MockFilter.java Thu Jan 13 02:09:33 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.util.DocIdBitSet;
 import java.util.BitSet;
 
@@ -25,7 +25,7 @@ public class MockFilter extends Filter {
   private boolean wasCalled;
 
   @Override
-  public DocIdSet getDocIdSet(IndexReader reader) {
+  public DocIdSet getDocIdSet(AtomicReaderContext context) {
     wasCalled = true;
     return new DocIdBitSet(new BitSet());
   }

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/QueryUtils.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/QueryUtils.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/QueryUtils.java Thu Jan 13 02:09:33 2011
@@ -12,12 +12,14 @@ import junit.framework.Assert;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.MultiReader;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.ReaderUtil;
 
 import static org.apache.lucene.util.LuceneTestCase.TEST_VERSION_CURRENT;
 
@@ -85,7 +87,7 @@ public class QueryUtils {
   }
   
   /** deep check that explanations of a query 'score' correctly */
-  public static void checkExplanations (final Query q, final Searcher s) throws IOException {
+  public static void checkExplanations (final Query q, final IndexSearcher s) throws IOException {
     CheckHits.checkExplanations(q, null, s, true);
   }
   
@@ -100,27 +102,19 @@ public class QueryUtils {
    * @see #checkSerialization
    * @see #checkEqual
    */
-  public static void check(Random random, Query q1, Searcher s) {
+  public static void check(Random random, Query q1, IndexSearcher s) {
     check(random, q1, s, true);
   }
-  private static void check(Random random, Query q1, Searcher s, boolean wrap) {
+  private static void check(Random random, Query q1, IndexSearcher s, boolean wrap) {
     try {
       check(q1);
       if (s!=null) {
-        if (s instanceof IndexSearcher) {
-          IndexSearcher is = (IndexSearcher)s;
-          checkFirstSkipTo(q1,is);
-          checkSkipTo(q1,is);
-          if (wrap) {
-            check(random, q1, wrapUnderlyingReader(random, is, -1), false);
-            check(random, q1, wrapUnderlyingReader(random, is,  0), false);
-            check(random, q1, wrapUnderlyingReader(random, is, +1), false);
-          }
-        }
+        checkFirstSkipTo(q1,s);
+        checkSkipTo(q1,s);
         if (wrap) {
-          check(random,q1, wrapSearcher(random, s, -1), false);
-          check(random,q1, wrapSearcher(random, s,  0), false);
-          check(random,q1, wrapSearcher(random, s, +1), false);
+          check(random, q1, wrapUnderlyingReader(random, s, -1), false);
+          check(random, q1, wrapUnderlyingReader(random, s,  0), false);
+          check(random, q1, wrapUnderlyingReader(random, s, +1), false);
         }
         checkExplanations(q1,s);
         checkSerialization(q1,s);
@@ -166,39 +160,6 @@ public class QueryUtils {
     out.setSimilarity(s.getSimilarity());
     return out;
   }
-  /**
-   * Given a Searcher, returns a new MultiSearcher wrapping the  
-   * the original Searcher, 
-   * as well as several "empty" IndexSearchers -- some of which will have
-   * deleted documents in them.  This new MultiSearcher 
-   * should behave exactly the same as the original Searcher.
-   * @param s the Searcher to wrap
-   * @param edge if negative, s will be the first sub; if 0, s will be in hte middle, if positive s will be the last sub
-   */
-  public static MultiSearcher wrapSearcher(Random random, final Searcher s, final int edge) 
-    throws IOException {
-
-    // we can't put deleted docs before the nested reader, because
-    // it will through off the docIds
-    Searcher[] searchers = new Searcher[] {
-      edge < 0 ? s : new IndexSearcher(makeEmptyIndex(random, 0), true),
-      new MultiSearcher(new Searcher[] {
-        new IndexSearcher(makeEmptyIndex(random, edge < 0 ? 65 : 0), true),
-        new IndexSearcher(makeEmptyIndex(random, 0), true),
-        0 == edge ? s : new IndexSearcher(makeEmptyIndex(random, 0), true)
-      }),
-      new IndexSearcher(makeEmptyIndex(random, 0 < edge ? 0 : 3), true),
-      new IndexSearcher(makeEmptyIndex(random, 0), true),
-      new MultiSearcher(new Searcher[] {
-        new IndexSearcher(makeEmptyIndex(random, 0 < edge ? 0 : 5), true),
-        new IndexSearcher(makeEmptyIndex(random, 0), true),
-        0 < edge ? s : new IndexSearcher(makeEmptyIndex(random, 0), true)
-      })
-    };
-    MultiSearcher out = new MultiSearcher(searchers);
-    out.setSimilarity(s.getSimilarity());
-    return out;
-  }
 
   private static Directory makeEmptyIndex(Random random, final int numDeletedDocs) 
     throws IOException {
@@ -231,7 +192,7 @@ public class QueryUtils {
   /** check that the query weight is serializable. 
    * @throws IOException if serialization check fail. 
    */
-  private static void checkSerialization(Query q, Searcher s) throws IOException {
+  private static void checkSerialization(Query q, IndexSearcher s) throws IOException {
     Weight w = q.weight(s);
     try {
       ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -251,6 +212,7 @@ public class QueryUtils {
       throw e2;
     }
   }
+  
 
 
   /** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
@@ -258,7 +220,7 @@ public class QueryUtils {
    */
   public static void checkSkipTo(final Query q, final IndexSearcher s) throws IOException {
     //System.out.println("Checking "+q);
-    
+    final AtomicReaderContext[] context = ReaderUtil.leaves(s.getTopReaderContext());
     if (q.weight(s).scoresDocsOutOfOrder()) return;  // in this case order of skipTo() might differ from that of next().
 
     final int skip_op = 0;
@@ -288,8 +250,8 @@ public class QueryUtils {
 
         s.search(q, new Collector() {
           private Scorer sc;
-          private IndexReader reader;
           private Scorer scorer;
+          private int leafPtr;
 
           @Override
           public void setScorer(Scorer scorer) throws IOException {
@@ -303,7 +265,7 @@ public class QueryUtils {
             try {
               if (scorer == null) {
                 Weight w = q.weight(s);
-                scorer = w.scorer(reader, true, false);
+                scorer = w.scorer(context[leafPtr], true, false);
               }
               
               int op = order[(opidx[0]++) % order.length];
@@ -346,14 +308,17 @@ public class QueryUtils {
             // previous reader, hits NO_MORE_DOCS
             if (lastReader[0] != null) {
               final IndexReader previousReader = lastReader[0];
-              Weight w = q.weight(new IndexSearcher(previousReader));
-              Scorer scorer = w.scorer(previousReader, true, false);
+              IndexSearcher indexSearcher = new IndexSearcher(previousReader);
+              Weight w = q.weight(indexSearcher);
+              Scorer scorer = w.scorer((AtomicReaderContext)indexSearcher.getTopReaderContext(), true, false);
               if (scorer != null) {
                 boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
                 Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
               }
+              leafPtr++;
             }
-            this.reader = lastReader[0] = reader;
+            lastReader[0] = reader;
+            assert context[leafPtr].reader == reader;
             this.scorer = null;
             lastDoc[0] = -1;
           }
@@ -368,8 +333,9 @@ public class QueryUtils {
           // confirm that skipping beyond the last doc, on the
           // previous reader, hits NO_MORE_DOCS
           final IndexReader previousReader = lastReader[0];
-          Weight w = q.weight(new IndexSearcher(previousReader));
-          Scorer scorer = w.scorer(previousReader, true, false);
+          IndexSearcher indexSearcher = new IndexSearcher(previousReader);
+          Weight w = q.weight(indexSearcher);
+          Scorer scorer = w.scorer((AtomicReaderContext)previousReader.getTopReaderContext() , true, false);
           if (scorer != null) {
             boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
             Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
@@ -384,10 +350,10 @@ public class QueryUtils {
     final float maxDiff = 1e-3f;
     final int lastDoc[] = {-1};
     final IndexReader lastReader[] = {null};
-
+    final AtomicReaderContext[] context = ReaderUtil.leaves(s.getTopReaderContext());
     s.search(q,new Collector() {
       private Scorer scorer;
-      private IndexReader reader;
+      private int leafPtr;
       @Override
       public void setScorer(Scorer scorer) throws IOException {
         this.scorer = scorer;
@@ -399,7 +365,7 @@ public class QueryUtils {
           long startMS = System.currentTimeMillis();
           for (int i=lastDoc[0]+1; i<=doc; i++) {
             Weight w = q.weight(s);
-            Scorer scorer = w.scorer(reader, true, false);
+            Scorer scorer = w.scorer(context[leafPtr], true, false);
             Assert.assertTrue("query collected "+doc+" but skipTo("+i+") says no more docs!",scorer.advance(i) != DocIdSetIterator.NO_MORE_DOCS);
             Assert.assertEquals("query collected "+doc+" but skipTo("+i+") got to "+scorer.docID(),doc,scorer.docID());
             float skipToScore = scorer.score();
@@ -424,15 +390,17 @@ public class QueryUtils {
         // previous reader, hits NO_MORE_DOCS
         if (lastReader[0] != null) {
           final IndexReader previousReader = lastReader[0];
-          Weight w = q.weight(new IndexSearcher(previousReader));
-          Scorer scorer = w.scorer(previousReader, true, false);
+          IndexSearcher indexSearcher = new IndexSearcher(previousReader);
+          Weight w = q.weight(indexSearcher);
+          Scorer scorer = w.scorer((AtomicReaderContext)indexSearcher.getTopReaderContext(), true, false);
           if (scorer != null) {
             boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
             Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
           }
+          leafPtr++;
         }
 
-        this.reader = lastReader[0] = reader;
+        lastReader[0] = reader;
         lastDoc[0] = -1;
       }
       @Override
@@ -445,8 +413,9 @@ public class QueryUtils {
       // confirm that skipping beyond the last doc, on the
       // previous reader, hits NO_MORE_DOCS
       final IndexReader previousReader = lastReader[0];
-      Weight w = q.weight(new IndexSearcher(previousReader));
-      Scorer scorer = w.scorer(previousReader, true, false);
+      IndexSearcher indexSearcher = new IndexSearcher(previousReader);
+      Weight w = q.weight(indexSearcher);
+      Scorer scorer = w.scorer((AtomicReaderContext)indexSearcher.getTopReaderContext(), true, false);
       if (scorer != null) {
         boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
         Assert.assertFalse("query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/SingleDocTestFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/SingleDocTestFilter.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/SingleDocTestFilter.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/SingleDocTestFilter.java Thu Jan 13 02:09:33 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.util.DocIdBitSet;
 
 import java.util.BitSet;
@@ -31,8 +31,8 @@ public class SingleDocTestFilter extends
   }
 
   @Override
-  public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
-    BitSet bits = new BitSet(reader.maxDoc());
+  public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {
+    BitSet bits = new BitSet(context.reader.maxDoc());
     bits.set(doc);
     return new DocIdBitSet(bits);
   }

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Thu Jan 13 02:09:33 2011
@@ -372,7 +372,7 @@ public class TestBooleanMinShouldMatch e
 
 
 
-    protected void printHits(String test, ScoreDoc[] h, Searcher searcher) throws Exception {
+    protected void printHits(String test, ScoreDoc[] h, IndexSearcher searcher) throws Exception {
 
         System.err.println("------- " + test + " -------");
 

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java Thu Jan 13 02:09:33 2011
@@ -17,13 +17,21 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.util.NamedThreadFactory;
 
 public class TestBooleanQuery extends LuceneTestCase {
   
@@ -116,5 +124,45 @@ public class TestBooleanQuery extends Lu
     w.close();
     dir.close();
   }
-  
+
+  public void testDeMorgan() throws Exception {
+    Directory dir1 = newDirectory();
+    RandomIndexWriter iw1 = new RandomIndexWriter(random, dir1);
+    Document doc1 = new Document();
+    doc1.add(newField("field", "foo bar", Field.Index.ANALYZED));
+    iw1.addDocument(doc1);
+    IndexReader reader1 = iw1.getReader();
+    iw1.close();
+    
+    Directory dir2 = newDirectory();
+    RandomIndexWriter iw2 = new RandomIndexWriter(random, dir2);
+    Document doc2 = new Document();
+    doc2.add(newField("field", "foo baz", Field.Index.ANALYZED));
+    iw2.addDocument(doc2);
+    IndexReader reader2 = iw2.getReader();
+    iw2.close();
+    
+    QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer());
+    qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
+    
+    MultiReader multireader = new MultiReader(reader1, reader2);
+    IndexSearcher searcher = new IndexSearcher(multireader);
+    assertEquals(0, searcher.search(qp.parse("+foo -ba*"), 10).totalHits);
+    
+    final ExecutorService es = Executors.newCachedThreadPool(new NamedThreadFactory("NRT search threads"));
+    searcher = new IndexSearcher(multireader, es);
+    if (VERBOSE)
+      System.out.println("rewritten form: " + searcher.rewrite(qp.parse("+foo -ba*")));
+    assertEquals(0, searcher.search(qp.parse("+foo -ba*"), 10).totalHits);
+    es.shutdown();
+    es.awaitTermination(1, TimeUnit.SECONDS);
+
+    multireader.close();
+    reader1.close();
+    reader2.close();
+    dir1.close();
+    dir2.close();
+  }
 }
+ 
+

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java Thu Jan 13 02:09:33 2011
@@ -83,7 +83,7 @@ public class TestBooleanScorer extends L
       }
       
     }};
-    BooleanScorer bs = new BooleanScorer(null, sim, 1, Arrays.asList(scorers), null, scorers.length);
+    BooleanScorer bs = new BooleanScorer(null, false, sim, 1, Arrays.asList(scorers), null, scorers.length);
     
     assertEquals("should have received 3000", 3000, bs.nextDoc());
     assertEquals("should have received NO_MORE_DOCS", DocIdSetIterator.NO_MORE_DOCS, bs.nextDoc());

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java Thu Jan 13 02:09:33 2011
@@ -23,6 +23,7 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.SerialMergeScheduler;
 import org.apache.lucene.index.SlowMultiReaderWrapper;
@@ -39,21 +40,21 @@ public class TestCachingWrapperFilter ex
     RandomIndexWriter writer = new RandomIndexWriter(random, dir);
     writer.close();
 
-    IndexReader reader = IndexReader.open(dir, true);
-
+    IndexReader reader = new SlowMultiReaderWrapper(IndexReader.open(dir, true));
+    AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext();
     MockFilter filter = new MockFilter();
     CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
 
     // first time, nested filter is called
-    cacher.getDocIdSet(reader);
+    cacher.getDocIdSet(context);
     assertTrue("first time", filter.wasCalled());
 
     // make sure no exception if cache is holding the wrong docIdSet
-    cacher.getDocIdSet(reader);
+    cacher.getDocIdSet(context);
 
     // second time, nested filter should not be called
     filter.clear();
-    cacher.getDocIdSet(reader);
+    cacher.getDocIdSet(context);
     assertFalse("second time", filter.wasCalled());
 
     reader.close();
@@ -65,18 +66,19 @@ public class TestCachingWrapperFilter ex
     RandomIndexWriter writer = new RandomIndexWriter(random, dir);
     writer.close();
 
-    IndexReader reader = IndexReader.open(dir, true);
+    IndexReader reader = new SlowMultiReaderWrapper(IndexReader.open(dir, true));
+    AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext();
 
     final Filter filter = new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) {
+      public DocIdSet getDocIdSet(AtomicReaderContext context) {
         return null;
       }
     };
     CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
 
     // the caching filter should return the empty set constant
-    assertSame(DocIdSet.EMPTY_DOCIDSET, cacher.getDocIdSet(reader));
+    assertSame(DocIdSet.EMPTY_DOCIDSET, cacher.getDocIdSet(context));
     
     reader.close();
     dir.close();
@@ -87,11 +89,12 @@ public class TestCachingWrapperFilter ex
     RandomIndexWriter writer = new RandomIndexWriter(random, dir);
     writer.close();
 
-    IndexReader reader = IndexReader.open(dir, true);
+    IndexReader reader = new SlowMultiReaderWrapper(IndexReader.open(dir, true));
+    AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext();
 
     final Filter filter = new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) {
+      public DocIdSet getDocIdSet(AtomicReaderContext context) {
         return new DocIdSet() {
           @Override
           public DocIdSetIterator iterator() {
@@ -103,16 +106,18 @@ public class TestCachingWrapperFilter ex
     CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
 
     // the caching filter should return the empty set constant
-    assertSame(DocIdSet.EMPTY_DOCIDSET, cacher.getDocIdSet(reader));
+    assertSame(DocIdSet.EMPTY_DOCIDSET, cacher.getDocIdSet(context));
     
     reader.close();
     dir.close();
   }
   
   private static void assertDocIdSetCacheable(IndexReader reader, Filter filter, boolean shouldCacheable) throws IOException {
+    assertTrue(reader.getTopReaderContext().isAtomic);
+    AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext();
     final CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
-    final DocIdSet originalSet = filter.getDocIdSet(reader);
-    final DocIdSet cachedSet = cacher.getDocIdSet(reader);
+    final DocIdSet originalSet = filter.getDocIdSet(context);
+    final DocIdSet cachedSet = cacher.getDocIdSet(context);
     assertTrue(cachedSet.isCacheable());
     assertEquals(shouldCacheable, originalSet.isCacheable());
     //System.out.println("Original: "+originalSet.getClass().getName()+" -- cached: "+cachedSet.getClass().getName());
@@ -140,7 +145,7 @@ public class TestCachingWrapperFilter ex
     // a openbitset filter is always cacheable
     assertDocIdSetCacheable(reader, new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) {
+      public DocIdSet getDocIdSet(AtomicReaderContext context) {
         return new OpenBitSet();
       }
     }, true);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Thu Jan 13 02:09:33 2011
@@ -89,7 +89,7 @@ public class TestCustomSearcherSort exte
     Sort custSort = new Sort(
         new SortField("publicationDate_", SortField.STRING),
         SortField.FIELD_SCORE);
-    Searcher searcher = new CustomSearcher(reader, 2);
+    IndexSearcher searcher = new CustomSearcher(reader, 2);
     // search and check hits
     matchHits(searcher, custSort);
   }
@@ -103,28 +103,13 @@ public class TestCustomSearcherSort exte
     Sort custSort = new Sort(
         new SortField("publicationDate_", SortField.STRING),
         SortField.FIELD_SCORE);
-    Searcher searcher = new MultiSearcher(new Searcher[] {new CustomSearcher(
-        reader, 2)});
-    // search and check hits
-    matchHits(searcher, custSort);
-  }
-  
-  /**
-   * Run the test using two CustomSearcher instances.
-   */
-  public void testFieldSortMultiCustomSearcher() throws Exception {
-    // log("Run testFieldSortMultiCustomSearcher");
-    // define the sort criteria
-    Sort custSort = new Sort(
-        new SortField("publicationDate_", SortField.STRING),
-        SortField.FIELD_SCORE);
-    Searcher searcher = new MultiSearcher(new CustomSearcher(reader, 0), new CustomSearcher(reader, 2));
+    IndexSearcher searcher = new CustomSearcher(reader, 2);
     // search and check hits
     matchHits(searcher, custSort);
   }
   
   // make sure the documents returned by the search match the expected list
-  private void matchHits(Searcher searcher, Sort sort) throws IOException {
+  private void matchHits(IndexSearcher searcher, Sort sort) throws IOException {
     // make a query without sorting first
     ScoreDoc[] hitsByRank = searcher.search(query, null, Integer.MAX_VALUE).scoreDocs;
     checkHits(hitsByRank, "Sort by rank: "); // check for duplicates

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Thu Jan 13 02:09:33 2011
@@ -22,7 +22,9 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.SlowMultiReaderWrapper;
+import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.store.Directory;
@@ -59,8 +61,9 @@ public class TestDisjunctionMaxQuery ext
     }
     
     @Override
-    public float lengthNorm(String fieldName, int numTerms) {
-      return 1.0f;
+    public float computeNorm(String fieldName, FieldInvertState state) {
+      // Disable length norm
+      return state.getBoost();
     }
     
     @Override
@@ -163,9 +166,9 @@ public class TestDisjunctionMaxQuery ext
     dq.add(tq("dek", "DOES_NOT_EXIST"));
     
     QueryUtils.check(random, dq, s);
-    
+    assertTrue(s.getTopReaderContext().isAtomic);
     final Weight dw = dq.weight(s);
-    final Scorer ds = dw.scorer(s.getIndexReader(), true, false);
+    final Scorer ds = dw.scorer((AtomicReaderContext)s.getTopReaderContext(), true, false);
     final boolean skipOk = ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS;
     if (skipOk) {
       fail("firsttime skipTo found a match? ... "
@@ -177,11 +180,10 @@ public class TestDisjunctionMaxQuery ext
     final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);
     dq.add(tq("dek", "albino"));
     dq.add(tq("dek", "DOES_NOT_EXIST"));
-    
+    assertTrue(s.getTopReaderContext().isAtomic);
     QueryUtils.check(random, dq, s);
-    
     final Weight dw = dq.weight(s);
-    final Scorer ds = dw.scorer(s.getIndexReader(), true, false);
+    final Scorer ds = dw.scorer((AtomicReaderContext)s.getTopReaderContext(), true, false);
     assertTrue("firsttime skipTo found no match",
         ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
     assertEquals("found wrong docid", "d4", r.document(ds.docID()).get("id"));
@@ -473,7 +475,7 @@ public class TestDisjunctionMaxQuery ext
     return q;
   }
   
-  protected void printHits(String test, ScoreDoc[] h, Searcher searcher)
+  protected void printHits(String test, ScoreDoc[] h, IndexSearcher searcher)
       throws Exception {
     
     System.err.println("------- " + test + " -------");

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java Thu Jan 13 02:09:33 2011
@@ -28,6 +28,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field.Index;
 import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -114,7 +115,7 @@ public class TestDocIdSet extends Lucene
     // Now search w/ a Filter which returns a null DocIdSet
     Filter f = new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+      public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {
         return null;
       }
     };

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFieldCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFieldCache.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFieldCache.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFieldCache.java Thu Jan 13 02:09:33 2011
@@ -180,7 +180,14 @@ public class TestFieldCache extends Luce
       assertEquals(val2, val1);
     }
 
-
+    // seek the enum around (note this isn't a great test here)
+    for (int i = 0; i < 100 * RANDOM_MULTIPLIER; i++) {
+      int k = _TestUtil.nextInt(random, 1, nTerms-1);
+      BytesRef val1 = termsIndex.lookup(k, val);
+      assertEquals(TermsEnum.SeekStatus.FOUND, tenum.seek(val1));
+      assertEquals(val1, tenum.term());
+    }
+    
     // test bad field
     termsIndex = cache.getTermsIndex(reader, "bogusfield");
 

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java Thu Jan 13 02:09:33 2011
@@ -20,6 +20,7 @@ package org.apache.lucene.search;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.BooleanClause.Occur;
@@ -87,7 +88,7 @@ public class TestFilteredQuery extends L
   private static Filter newStaticFilterB() {
     return new Filter() {
       @Override
-      public DocIdSet getDocIdSet (IndexReader reader) {
+      public DocIdSet getDocIdSet (AtomicReaderContext context) {
         BitSet bitset = new BitSet(5);
         bitset.set (1);
         bitset.set (3);
@@ -158,7 +159,7 @@ public class TestFilteredQuery extends L
   private static Filter newStaticFilterA() {
     return new Filter() {
       @Override
-      public DocIdSet getDocIdSet (IndexReader reader) {
+      public DocIdSet getDocIdSet (AtomicReaderContext context) {
         BitSet bitset = new BitSet(5);
         bitset.set(0, 5);
         return new DocIdBitSet(bitset);
@@ -216,7 +217,7 @@ public class TestFilteredQuery extends L
     bq.add(new TermQuery(new Term("field", "two")), BooleanClause.Occur.SHOULD);
     ScoreDoc[] hits = searcher.search(query, 1000).scoreDocs;
     assertEquals(1, hits.length);
-    QueryUtils.check(random, query,searcher);    
+    QueryUtils.check(random, query, searcher);    
   }
 }
 

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java Thu Jan 13 02:09:33 2011
@@ -25,6 +25,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -33,6 +34,7 @@ import org.apache.lucene.store.LockObtai
 import org.apache.lucene.util.OpenBitSet;
 
 
+
 /**
  *
  */
@@ -59,7 +61,7 @@ public class TestFilteredSearch extends 
     directory.close();
   }
 
-  public void searchFiltered(IndexWriter writer, Directory directory, SimpleDocIdSetFilter filter, boolean optimize) {
+  public void searchFiltered(IndexWriter writer, Directory directory, Filter filter, boolean optimize) {
     try {
       for (int i = 0; i < 60; i++) {//Simple docs
         Document doc = new Document();
@@ -75,7 +77,6 @@ public class TestFilteredSearch extends 
      
      
       IndexSearcher indexSearcher = new IndexSearcher(directory, true);
-      filter.setTopReader(indexSearcher.getIndexReader());
       ScoreDoc[] hits = indexSearcher.search(booleanQuery, filter, 1000).scoreDocs;
       assertEquals("Number of matched documents", 1, hits.length);
       indexSearcher.close();
@@ -89,20 +90,17 @@ public class TestFilteredSearch extends 
   public static final class SimpleDocIdSetFilter extends Filter {
     private final int[] docs;
     private int index;
-    private IndexReader topReader;
+    
     public SimpleDocIdSetFilter(int[] docs) {
       this.docs = docs;
     }
 
-    public void setTopReader(IndexReader r) {
-      topReader = r;
-    }
-
     @Override
-    public DocIdSet getDocIdSet(IndexReader reader) {
+    public DocIdSet getDocIdSet(AtomicReaderContext context) {
+      assert context.isAtomic;
       final OpenBitSet set = new OpenBitSet();
-      int docBase = topReader.getSubReaderDocBase(reader);
-      final int limit = docBase+reader.maxDoc();
+      int docBase = context.docBase;
+      final int limit = docBase+context.reader.maxDoc();
       for (;index < docs.length; index++) {
         final int docId = docs[index];
         if(docId > limit)

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java Thu Jan 13 02:09:33 2011
@@ -87,8 +87,8 @@ public class TestMultiTermQueryRewrites 
   
   private Query extractInnerQuery(Query q) {
     if (q instanceof ConstantScoreQuery) {
-      // wrapped as ConstantScoreQuery using QueryWrapperFilter
-      q = ((QueryWrapperFilter) ((ConstantScoreQuery) q).getFilter()).getQuery();
+      // wrapped as ConstantScoreQuery
+      q = ((ConstantScoreQuery) q).getQuery();
     }
     return q;
   }

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java Thu Jan 13 02:09:33 2011
@@ -59,7 +59,7 @@ public class TestMultiValuedNumericRange
     IndexReader reader = writer.getReader();
     writer.close();
     
-    Searcher searcher=new IndexSearcher(reader);
+    IndexSearcher searcher=new IndexSearcher(reader);
     num = 50 * RANDOM_MULTIPLIER;
     for (int i = 0; i < num; i++) {
       int lower=random.nextInt(Integer.MAX_VALUE);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNot.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNot.java Thu Jan 13 02:09:33 2011
@@ -44,7 +44,7 @@ public class TestNot extends LuceneTestC
     writer.addDocument(d1);
     IndexReader reader = writer.getReader();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = new IndexSearcher(reader);
       QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer());
     Query query = parser.parse("a NOT b");
     //System.out.println(query);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Thu Jan 13 02:09:33 2011
@@ -22,9 +22,11 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericField;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.SlowMultiReaderWrapper;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.store.Directory;
@@ -32,10 +34,9 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util._TestUtil;
-
-import org.junit.Test;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class TestNumericRangeQuery32 extends LuceneTestCase {
   // distance of entries
@@ -176,14 +177,15 @@ public class TestNumericRangeQuery32 ext
   
   @Test
   public void testInverseRange() throws Exception {
+    AtomicReaderContext context = (AtomicReaderContext) new SlowMultiReaderWrapper(searcher.getIndexReader()).getTopReaderContext();
     NumericRangeFilter<Integer> f = NumericRangeFilter.newIntRange("field8", 8, 1000, -1000, true, true);
-    assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+    assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context));
     f = NumericRangeFilter.newIntRange("field8", 8, Integer.MAX_VALUE, null, false, false);
     assertSame("A exclusive range starting with Integer.MAX_VALUE should return the EMPTY_DOCIDSET instance",
-      DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+               DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context));
     f = NumericRangeFilter.newIntRange("field8", 8, null, Integer.MIN_VALUE, false, false);
     assertSame("A exclusive range ending with Integer.MIN_VALUE should return the EMPTY_DOCIDSET instance",
-      DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+               DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context));
   }
   
   @Test

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Thu Jan 13 02:09:33 2011
@@ -24,15 +24,16 @@ import org.apache.lucene.document.Numeri
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.SlowMultiReaderWrapper;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util._TestUtil;
-
-import org.junit.Test;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class TestNumericRangeQuery64 extends LuceneTestCase {
   // distance of entries
@@ -181,14 +182,16 @@ public class TestNumericRangeQuery64 ext
   
   @Test
   public void testInverseRange() throws Exception {
+    AtomicReaderContext context = (AtomicReaderContext) new SlowMultiReaderWrapper(searcher.getIndexReader()).getTopReaderContext();
     NumericRangeFilter<Long> f = NumericRangeFilter.newLongRange("field8", 8, 1000L, -1000L, true, true);
-    assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+    assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET,
+        f.getDocIdSet(context));
     f = NumericRangeFilter.newLongRange("field8", 8, Long.MAX_VALUE, null, false, false);
     assertSame("A exclusive range starting with Long.MAX_VALUE should return the EMPTY_DOCIDSET instance",
-      DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+               DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context));
     f = NumericRangeFilter.newLongRange("field8", 8, null, Long.MIN_VALUE, false, false);
     assertSame("A exclusive range ending with Long.MIN_VALUE should return the EMPTY_DOCIDSET instance",
-      DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
+               DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context));
   }
   
   @Test

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java Thu Jan 13 02:09:33 2011
@@ -352,7 +352,7 @@ public class TestPhraseQuery extends Luc
     IndexReader reader = writer.getReader();
     writer.close();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = new IndexSearcher(reader);
     PhraseQuery query = new PhraseQuery();
     query.add(new Term("field", "firstname"));
     query.add(new Term("field", "lastname"));

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java Thu Jan 13 02:09:33 2011
@@ -38,7 +38,7 @@ import org.apache.lucene.util._TestUtil;
  * and validates the correct number of hits are returned.
  */
 public class TestRegexpRandom extends LuceneTestCase {
-  private Searcher searcher;
+  private IndexSearcher searcher;
   private IndexReader reader;
   private Directory dir;
   

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java Thu Jan 13 02:09:33 2011
@@ -49,7 +49,7 @@ import org.apache.lucene.util.automaton.
  * Generates random regexps, and validates against a simple impl.
  */
 public class TestRegexpRandom2 extends LuceneTestCase {
-  private IndexSearcher searcher;
+  protected IndexSearcher searcher;
   private IndexReader reader;
   private Directory dir;
   
@@ -146,7 +146,7 @@ public class TestRegexpRandom2 extends L
   /** check that the # of hits is the same as from a very
    * simple regexpquery implementation.
    */
-  private void assertSame(String regexp) throws IOException {   
+  protected void assertSame(String regexp) throws IOException {   
     RegexpQuery smart = new RegexpQuery(new Term("field", regexp), RegExp.NONE);
     DumbRegexpQuery dumb = new DumbRegexpQuery(new Term("field", regexp), RegExp.NONE);
     

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java Thu Jan 13 02:09:33 2011
@@ -7,6 +7,7 @@ import java.util.BitSet;
 import java.io.IOException;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -141,7 +142,7 @@ public class TestScorerPerf extends Luce
     final BitSet rnd = sets[random.nextInt(sets.length)];
     Query q = new ConstantScoreQuery(new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) {
+      public DocIdSet getDocIdSet(AtomicReaderContext context) {
         return new DocIdBitSet(rnd);
       }
     });

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimilarity.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimilarity.java Thu Jan 13 02:09:33 2011
@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTest
 import java.io.IOException;
 import java.util.Collection;
 
+import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
@@ -38,13 +39,13 @@ import org.apache.lucene.search.Explanat
 public class TestSimilarity extends LuceneTestCase {
   
   public static class SimpleSimilarity extends Similarity {
-    @Override public float lengthNorm(String field, int numTerms) { return 1.0f; }
+    @Override public float computeNorm(String field, FieldInvertState state) { return state.getBoost(); }
     @Override public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
     @Override public float tf(float freq) { return freq; }
     @Override public float sloppyFreq(int distance) { return 2.0f; }
     @Override public float idf(int docFreq, int numDocs) { return 1.0f; }
     @Override public float coord(int overlap, int maxOverlap) { return 1.0f; }
-    @Override public IDFExplanation idfExplain(Collection<Term> terms, Searcher searcher) throws IOException {
+    @Override public IDFExplanation idfExplain(Collection<Term> terms, IndexSearcher searcher) throws IOException {
       return new IDFExplanation() {
         @Override
         public float getIdf() {
@@ -75,7 +76,7 @@ public class TestSimilarity extends Luce
     IndexReader reader = writer.getReader();
     writer.close();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = new IndexSearcher(reader);
     searcher.setSimilarity(new SimpleSimilarity());
 
     Term a = new Term("field", "a");

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java Thu Jan 13 02:09:33 2011
@@ -17,18 +17,6 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.spans.SpanNearQuery;
-import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.store.Directory;
-
-
 /**
  * TestExplanations subclass focusing on basic query types
  */
@@ -301,73 +289,4 @@ public class TestSimpleExplanations exte
     qtest(q, new int[] { 0,3 });
     
   }
-  
-  
-  public void testTermQueryMultiSearcherExplain() throws Exception {
-    // creating two directories for indices
-    Directory indexStoreA = newDirectory();
-    Directory indexStoreB = newDirectory();
-
-    Document lDoc = new Document();
-    lDoc.add(newField("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
-    Document lDoc2 = new Document();
-    lDoc2.add(newField("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
-    Document lDoc3 = new Document();
-    lDoc3.add(newField("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
-
-    IndexWriter writerA = new IndexWriter(indexStoreA, newIndexWriterConfig(
-        TEST_VERSION_CURRENT, new MockAnalyzer()));
-    IndexWriter writerB = new IndexWriter(indexStoreB, newIndexWriterConfig(
-        TEST_VERSION_CURRENT, new MockAnalyzer()));
-
-    writerA.addDocument(lDoc);
-    writerA.addDocument(lDoc2);
-    writerA.optimize();
-    writerA.close();
-
-    writerB.addDocument(lDoc3);
-    writerB.close();
-
-    QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, "fulltext", new MockAnalyzer());
-    Query query = parser.parse("handle:1");
-
-    Searcher[] searchers = new Searcher[2];
-    searchers[0] = new IndexSearcher(indexStoreB, true);
-    searchers[1] = new IndexSearcher(indexStoreA, true);
-    Searcher mSearcher = new MultiSearcher(searchers);
-    ScoreDoc[] hits = mSearcher.search(query, null, 1000).scoreDocs;
-
-    assertEquals(3, hits.length);
-
-    Explanation explain = mSearcher.explain(query, hits[0].doc);
-    String exp = explain.toString(0);
-    assertTrue(exp, exp.indexOf("maxDocs=3") > -1);
-    assertTrue(exp, exp.indexOf("docFreq=3") > -1);
-    
-    query = parser.parse("handle:\"1 2\"");
-    hits = mSearcher.search(query, null, 1000).scoreDocs;
-
-    assertEquals(3, hits.length);
-
-    explain = mSearcher.explain(query, hits[0].doc);
-    exp = explain.toString(0);
-    assertTrue(exp, exp.indexOf("1=3") > -1);
-    assertTrue(exp, exp.indexOf("2=3") > -1);
-    
-    query = new SpanNearQuery(new SpanQuery[] {
-        new SpanTermQuery(new Term("handle", "1")),
-        new SpanTermQuery(new Term("handle", "2")) }, 0, true);
-    hits = mSearcher.search(query, null, 1000).scoreDocs;
-
-    assertEquals(3, hits.length);
-
-    explain = mSearcher.explain(query, hits[0].doc);
-    exp = explain.toString(0);
-    assertTrue(exp, exp.indexOf("1=3") > -1);
-    assertTrue(exp, exp.indexOf("2=3") > -1);
-    mSearcher.close();
-    indexStoreA.close();
-    indexStoreB.close();
-  }
-  
 }

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestSort.java Thu Jan 13 02:09:33 2011
@@ -34,11 +34,12 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.MultiReader;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.FieldValueHitQueue.Entry;
@@ -49,8 +50,9 @@ import org.apache.lucene.search.cache.Fl
 import org.apache.lucene.search.cache.IntValuesCreator;
 import org.apache.lucene.search.cache.LongValuesCreator;
 import org.apache.lucene.search.cache.ShortValuesCreator;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.LockObtainFailedException;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
@@ -456,7 +458,7 @@ public class TestSort extends LuceneTest
 
   // test sorts when there's nothing in the index
   public void testEmptyIndex() throws Exception {
-    Searcher empty = getEmptyIndex();
+    IndexSearcher empty = getEmptyIndex();
 
     sort = new Sort();
     assertMatches (empty, queryX, sort, "");
@@ -599,23 +601,9 @@ public class TestSort extends LuceneTest
         new SortField ("float", SortField.FLOAT, true) );
     assertMatches (full, queryG, sort, "ZYXW");
 
-    // Do the same for a MultiSearcher
-    Searcher multiSearcher=new MultiSearcher (full);
-
-    sort.setSort (new SortField ("int", SortField.INT),
-                                new SortField ("string", SortField.STRING),
-        new SortField ("float", SortField.FLOAT) );
-    assertMatches (multiSearcher, queryG, sort, "ZWXY");
-
-    sort.setSort (new SortField ("int", SortField.INT),
-                                new SortField ("string", SortField.STRING),
-        new SortField ("float", SortField.FLOAT, true) );
-    assertMatches (multiSearcher, queryG, sort, "ZYXW");
-    // Don't close the multiSearcher. it would close the full searcher too!
-
     // Do the same for a ParallelMultiSearcher
     ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random, 2, 8));
-    Searcher parallelSearcher=new ParallelMultiSearcher (exec, full);
+    IndexSearcher parallelSearcher=new IndexSearcher (full.getIndexReader(), exec);
 
     sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
@@ -627,6 +615,7 @@ public class TestSort extends LuceneTest
         new SortField ("float", SortField.FLOAT, true) );
     assertMatches (parallelSearcher, queryG, sort, "ZYXW");
     parallelSearcher.close();
+    exec.shutdown();
     exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
   }
 
@@ -672,117 +661,19 @@ public class TestSort extends LuceneTest
     assertMatches (full, queryX, sort, "EACGI");
   }
     
-    // Test the MultiSearcher's ability to preserve locale-sensitive ordering
-    // by wrapping it around a single searcher
-  public void testInternationalMultiSearcherSort() throws Exception {
-    Searcher multiSearcher = new MultiSearcher (full);
-    
-    sort.setSort (new SortField ("i18n", new Locale("sv", "se")));
-    assertMatches (multiSearcher, queryY, sort, "BJDFH");
-    
-    sort.setSort (new SortField ("i18n", Locale.US));
-    assertMatches (multiSearcher, queryY, sort, oStrokeFirst ? "BFJHD" : "BFJDH");
-    
-    sort.setSort (new SortField ("i18n", new Locale("da", "dk")));
-    assertMatches (multiSearcher, queryY, sort, "BJDHF");
-  } 
-
-  // test a variety of sorts using more than one searcher
-  public void testMultiSort() throws Exception {
-    MultiSearcher searcher = new MultiSearcher (searchX, searchY);
-    runMultiSorts(searcher, false);
-  }
-
   // test a variety of sorts using a parallel multisearcher
   public void testParallelMultiSort() throws Exception {
     ExecutorService exec = Executors.newFixedThreadPool(_TestUtil.nextInt(random, 2, 8));
-    Searcher searcher = new ParallelMultiSearcher (exec, searchX, searchY);
+    IndexSearcher searcher = new IndexSearcher(
+                                  new MultiReader(
+                                       new IndexReader[] {searchX.getIndexReader(),
+                                                          searchY.getIndexReader()}), exec);
     runMultiSorts(searcher, false);
     searcher.close();
+    exec.shutdown();
     exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
   }
 
-  // test that the relevancy scores are the same even if
-  // hits are sorted
-  public void testNormalizedScores() throws Exception {
-
-    // capture relevancy scores
-    HashMap<String,Float> scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
-    HashMap<String,Float> scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
-    HashMap<String,Float> scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
-
-    // we'll test searching locally, remote and multi
-    
-    MultiSearcher multi  = new MultiSearcher (searchX, searchY);
-
-    // change sorting and make sure relevancy stays the same
-
-    sort = new Sort();
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort(SortField.FIELD_DOC);
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField("int", SortField.INT));
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField("float", SortField.FLOAT));
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField("string", SortField.STRING));
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField("int", SortField.INT),new SortField("float", SortField.FLOAT));
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField ("int", SortField.INT, true), new SortField (null, SortField.DOC, true) );
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-    sort.setSort (new SortField("int", SortField.INT),new SortField("string", SortField.STRING));
-    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
-    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
-    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
-
-  }
-
   public void testTopDocsScores() throws Exception {
 
     // There was previously a bug in FieldSortedHitQueue.maxscore when only a single
@@ -797,9 +688,9 @@ public class TestSort extends LuceneTest
     // a filter that only allows through the first hit
     Filter filt = new Filter() {
       @Override
-      public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
-        BitSet bs = new BitSet(reader.maxDoc());
-        bs.set(0, reader.maxDoc());
+      public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {
+        BitSet bs = new BitSet(context.reader.maxDoc());
+        bs.set(0, context.reader.maxDoc());
         bs.set(docs1.scoreDocs[0].doc);
         return new DocIdBitSet(bs);
       }
@@ -1024,7 +915,7 @@ public class TestSort extends LuceneTest
   }
   
   // runs a variety of sorts useful for multisearchers
-  private void runMultiSorts(Searcher multi, boolean isFull) throws Exception {
+  private void runMultiSorts(IndexSearcher multi, boolean isFull) throws Exception {
     sort.setSort(SortField.FIELD_DOC);
     String expected = isFull ? "ABCDEFGHIJ" : "ACEGIBDFHJ";
     assertMatches(multi, queryA, sort, expected);
@@ -1101,12 +992,12 @@ public class TestSort extends LuceneTest
 
   }
 
-  private void assertMatches(Searcher searcher, Query query, Sort sort, String expectedResult) throws IOException {
+  private void assertMatches(IndexSearcher searcher, Query query, Sort sort, String expectedResult) throws IOException {
     assertMatches( null, searcher, query, sort, expectedResult );
   }
 
   // make sure the documents returned by the search match the expected list
-  private void assertMatches(String msg, Searcher searcher, Query query, Sort sort,
+  private void assertMatches(String msg, IndexSearcher searcher, Query query, Sort sort,
       String expectedResult) throws IOException {
     //ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs;
     TopDocs hits = searcher.search (query, null, Math.max(1, expectedResult.length()), sort);
@@ -1124,7 +1015,7 @@ public class TestSort extends LuceneTest
     assertEquals (msg, expectedResult, buff.toString());
   }
 
-  private HashMap<String,Float> getScores (ScoreDoc[] hits, Searcher searcher)
+  private HashMap<String,Float> getScores (ScoreDoc[] hits, IndexSearcher searcher)
   throws IOException {
     HashMap<String,Float> scoreMap = new HashMap<String,Float>();
     int n = hits.length;

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java Thu Jan 13 02:09:33 2011
@@ -134,7 +134,7 @@ public class TestTermRangeQuery extends 
     searcher.close();
   }
   
-  private void checkBooleanTerms(Searcher searcher, TermRangeQuery query, String... terms) throws IOException {
+  private void checkBooleanTerms(IndexSearcher searcher, TermRangeQuery query, String... terms) throws IOException {
     query.setRewriteMethod(new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(50));
     final BooleanQuery bq = (BooleanQuery) searcher.rewrite(query);
     final Set<String> allowedTerms = asSet(terms);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermScorer.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTermScorer.java Thu Jan 13 02:09:33 2011
@@ -28,6 +28,7 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.SlowMultiReaderWrapper;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.store.Directory;
 
 public class TestTermScorer extends LuceneTestCase {
@@ -70,8 +71,8 @@ public class TestTermScorer extends Luce
     TermQuery termQuery = new TermQuery(allTerm);
     
     Weight weight = termQuery.weight(indexSearcher);
-    
-    Scorer ts = weight.scorer(indexSearcher.getIndexReader(), true, true);
+    assertTrue(indexSearcher.getTopReaderContext().isAtomic);
+    Scorer ts = weight.scorer((AtomicReaderContext)indexSearcher.getTopReaderContext(), true, true);
     // we have 2 documents with the term all in them, one document for all the
     // other values
     final List<TestHit> docs = new ArrayList<TestHit>();
@@ -131,8 +132,8 @@ public class TestTermScorer extends Luce
     TermQuery termQuery = new TermQuery(allTerm);
     
     Weight weight = termQuery.weight(indexSearcher);
-    
-    Scorer ts = weight.scorer(indexSearcher.getIndexReader(), true, true);
+    assertTrue(indexSearcher.getTopReaderContext().isAtomic);
+    Scorer ts = weight.scorer((AtomicReaderContext) indexSearcher.getTopReaderContext(), true, true);
     assertTrue("next did not return a doc",
         ts.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
     assertTrue("score is not correct", ts.score() == 1.6931472f);
@@ -149,8 +150,9 @@ public class TestTermScorer extends Luce
     TermQuery termQuery = new TermQuery(allTerm);
     
     Weight weight = termQuery.weight(indexSearcher);
-    
-    Scorer ts = weight.scorer(indexSearcher.getIndexReader(), true, true);
+    assertTrue(indexSearcher.getTopReaderContext().isAtomic);
+
+    Scorer ts = weight.scorer((AtomicReaderContext) indexSearcher.getTopReaderContext(), true, true);
     assertTrue("Didn't skip", ts.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
     // The next doc should be doc 5
     assertTrue("doc should be number 5", ts.docID() == 5);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestThreadSafe.java Thu Jan 13 02:09:33 2011
@@ -27,6 +27,7 @@ import org.apache.lucene.document.*;
 
 import java.util.Random;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.io.IOException;
 
 public class TestThreadSafe extends LuceneTestCase {
@@ -34,16 +35,16 @@ public class TestThreadSafe extends Luce
 
   IndexReader ir1;
 
-  String failure=null;
-
-
   class Thr extends Thread {
     final int iter;
     final Random rand;
+    final AtomicBoolean failed;
+
     // pass in random in case we want to make things reproducable
-    public Thr(int iter, Random rand) {
+    public Thr(int iter, Random rand, AtomicBoolean failed) {
       this.iter = iter;
       this.rand = rand;
+      this.failed = failed;
     }
 
     @Override
@@ -61,8 +62,8 @@ public class TestThreadSafe extends Luce
 
         }
       } catch (Throwable th) {
-        failure=th.toString();
-        fail(failure);
+        failed.set(true);
+        throw new RuntimeException(th);
       }
     }
 
@@ -124,16 +125,15 @@ public class TestThreadSafe extends Luce
 
   void doTest(int iter, int nThreads) throws Exception {
     Thr[] tarr = new Thr[nThreads];
+    AtomicBoolean failed = new AtomicBoolean();
     for (int i=0; i<nThreads; i++) {
-      tarr[i] = new Thr(iter, new Random(random.nextLong()));
+      tarr[i] = new Thr(iter, new Random(random.nextLong()), failed);
       tarr[i].start();
     }
     for (int i=0; i<nThreads; i++) {
       tarr[i].join();
     }
-    if (failure!=null) {
-      fail(failure);
-    }
+    assertFalse(failed.get());
   }
 
   public void testLazyLoadThreadSafety() throws Exception{
@@ -142,7 +142,7 @@ public class TestThreadSafe extends Luce
     buildDir(dir1, 15, 5, 2000);
 
     // do many small tests so the thread locals go away inbetween
-    int num = 100 * RANDOM_MULTIPLIER;
+    int num = 10 * RANDOM_MULTIPLIER;
     for (int i = 0; i < num; i++) {
       ir1 = IndexReader.open(dir1, false);
       doTest(10,10);

Modified: lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=1058390&r1=1058389&r2=1058390&view=diff
==============================================================================
--- lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/dev/branches/bulkpostings/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Thu Jan 13 02:09:33 2011
@@ -30,12 +30,14 @@ import org.apache.lucene.search.TimeLimi
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.junit.Ignore;
 
 /**
  * Tests the {@link TimeLimitingCollector}.  This test checks (1) search
  * correctness (regardless of timeout), (2) expected timeout behavior,
  * and (3) a sanity test with multiple searching threads.
  */
+@Ignore("broken: see https://issues.apache.org/jira/browse/LUCENE-2822")
 public class TestTimeLimitingCollector extends LuceneTestCase {
   private static final int SLOW_DOWN = 3;
   private static final long TIME_ALLOWED = 17 * SLOW_DOWN; // so searches can find about 17 docs.
@@ -48,7 +50,7 @@ public class TestTimeLimitingCollector e
   private static final int N_DOCS = 3000;
   private static final int N_THREADS = 50;
 
-  private Searcher searcher;
+  private IndexSearcher searcher;
   private Directory directory;
   private IndexReader reader;
 



Mime
View raw message