lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1058431 [1/2] - in /lucene/dev/trunk: lucene/src/java/org/apache/lucene/search/ lucene/src/java/org/apache/lucene/search/function/ lucene/src/java/org/apache/lucene/util/ lucene/src/test/org/apache/lucene/search/function/ solr/src/java/org...
Date Thu, 13 Jan 2011 07:13:28 GMT
Author: simonw
Date: Thu Jan 13 07:13:23 2011
New Revision: 1058431

URL: http://svn.apache.org/viewvc?rev=1058431&view=rev
Log:
LUCENE-2831:  Cut over ValueSource#docValues to AtomicReaderContext & removed SolrIndexReader

Removed:
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexReader.java
Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TermQuery.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/FieldCacheSource.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/MultiValueSource.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/OrdFieldSource.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ReverseOrdFieldSource.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSource.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ReaderUtil.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestOrdValues.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/ReplicationHandler.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/SnapPuller.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/HighlightComponent.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/StatsComponent.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/TermVectorComponent.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/request/UnInvertedField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/DateField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/LatLonType.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/RandomSortField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableDoubleField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableFloatField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrFilter.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/BoostedQuery.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ByteFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ConstValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DocFreqValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleConstValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DualFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/FileFloatSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/FloatFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/FunctionQuery.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IDFValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/IntFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/JoinDocFreqValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/LinearFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/LiteralValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/LongFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/MaxDocValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/MaxFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/MultiFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/NormValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/NumDocsValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/OrdFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/QueryValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/RangeMapFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ReciprocalFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ReverseOrdFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ScaleFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ShortFieldSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/SimpleFloatFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/TFValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/TermFreqValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/VectorValueSource.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/GeohashFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/GeohashHaversineFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/HaversineConstFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/HaversineFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/StringDistanceFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/distance/VectorDistanceFunction.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/update/UpdateHandler.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/request/TestFaceting.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/search/TestIndexSearcher.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
    lucene/dev/trunk/solr/src/webapp/src/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java Thu Jan 13 07:13:23 2011
@@ -174,20 +174,34 @@ public class IndexSearcher {
       }
     }
   }
-  
-  /* Ctor for concurrent sub-searchers searching only on a specific leaf of the given top-reader context
-   * - instead of searching over all leaves this searcher only searches a single leaf searcher slice. Hence, 
-   * for scorer and filter this looks like an ordinary search in the hierarchy such that there is no difference
-   * between single and multi-threaded */
-  private IndexSearcher(ReaderContext topLevel, AtomicReaderContext leaf) {
+
+  /**
+   * Expert: Creates a searcher from a top-level {@link ReaderContext} with and
+   * executes searches on the given leave slice exclusively instead of searching
+   * over all leaves. This constructor should be used to run one or more leaves
+   * within a single thread. Hence, for scorer and filter this looks like an
+   * ordinary search in the hierarchy such that there is no difference between
+   * single and multi-threaded.
+   * 
+   * @lucene.experimental
+   * */
+  public IndexSearcher(ReaderContext topLevel, AtomicReaderContext... leaves) {
+    assert assertLeaves(topLevel, leaves);
     readerContext = topLevel;
     reader = topLevel.reader;
-    leafContexts = new AtomicReaderContext[] {leaf};
+    leafContexts = leaves;
     executor = null;
     subSearchers = null;
     closeReader = false;
   }
   
+  private boolean assertLeaves(ReaderContext topLevel, AtomicReaderContext... leaves) {
+    for (AtomicReaderContext leaf : leaves) {
+      assert ReaderUtil.getTopLevelContext(leaf) == topLevel : "leaf context is not a leaf of the given top-level context";
+    }
+    return true;
+  }
+  
   /** Return the {@link IndexReader} this searches. */
   public IndexReader getIndexReader() {
     return reader;

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TermQuery.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TermQuery.java Thu Jan 13 07:13:23 2011
@@ -30,6 +30,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Explanation.IDFExplanation;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.PerReaderTermState;
+import org.apache.lucene.util.ReaderUtil;
 import org.apache.lucene.util.ToStringUtils;
 
 /** A Query that matches documents containing a term.
@@ -88,7 +89,7 @@ public class TermQuery extends Query {
     public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       final String field = term.field();
       final IndexReader reader = context.reader;
-      assert assertTopReaderContext(termStates, context) : "The top-reader used to create Weight is not the same as the current reader's top-reader";
+      assert termStates.topReaderContext == ReaderUtil.getTopLevelContext(context) : "The top-reader used to create Weight is not the same as the current reader's top-reader";
       final TermState state = termStates
           .get(context.ord);
       if (state == null) { // term is not present in that reader
@@ -106,14 +107,6 @@ public class TermQuery extends Query {
       return terms == null || terms.docFreq(bytes) == 0;
     }
     
-    private boolean assertTopReaderContext(PerReaderTermState state, ReaderContext context) {
-      while(context.parent != null) {
-        context = context.parent;
-      }
-      return state.topReaderContext == context;
-    }
-    
-   
     @Override
     public Explanation explain(AtomicReaderContext context, int doc)
       throws IOException {

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/FieldCacheSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/FieldCacheSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/FieldCacheSource.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/FieldCacheSource.java Thu Jan 13 07:13:23 2011
@@ -20,6 +20,7 @@ package org.apache.lucene.search.functio
 import java.io.IOException;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.FieldCache;
 
 /**
@@ -55,8 +56,8 @@ public abstract class FieldCacheSource e
 
   /* (non-Javadoc) @see org.apache.lucene.search.function.ValueSource#getValues(org.apache.lucene.index.IndexReader) */
   @Override
-  public final DocValues getValues(IndexReader reader) throws IOException {
-    return getCachedFieldValues(FieldCache.DEFAULT, field, reader);
+  public final DocValues getValues(AtomicReaderContext context) throws IOException {
+    return getCachedFieldValues(FieldCache.DEFAULT, field, context.reader);
   }
 
   /* (non-Javadoc) @see org.apache.lucene.search.function.ValueSource#description() */

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/MultiValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/MultiValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/MultiValueSource.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/MultiValueSource.java Thu Jan 13 07:13:23 2011
@@ -20,6 +20,9 @@ package org.apache.lucene.search.functio
 import java.io.IOException;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
+import org.apache.lucene.index.IndexReader.ReaderContext;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.util.ReaderUtil;
 
@@ -44,16 +47,16 @@ public final class MultiValueSource exte
   }
 
   @Override
-  public DocValues getValues(IndexReader reader) throws IOException {
-
-    IndexReader[] subReaders = reader.getSequentialSubReaders();
-    if (subReaders != null) {
-      // This is a composite reader
-      return new MultiDocValues(subReaders);
-    } else {
+  public DocValues getValues(AtomicReaderContext context) throws IOException {
       // Already an atomic reader -- just delegate
-      return other.getValues(reader);
+      return other.getValues(context);
+  }
+  
+  public DocValues getValues(ReaderContext context) throws IOException {
+    if (context.isAtomic) {
+      return getValues((AtomicReaderContext) context);
     }
+    return new MultiDocValues(ReaderUtil.leaves(context));
   }
 
   @Override
@@ -78,59 +81,56 @@ public final class MultiValueSource exte
   private final class MultiDocValues extends DocValues {
 
     final DocValues[] docValues;
-    final int[] docStarts;
+    final AtomicReaderContext[] leaves;
 
-    MultiDocValues(IndexReader[] subReaders) throws IOException {
-      docValues = new DocValues[subReaders.length];
-      docStarts = new int[subReaders.length];
-      int base = 0;
-      for(int i=0;i<subReaders.length;i++) {
-        docValues[i] = other.getValues(subReaders[i]);
-        docStarts[i] = base;
-        base += subReaders[i].maxDoc();
+    MultiDocValues(AtomicReaderContext[] leaves) throws IOException {
+      this.leaves = leaves;
+      docValues = new DocValues[leaves.length];
+      for(int i=0;i<leaves.length;i++) {
+        docValues[i] = other.getValues(leaves[i]);
       }
     }
     
     @Override
     public float floatVal(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].floatVal(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].floatVal(doc-leaves[n].docBase);
     }
 
     @Override
     public int intVal(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].intVal(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].intVal(doc-leaves[n].docBase);
     }
 
     @Override
     public long longVal(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].longVal(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].longVal(doc-leaves[n].docBase);
     }
 
     @Override
     public double doubleVal(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].doubleVal(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].doubleVal(doc-leaves[n].docBase);
     }
 
     @Override
     public String strVal(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].strVal(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].strVal(doc-leaves[n].docBase);
     }
 
     @Override
     public String toString(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].toString(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].toString(doc-leaves[n].docBase);
     }
 
     @Override
     public Explanation explain(int doc) {
-      final int n = ReaderUtil.subIndex(doc, docStarts);
-      return docValues[n].explain(doc-docStarts[n]);
+      final int n = ReaderUtil.subIndex(doc, leaves);
+      return docValues[n].explain(doc-leaves[n].docBase);
     }
   }
 }

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/OrdFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/OrdFieldSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/OrdFieldSource.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/OrdFieldSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.lucene.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.FieldCache.DocTermsIndex;
 
@@ -69,8 +69,8 @@ public class OrdFieldSource extends Valu
 
   /*(non-Javadoc) @see org.apache.lucene.search.function.ValueSource#getValues(org.apache.lucene.index.IndexReader) */
   @Override
-  public DocValues getValues(IndexReader reader) throws IOException {
-    final DocTermsIndex termsIndex = FieldCache.DEFAULT.getTermsIndex(reader, field);
+  public DocValues getValues(AtomicReaderContext context) throws IOException {
+    final DocTermsIndex termsIndex = FieldCache.DEFAULT.getTermsIndex(context.reader, field);
     return new DocValues() {
       /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#floatVal(int) */
       @Override

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ReverseOrdFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ReverseOrdFieldSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ReverseOrdFieldSource.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ReverseOrdFieldSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.lucene.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.FieldCache;
 
 import java.io.IOException;
@@ -69,8 +69,8 @@ public class ReverseOrdFieldSource exten
 
   /*(non-Javadoc) @see org.apache.lucene.search.function.ValueSource#getValues(org.apache.lucene.index.IndexReader) */
   @Override
-  public DocValues getValues(IndexReader reader) throws IOException {
-    final FieldCache.DocTermsIndex termsIndex = FieldCache.DEFAULT.getTermsIndex(reader, field);
+  public DocValues getValues(AtomicReaderContext context) throws IOException {
+    final FieldCache.DocTermsIndex termsIndex = FieldCache.DEFAULT.getTermsIndex(context.reader, field);
 
     final int end = termsIndex.numOrd();
 

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSource.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,10 @@ package org.apache.lucene.search.functio
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
+import org.apache.lucene.index.IndexReader.CompositeReaderContext;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
+import org.apache.lucene.index.IndexReader.ReaderContext;
 import org.apache.lucene.search.function.DocValues;
 
 import java.io.IOException;
@@ -39,11 +42,23 @@ public abstract class ValueSource implem
 
   /**
    * Return the DocValues used by the function query.
-   * @param reader the IndexReader used to read these values.
+   * @param context the IndexReader used to read these values.
    * If any caching is involved, that caching would also be IndexReader based.  
    * @throws IOException for any error.
    */
-  public abstract DocValues getValues(IndexReader reader) throws IOException;
+  public abstract DocValues getValues(AtomicReaderContext context) throws IOException;
+  
+  /**
+   * Return the DocValues used by the function query.
+   * @deprecated (4.0) This method is temporary, to ease the migration to segment-based
+   * searching. Please change your code to not pass {@link CompositeReaderContext} to these
+   * APIs. Use {@link #getValues(AtomicReaderContext)} instead
+   */
+  @Deprecated
+  public DocValues getValues(ReaderContext context) throws IOException {
+    return getValues((AtomicReaderContext) context);
+  }
+
 
   /** 
    * description of field, used in explain() 

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/function/ValueSourceQuery.java Thu Jan 13 07:13:23 2011
@@ -100,13 +100,13 @@ public class ValueSourceQuery extends Qu
 
     @Override
     public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
-      return new ValueSourceScorer(similarity, context.reader, this);
+      return new ValueSourceScorer(similarity, context, this);
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */
     @Override
     public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
-      DocValues vals = valSrc.getValues(context.reader);
+      DocValues vals = valSrc.getValues(context);
       float sc = queryWeight * vals.floatVal(doc);
 
       Explanation result = new ComplexExplanation(
@@ -133,11 +133,12 @@ public class ValueSourceQuery extends Qu
     private int doc = -1;
 
     // constructor
-    private ValueSourceScorer(Similarity similarity, IndexReader reader, ValueSourceWeight w) throws IOException {
+    private ValueSourceScorer(Similarity similarity, AtomicReaderContext context, ValueSourceWeight w) throws IOException {
       super(similarity,w);
+      final IndexReader reader = context.reader;
       qWeight = w.getValue();
       // this is when/where the values are first created.
-      vals = valSrc.getValues(reader);
+      vals = valSrc.getValues(context);
       delDocs = reader.getDeletedDocs();
       maxDoc = reader.maxDoc();
     }

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ReaderUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ReaderUtil.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ReaderUtil.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ReaderUtil.java Thu Jan 13 07:13:23 2011
@@ -228,6 +228,17 @@ public final class ReaderUtil {
     }
     return leaves;
   }
+  
+  /**
+   * Walks up the reader tree and return the given context's top level reader
+   * context, or in other words the reader tree's root context.
+   */
+  public static ReaderContext getTopLevelContext(ReaderContext context) {
+    while (context.parent != null) {
+      context = context.parent;
+    }
+    return context;
+  }
 
   /**
    * Returns index of the searcher/reader for document <code>n</code> in the

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java Thu Jan 13 07:13:23 2011
@@ -18,6 +18,7 @@ package org.apache.lucene.search.functio
  */
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.FieldCache;
 
 import java.io.IOException;
@@ -82,7 +83,7 @@ final class JustCompileSearchFunction {
     }
 
     @Override
-    public DocValues getValues(IndexReader reader) throws IOException {
+    public DocValues getValues(AtomicReaderContext context) throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java Thu Jan 13 07:13:23 2011
@@ -19,12 +19,13 @@ package org.apache.lucene.search.functio
 
 import java.util.HashMap;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.ReaderUtil;
 import org.junit.Test;
 
 /**
@@ -185,12 +186,12 @@ public class TestFieldScoreQuery extends
       FieldScoreQuery q = new FieldScoreQuery(field,tp);
       ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
       assertEquals("All docs should be matched!",N_DOCS,h.length);
-      IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
-      for (int j = 0; j < readers.length; j++) {
-        IndexReader reader = readers[j];
+      AtomicReaderContext[] leaves = ReaderUtil.leaves(s.getTopReaderContext());
+      for (int j = 0; j < leaves.length; j++) {
+        AtomicReaderContext leaf = leaves[j];
         try {
           if (i == 0) {
-            innerArray[j] = q.valSrc.getValues(reader).getInnerArray();
+            innerArray[j] = q.valSrc.getValues(leaf).getInnerArray();
             log(i + ".  compare: " + innerArray[j].getClass() + " to "
                 + expectedArrayTypes.get(tp).getClass());
             assertEquals(
@@ -198,9 +199,9 @@ public class TestFieldScoreQuery extends
                 innerArray[j].getClass(), expectedArrayTypes.get(tp).getClass());
           } else {
             log(i + ".  compare: " + innerArray[j] + " to "
-                + q.valSrc.getValues(reader).getInnerArray());
+                + q.valSrc.getValues(leaf).getInnerArray());
             assertSame("field values should be cached and reused!", innerArray[j],
-                q.valSrc.getValues(reader).getInnerArray());
+                q.valSrc.getValues(leaf).getInnerArray());
           }
         } catch (UnsupportedOperationException e) {
           if (!warned) {
@@ -217,15 +218,15 @@ public class TestFieldScoreQuery extends
     FieldScoreQuery q = new FieldScoreQuery(field,tp);
     ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
     assertEquals("All docs should be matched!",N_DOCS,h.length);
-    IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
-    for (int j = 0; j < readers.length; j++) {
-      IndexReader reader = readers[j];
+    AtomicReaderContext[] leaves = ReaderUtil.leaves(s.getTopReaderContext());
+    for (int j = 0; j < leaves.length; j++) {
+      AtomicReaderContext leaf = leaves[j];
       try {
         log("compare: " + innerArray + " to "
-            + q.valSrc.getValues(reader).getInnerArray());
+            + q.valSrc.getValues(leaf).getInnerArray());
         assertNotSame(
             "cached field values should not be reused if reader as changed!",
-            innerArray, q.valSrc.getValues(reader).getInnerArray());
+            innerArray, q.valSrc.getValues(leaf).getInnerArray());
       } catch (UnsupportedOperationException e) {
         if (!warned) {
           System.err.println("WARNING: " + testName()

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestOrdValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestOrdValues.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestOrdValues.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestOrdValues.java Thu Jan 13 07:13:23 2011
@@ -18,8 +18,9 @@ package org.apache.lucene.search.functio
  */
 
 import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.*;
+import org.apache.lucene.util.ReaderUtil;
 import org.junit.Test;
 
 /**
@@ -168,14 +169,14 @@ public class TestOrdValues extends Funct
       ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
       try {
         assertEquals("All docs should be matched!", N_DOCS, h.length);
-        IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
+        AtomicReaderContext[] leaves = ReaderUtil.leaves(s.getTopReaderContext());
 
-        for (IndexReader reader : readers) {
+        for (AtomicReaderContext leaf : leaves) {
           if (i == 0) {
-            innerArray = q.valSrc.getValues(reader).getInnerArray();
+            innerArray = q.valSrc.getValues(leaf).getInnerArray();
           } else {
-            log(i + ".  compare: " + innerArray + " to " + q.valSrc.getValues(reader).getInnerArray());
-            assertSame("field values should be cached and reused!", innerArray, q.valSrc.getValues(reader).getInnerArray());
+            log(i + ".  compare: " + innerArray + " to " + q.valSrc.getValues(leaf).getInnerArray());
+            assertSame("field values should be cached and reused!", innerArray, q.valSrc.getValues(leaf).getInnerArray());
           }
         }
       } catch (UnsupportedOperationException e) {
@@ -201,15 +202,15 @@ public class TestOrdValues extends Funct
     q = new ValueSourceQuery(vs);
     h = s.search(q, null, 1000).scoreDocs;
     assertEquals("All docs should be matched!", N_DOCS, h.length);
-    IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
+    AtomicReaderContext[] leaves = ReaderUtil.leaves(s.getTopReaderContext());
 
-    for (IndexReader reader : readers) {
+    for (AtomicReaderContext leaf : leaves) {
       try {
         log("compare (should differ): " + innerArray + " to "
-                + q.valSrc.getValues(reader).getInnerArray());
+                + q.valSrc.getValues(leaf).getInnerArray());
         assertNotSame(
                 "different values should be loaded for a different field!",
-                innerArray, q.valSrc.getValues(reader).getInnerArray());
+                innerArray, q.valSrc.getValues(leaf).getInnerArray());
       } catch (UnsupportedOperationException e) {
         if (!warned) {
           System.err.println("WARNING: " + testName()
@@ -229,15 +230,15 @@ public class TestOrdValues extends Funct
     q = new ValueSourceQuery(vs);
     h = s.search(q, null, 1000).scoreDocs;
     assertEquals("All docs should be matched!", N_DOCS, h.length);
-    readers = s.getIndexReader().getSequentialSubReaders();
+    leaves = ReaderUtil.leaves(s.getTopReaderContext());
 
-    for (IndexReader reader : readers) {
+    for (AtomicReaderContext leaf : leaves) {
       try {
         log("compare (should differ): " + innerArray + " to "
-                + q.valSrc.getValues(reader).getInnerArray());
+                + q.valSrc.getValues(leaf).getInnerArray());
         assertNotSame(
                 "cached field values should not be reused if reader as changed!",
-                innerArray, q.valSrc.getValues(reader).getInnerArray());
+                innerArray, q.valSrc.getValues(leaf).getInnerArray());
       } catch (UnsupportedOperationException e) {
         if (!warned) {
           System.err.println("WARNING: " + testName()

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/function/TestValueSource.java Thu Jan 13 07:13:23 2011
@@ -22,6 +22,7 @@ import org.apache.lucene.store.*;
 import org.apache.lucene.search.*;
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.index.*;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.document.*;
 
 public class TestValueSource extends LuceneTestCase {
@@ -45,11 +46,17 @@ public class TestValueSource extends Luc
     assertTrue(r.getSequentialSubReaders().length > 1);
 
     ValueSource s1 = new IntFieldSource("field");
-    DocValues v1 = s1.getValues(r);
-    DocValues v2 = new MultiValueSource(s1).getValues(r);
-
+    AtomicReaderContext[] leaves = ReaderUtil.leaves(r.getTopReaderContext());
+    DocValues v1 = null;
+    DocValues v2 = new MultiValueSource(s1).getValues(r.getTopReaderContext());
+    int leafOrd = -1;
     for(int i=0;i<r.maxDoc();i++) {
-      assertEquals(v1.intVal(i), i);
+      int subIndex = ReaderUtil.subIndex(i, leaves);
+      if (subIndex != leafOrd) {
+        leafOrd = subIndex;
+        v1 = s1.getValues(leaves[leafOrd]);
+      }
+      assertEquals(v1.intVal(i - leaves[leafOrd].docBase), i);
       assertEquals(v2.intVal(i), i);
     }
 

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java Thu Jan 13 07:13:23 2011
@@ -1005,7 +1005,7 @@ public final class SolrCore implements S
       
       if (newestSearcher != null && solrConfig.reopenReaders
           && indexDirFile.equals(newIndexDirFile)) {
-        IndexReader currentReader = newestSearcher.get().getReader();
+        IndexReader currentReader = newestSearcher.get().getIndexReader();
         IndexReader newReader = currentReader.reopen();
 
         if (newReader == currentReader) {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java Thu Jan 13 07:13:23 2011
@@ -284,7 +284,7 @@ public class MoreLikeThisHandler extends
     public MoreLikeThisHelper( SolrParams params, SolrIndexSearcher searcher )
     {
       this.searcher = searcher;
-      this.reader = searcher.getReader();
+      this.reader = searcher.getIndexReader();
       this.uniqueKeyField = searcher.getSchema().getUniqueKeyField();
       this.needDocSet = params.getBool(FacetParams.FACET,false);
       

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/ReplicationHandler.java Thu Jan 13 07:13:23 2011
@@ -281,7 +281,7 @@ public class ReplicationHandler extends 
       IndexCommit indexCommit = delPolicy.getLatestCommit();
 
       if(indexCommit == null) {
-        indexCommit = req.getSearcher().getReader().getIndexCommit();
+        indexCommit = req.getSearcher().getIndexReader().getIndexCommit();
       }
 
       // small race here before the commit point is saved
@@ -481,8 +481,8 @@ public class ReplicationHandler extends 
     long version[] = new long[2];
     RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     try {
-      version[0] = searcher.get().getReader().getIndexCommit().getVersion();
-      version[1] = searcher.get().getReader().getIndexCommit().getGeneration();
+      version[0] = searcher.get().getIndexReader().getIndexCommit().getVersion();
+      version[1] = searcher.get().getIndexReader().getIndexCommit().getGeneration();
     } catch (IOException e) {
       LOG.warn("Unable to get index version : ", e);
     } finally {
@@ -823,7 +823,7 @@ public class ReplicationHandler extends 
         replicateOnStart = true;
         RefCounted<SolrIndexSearcher> s = core.getNewestSearcher(false);
         try {
-          IndexReader reader = s==null ? null : s.get().getReader();
+          IndexReader reader = s==null ? null : s.get().getIndexReader();
           if (reader!=null && reader.getIndexCommit() != null && reader.getIndexCommit().getGeneration() != 1L) {
             try {
               if(replicateOnOptimize){

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/SnapPuller.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/SnapPuller.java Thu Jan 13 07:13:23 2011
@@ -269,7 +269,7 @@ public class SnapPuller {
       RefCounted<SolrIndexSearcher> searcherRefCounted = null;
       try {
         searcherRefCounted = core.getNewestSearcher(false);
-        commit = searcherRefCounted.get().getReader().getIndexCommit();
+        commit = searcherRefCounted.get().getIndexReader().getIndexCommit();
       } finally {
         if (searcherRefCounted != null)
           searcherRefCounted.decref();

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Thu Jan 13 07:13:23 2011
@@ -470,7 +470,7 @@ public class CoreAdminHandler extends Re
         info.add("uptime", System.currentTimeMillis() - core.getStartTime());
         RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
         try {
-          info.add("index", LukeRequestHandler.getIndexInfo(searcher.get().getReader(), false));
+          info.add("index", LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader(), false));
         } finally {
           searcher.decref();
         }

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java Thu Jan 13 07:13:23 2011
@@ -97,7 +97,7 @@ public class LukeRequestHandler extends 
   {    
     IndexSchema schema = req.getSchema();
     SolrIndexSearcher searcher = req.getSearcher();
-    IndexReader reader = searcher.getReader();
+    IndexReader reader = searcher.getIndexReader();
     SolrParams params = req.getParams();
     int numTerms = params.getInt( NUMTERMS, DEFAULT_COUNT );
         
@@ -285,7 +285,7 @@ public class LukeRequestHandler extends 
     final SolrIndexSearcher searcher, final Set<String> fields, final int numTerms ) 
     throws Exception {
 
-    IndexReader reader = searcher.getReader();
+    IndexReader reader = searcher.getIndexReader();
     IndexSchema schema = searcher.getSchema();
     
     // Walk the term enum and keep a priority queue for each map in our set

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/HighlightComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/HighlightComponent.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/HighlightComponent.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/HighlightComponent.java Thu Jan 13 07:13:23 2011
@@ -113,7 +113,7 @@ public class HighlightComponent extends 
       
       if(highlightQuery != null) {
         boolean rewrite = !(Boolean.valueOf(req.getParams().get(HighlightParams.USE_PHRASE_HIGHLIGHTER, "true")) && Boolean.valueOf(req.getParams().get(HighlightParams.HIGHLIGHT_MULTI_TERM, "true")));
-        highlightQuery = rewrite ?  highlightQuery.rewrite(req.getSearcher().getReader()) : highlightQuery;
+        highlightQuery = rewrite ?  highlightQuery.rewrite(req.getSearcher().getIndexReader()) : highlightQuery;
       }
       
       // No highlighting if there is no query -- consider q.alt="*:*

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java Thu Jan 13 07:13:23 2011
@@ -200,7 +200,7 @@ public class QueryElevationComponent ext
           RefCounted<SolrIndexSearcher> searchHolder = null;
           try {
             searchHolder = core.getNewestSearcher(false);
-            IndexReader reader = searchHolder.get().getReader();
+            IndexReader reader = searchHolder.get().getIndexReader();
             getElevationMap( reader, core );
           } finally {
             if (searchHolder != null) searchHolder.decref();
@@ -344,7 +344,7 @@ public class QueryElevationComponent ext
     }
 
     qstr = getAnalyzedQuery(qstr);
-    IndexReader reader = req.getSearcher().getReader();
+    IndexReader reader = req.getSearcher().getIndexReader();
     ElevationObj booster = null;
     try {
       booster = getElevationMap( reader, req.getCore() ).get( qstr );

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java Thu Jan 13 07:13:23 2011
@@ -143,7 +143,7 @@ public class SpellCheckComponent extends
         boolean extendedResults = params.getBool(SPELLCHECK_EXTENDED_RESULTS,
             false);
         NamedList response = new SimpleOrderedMap();
-        IndexReader reader = rb.req.getSearcher().getReader();
+        IndexReader reader = rb.req.getSearcher().getIndexReader();
         boolean collate = params.getBool(SPELLCHECK_COLLATE, false);
         float accuracy = params.getFloat(SPELLCHECK_ACCURACY, Float.MIN_VALUE);
         SolrParams customParams = getCustomParams(getDictionaryName(params), params, shardRequest);
@@ -678,7 +678,7 @@ public class SpellCheckComponent extends
         if (buildOnCommit)  {
           buildSpellIndex(newSearcher);
         } else if (buildOnOptimize) {
-          if (newSearcher.getReader().isOptimized())  {
+          if (newSearcher.getIndexReader().isOptimized())  {
             buildSpellIndex(newSearcher);
           } else  {
             LOG.info("Index is not optimized therefore skipping building spell check index for: " + checker.getDictionaryName());

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/StatsComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/StatsComponent.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/StatsComponent.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/StatsComponent.java Thu Jan 13 07:13:23 2011
@@ -248,7 +248,7 @@ class SimpleStats {
 
     FieldCache.DocTermsIndex si = null;
     try {
-      si = FieldCache.DEFAULT.getTermsIndex(searcher.getReader(), fieldName);
+      si = FieldCache.DEFAULT.getTermsIndex(searcher.getIndexReader(), fieldName);
     } 
     catch (IOException e) {
       throw new RuntimeException( "failed to open field cache for: "+fieldName, e );
@@ -263,7 +263,7 @@ class SimpleStats {
     for( String f : facet ) {
       ft = searcher.getSchema().getFieldType(f);
       try {
-        si = FieldCache.DEFAULT.getTermsIndex(searcher.getReader(), f);
+        si = FieldCache.DEFAULT.getTermsIndex(searcher.getIndexReader(), f);
       } 
       catch (IOException e) {
         throw new RuntimeException( "failed to open field cache for: "+f, e );

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/TermVectorComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/TermVectorComponent.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/TermVectorComponent.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/handler/component/TermVectorComponent.java Thu Jan 13 07:13:23 2011
@@ -174,7 +174,7 @@ public class TermVectorComponent extends
     }
     SolrIndexSearcher searcher = rb.req.getSearcher();
 
-    IndexReader reader = searcher.getReader();
+    IndexReader reader = searcher.getIndexReader();
     //the TVMapper is a TermVectorMapper which can be used to optimize loading of Term Vectors
     SchemaField keyField = schema.getUniqueKeyField();
     String uniqFieldName = null;

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java Thu Jan 13 07:13:23 2011
@@ -216,7 +216,7 @@ public class DefaultSolrHighlighter exte
   private Scorer getQueryScorer(Query query, String fieldName, SolrQueryRequest request) {
      boolean reqFieldMatch = request.getParams().getFieldBool(fieldName, HighlightParams.FIELD_MATCH, false);
      if (reqFieldMatch) {
-        return new QueryTermScorer(query, request.getSearcher().getReader(), fieldName);
+        return new QueryTermScorer(query, request.getSearcher().getIndexReader(), fieldName);
      }
      else {
         return new QueryTermScorer(query);
@@ -415,7 +415,7 @@ public class DefaultSolrHighlighter exte
 
     TermOffsetsTokenStream tots = null; // to be non-null iff we're using TermOffsets optimization
     try {
-        TokenStream tvStream = TokenSources.getTokenStream(searcher.getReader(), docId, fieldName);
+        TokenStream tvStream = TokenSources.getTokenStream(searcher.getIndexReader(), docId, fieldName);
         if (tvStream != null) {
           tots = new TermOffsetsTokenStream(tvStream);
         }
@@ -503,7 +503,7 @@ public class DefaultSolrHighlighter exte
       String fieldName ) throws IOException {
     SolrParams params = req.getParams(); 
     SolrFragmentsBuilder solrFb = getSolrFragmentsBuilder( fieldName, params );
-    String[] snippets = highlighter.getBestFragments( fieldQuery, req.getSearcher().getReader(), docId, fieldName,
+    String[] snippets = highlighter.getBestFragments( fieldQuery, req.getSearcher().getIndexReader(), docId, fieldName,
         params.getFieldInt( fieldName, HighlightParams.FRAGSIZE, 100 ),
         params.getFieldInt( fieldName, HighlightParams.SNIPPETS, 1 ),
         getFragListBuilder( fieldName, params ),

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java Thu Jan 13 07:13:23 2011
@@ -413,7 +413,7 @@ public class SimpleFacets {
     FieldType ft = searcher.getSchema().getFieldType(fieldName);
     NamedList<Integer> res = new NamedList<Integer>();
 
-    FieldCache.DocTermsIndex si = FieldCache.DEFAULT.getTermsIndex(searcher.getReader(), fieldName);
+    FieldCache.DocTermsIndex si = FieldCache.DEFAULT.getTermsIndex(searcher.getIndexReader(), fieldName);
 
     final BytesRef prefixRef;
     if (prefix == null) {
@@ -611,7 +611,7 @@ public class SimpleFacets {
 
 
     IndexSchema schema = searcher.getSchema();
-    IndexReader r = searcher.getReader();
+    IndexReader r = searcher.getIndexReader();
     FieldType ft = schema.getFieldType(field);
 
     boolean sortByCount = sort.equals("count") || sort.equals("true");

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/request/UnInvertedField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/request/UnInvertedField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/request/UnInvertedField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/request/UnInvertedField.java Thu Jan 13 07:13:23 2011
@@ -192,7 +192,7 @@ public class UnInvertedField {
   private void uninvert(SolrIndexSearcher searcher) throws IOException {
     long startTime = System.currentTimeMillis();
 
-    IndexReader reader = searcher.getReader();
+    IndexReader reader = searcher.getIndexReader();
     int maxDoc = reader.maxDoc();
 
     int[] index = new int[maxDoc];       // immediate term numbers, or the index into the byte[] representing the last number
@@ -481,7 +481,7 @@ public class UnInvertedField {
       int startTerm = 0;
       int endTerm = numTermsInField;  // one past the end
 
-      NumberedTermsEnum te = ti.getEnumerator(searcher.getReader());
+      NumberedTermsEnum te = ti.getEnumerator(searcher.getIndexReader());
       if (prefix != null && prefix.length() > 0) {
         BytesRef prefixBr = new BytesRef(prefix);
         te.skipTo(prefixBr);
@@ -719,7 +719,7 @@ public class UnInvertedField {
     for (String f : facet) {
       FieldType facet_ft = searcher.getSchema().getFieldType(f);
       try {
-        si = FieldCache.DEFAULT.getTermsIndex(searcher.getReader(), f);
+        si = FieldCache.DEFAULT.getTermsIndex(searcher.getIndexReader(), f);
       }
       catch (IOException e) {
         throw new RuntimeException("failed to open field cache for: " + f, e);
@@ -731,7 +731,7 @@ public class UnInvertedField {
     final int[] index = this.index;
     final int[] counts = new int[numTermsInField];//keep track of the number of times we see each word in the field for all the documents in the docset
 
-    NumberedTermsEnum te = ti.getEnumerator(searcher.getReader());
+    NumberedTermsEnum te = ti.getEnumerator(searcher.getIndexReader());
 
 
     boolean doNegative = false;

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/DateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/DateField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/DateField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/DateField.java Thu Jan 13 07:13:23 2011
@@ -18,7 +18,7 @@
 package org.apache.solr.schema;
 
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermRangeQuery;
@@ -427,8 +427,8 @@ class DateFieldSource extends FieldCache
     return "date(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
-    return new StringIndexDocValues(this, reader, field) {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+    return new StringIndexDocValues(this, readerContext, field) {
       protected String toTerm(String readableValue) {
         // needed for frange queries to work properly
         return ft.toInternal(readableValue);

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/LatLonType.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/LatLonType.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/LatLonType.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/LatLonType.java Thu Jan 13 07:13:23 2011
@@ -20,7 +20,6 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.search.*;
 import org.apache.lucene.spatial.DistanceUtils;
 import org.apache.lucene.spatial.tier.InvalidGeoException;
@@ -372,7 +371,7 @@ class SpatialDistanceQuery extends Query
 
     @Override
     public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
-      return new SpatialScorer(getSimilarity(searcher), context.reader, this);
+      return new SpatialScorer(getSimilarity(searcher), context, this);
     }
 
     @Override
@@ -405,15 +404,15 @@ class SpatialDistanceQuery extends Query
     int lastDistDoc;
     double lastDist;
 
-    public SpatialScorer(Similarity similarity, IndexReader reader, SpatialWeight w) throws IOException {
+    public SpatialScorer(Similarity similarity, AtomicReaderContext readerContext, SpatialWeight w) throws IOException {
       super(similarity);
       this.weight = w;
       this.qWeight = w.getValue();
-      this.reader = reader;
+      this.reader = readerContext.reader;
       this.maxDoc = reader.maxDoc();
-      this.delDocs = reader.hasDeletions() ? MultiFields.getDeletedDocs(reader) : null;
-      latVals = latSource.getValues(weight.latContext, reader);
-      lonVals = lonSource.getValues(weight.lonContext, reader);
+      this.delDocs = reader.getDeletedDocs();
+      latVals = latSource.getValues(weight.latContext, readerContext);
+      lonVals = lonSource.getValues(weight.lonContext, readerContext);
 
       this.lonMin = SpatialDistanceQuery.this.lonMin;
       this.lonMax = SpatialDistanceQuery.this.lonMax;

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/RandomSortField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/RandomSortField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/RandomSortField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/RandomSortField.java Thu Jan 13 07:13:23 2011
@@ -24,11 +24,11 @@ import org.apache.lucene.document.Fielda
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.*;
+import org.apache.lucene.util.ReaderUtil;
 import org.apache.solr.response.TextResponseWriter;
 import org.apache.solr.search.QParser;
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.ValueSource;
-import org.apache.solr.search.SolrIndexReader;
 
 /**
  * Utility Field used for random sorting.  It should not be passed a value.
@@ -78,17 +78,11 @@ public class RandomSortField extends Fie
    * Given a field name and an IndexReader, get a random hash seed.  
    * Using dynamic fields, you can force the random order to change 
    */
-  private static int getSeed(String fieldName, IndexReader r) {
-    SolrIndexReader top = (SolrIndexReader)r;
-    int base=0;
-    while (top.getParent() != null) {
-      base += top.getBase();
-      top = top.getParent();
-    }
-
+  private static int getSeed(String fieldName, AtomicReaderContext context) {
+    final IndexReader top = ReaderUtil.getTopLevelContext(context).reader;
     // calling getVersion() on a segment will currently give you a null pointer exception, so
     // we use the top-level reader.
-    return fieldName.hashCode() + base + (int)top.getVersion();
+    return fieldName.hashCode() + context.docBase + (int)top.getVersion();
   }
   
   @Override
@@ -129,7 +123,7 @@ public class RandomSortField extends Fie
         }
 
         public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
-          seed = getSeed(fieldname, context.reader);
+          seed = getSeed(fieldname, context);
           return this;
         }
 
@@ -155,9 +149,9 @@ public class RandomSortField extends Fie
     }
 
     @Override
-    public DocValues getValues(Map context, final IndexReader reader) throws IOException {
+    public DocValues getValues(Map context, final AtomicReaderContext readerContext) throws IOException {
       return new DocValues() {
-          private final int seed = getSeed(field, reader);
+          private final int seed = getSeed(field, readerContext);
           @Override
           public float floatVal(int doc) {
             return (float)hash(doc+seed);

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableDoubleField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableDoubleField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableDoubleField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableDoubleField.java Thu Jan 13 07:13:23 2011
@@ -28,7 +28,7 @@ import org.apache.solr.search.function.F
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.StringIndexDocValues;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.solr.util.ByteUtils;
 import org.apache.solr.util.NumberUtils;
 import org.apache.solr.response.TextResponseWriter;
@@ -99,10 +99,10 @@ class SortableDoubleFieldSource extends 
     return "sdouble(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     final double def = defVal;
 
-    return new StringIndexDocValues(this, reader, field) {
+    return new StringIndexDocValues(this, readerContext, field) {
       private final BytesRef spare = new BytesRef();
 
       protected String toTerm(String readableValue) {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableFloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableFloatField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableFloatField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableFloatField.java Thu Jan 13 07:13:23 2011
@@ -28,7 +28,7 @@ import org.apache.solr.search.function.F
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.StringIndexDocValues;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.solr.util.ByteUtils;
 import org.apache.solr.util.NumberUtils;
 import org.apache.solr.response.TextResponseWriter;
@@ -99,10 +99,10 @@ class SortableFloatFieldSource extends F
     return "sfloat(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     final float def = defVal;
 
-    return new StringIndexDocValues(this, reader, field) {
+    return new StringIndexDocValues(this, readerContext, field) {
       private final BytesRef spare = new BytesRef();
 
       protected String toTerm(String readableValue) {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableIntField.java Thu Jan 13 07:13:23 2011
@@ -28,7 +28,7 @@ import org.apache.solr.search.function.F
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.StringIndexDocValues;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.solr.util.ByteUtils;
 import org.apache.solr.util.NumberUtils;
 import org.apache.solr.response.TextResponseWriter;
@@ -101,10 +101,10 @@ class SortableIntFieldSource extends Fie
     return "sint(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     final int def = defVal;
 
-    return new StringIndexDocValues(this, reader, field) {
+    return new StringIndexDocValues(this, readerContext, field) {
       private final BytesRef spare = new BytesRef();
 
       protected String toTerm(String readableValue) {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/SortableLongField.java Thu Jan 13 07:13:23 2011
@@ -28,7 +28,7 @@ import org.apache.solr.search.function.F
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.StringIndexDocValues;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.solr.util.ByteUtils;
 import org.apache.solr.util.NumberUtils;
 import org.apache.solr.response.TextResponseWriter;
@@ -100,10 +100,10 @@ class SortableLongFieldSource extends Fi
     return "slong(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     final long def = defVal;
 
-    return new StringIndexDocValues(this, reader, field) {
+    return new StringIndexDocValues(this, readerContext, field) {
       private final BytesRef spare = new BytesRef();
 
       protected String toTerm(String readableValue) {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/schema/StrFieldSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.solr.schema;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.search.function.DocValues;
 import org.apache.solr.search.function.FieldCacheSource;
@@ -36,8 +36,8 @@ public class StrFieldSource extends Fiel
     return "str(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
-    return new StringIndexDocValues(this, reader, field) {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+    return new StringIndexDocValues(this, readerContext, field) {
       protected String toTerm(String readableValue) {
         return readableValue;
       }

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java Thu Jan 13 07:13:23 2011
@@ -688,7 +688,7 @@ class TopGroupCollector extends GroupCol
   @Override
   public void setNextReader(AtomicReaderContext readerContext) throws IOException {
     this.docBase = readerContext.docBase;
-    docValues = vs.getValues(context, readerContext.reader);
+    docValues = vs.getValues(context, readerContext);
     filler = docValues.getValueFiller();
     mval = filler.getValue();
     for (int i=0; i<comparators.length; i++)
@@ -762,7 +762,7 @@ class Phase2GroupCollector extends Colle
   @Override
   public void setNextReader(AtomicReaderContext readerContext) throws IOException {
     this.docBase = readerContext.docBase;
-    docValues = vs.getValues(context, readerContext.reader);
+    docValues = vs.getValues(context, readerContext);
     filler = docValues.getValueFiller();
     mval = filler.getValue();
     for (SearchGroupDocs group : groupMap.values())

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrFilter.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrFilter.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrFilter.java Thu Jan 13 07:13:23 2011
@@ -22,7 +22,7 @@ import org.apache.lucene.search.IndexSea
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.index.IndexReader.ReaderContext;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 
 import java.util.Map;
 import java.io.IOException;
@@ -39,7 +39,7 @@ public abstract class SolrFilter extends
    * The context object will be passed to getDocIdSet() where this info can be retrieved. */
   public abstract void createWeight(Map context, IndexSearcher searcher) throws IOException;
   
-  public abstract DocIdSet getDocIdSet(Map context, ReaderContext readerContext) throws IOException;
+  public abstract DocIdSet getDocIdSet(Map context, AtomicReaderContext readerContext) throws IOException;
 
   @Override
   public DocIdSet getDocIdSet(AtomicReaderContext context) throws IOException {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java Thu Jan 13 07:13:23 2011
@@ -68,7 +68,7 @@ public class SolrIndexSearcher extends I
   private long openTime = System.currentTimeMillis();
   private long registerTime = 0;
   private long warmupTime = 0;
-  private final SolrIndexReader reader;
+  private final IndexReader reader;
   private final boolean closeReader;
 
   private final int queryResultWindowSize;
@@ -117,28 +117,15 @@ public class SolrIndexSearcher extends I
     this(core, schema,name,r, false, enableCache);
   }
 
-  private static SolrIndexReader wrap(IndexReader r) {
-    SolrIndexReader sir;
-    // wrap the reader
-    if (!(r instanceof SolrIndexReader)) {
-      sir = new SolrIndexReader(r, null, 0);
-      sir.associateInfo(null);
-    } else {
-      sir = (SolrIndexReader)r;
-    }
-    return sir;
-  }
 
   public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache) {
-    super(wrap(r));
-    this.reader = (SolrIndexReader)super.getIndexReader();
+    super(r);
+    this.reader = getIndexReader();
     this.core = core;
     this.schema = schema;
     this.name = "Searcher@" + Integer.toHexString(hashCode()) + (name!=null ? " "+name : "");
     log.info("Opening " + this.name);
 
-    SolrIndexReader.setSearcher(reader, this);
-
     if (r.directory() instanceof FSDirectory) {
       FSDirectory fsDirectory = (FSDirectory) r.directory();
       indexDir = fsDirectory.getDirectory().getAbsolutePath();
@@ -247,8 +234,6 @@ public class SolrIndexSearcher extends I
     numCloses.incrementAndGet();
   }
 
-  /** Direct access to the IndexReader used by this searcher */
-  public SolrIndexReader getReader() { return reader; }
   /** Direct access to the IndexSchema for use with this searcher */
   public IndexSchema getSchema() { return schema; }
   

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java Thu Jan 13 07:13:23 2011
@@ -16,7 +16,7 @@
  */
 package org.apache.solr.search;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.Query;
@@ -710,7 +710,7 @@ class LongConstValueSource extends Const
     return "const(" + constant + ")";
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     return new DocValues() {
       public float floatVal(int doc) {
         return fv;
@@ -807,8 +807,8 @@ abstract class DoubleParser extends Name
     }
 
     @Override
-    public DocValues getValues(Map context, IndexReader reader) throws IOException {
-      final DocValues vals =  source.getValues(context, reader);
+    public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+      final DocValues vals =  source.getValues(context, readerContext);
       return new DocValues() {
         public float floatVal(int doc) {
           return (float)doubleVal(doc);
@@ -862,9 +862,9 @@ abstract class Double2Parser extends Nam
       return name() + "(" + a.description() + "," + b.description() + ")";
     }
 
-    public DocValues getValues(Map context, IndexReader reader) throws IOException {
-      final DocValues aVals =  a.getValues(context, reader);
-      final DocValues bVals =  b.getValues(context, reader);
+    public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+      final DocValues aVals =  a.getValues(context, readerContext);
+      final DocValues bVals =  b.getValues(context, readerContext);
       return new DocValues() {
         public float floatVal(int doc) {
           return (float)doubleVal(doc);

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/BoostedQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/BoostedQuery.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/BoostedQuery.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/BoostedQuery.java Thu Jan 13 07:13:23 2011
@@ -96,7 +96,7 @@ public class BoostedQuery extends Query 
       if(subQueryScorer == null) {
         return null;
       }
-      return new BoostedQuery.CustomScorer(getSimilarity(searcher), searcher, context.reader, this, subQueryScorer, boostVal);
+      return new BoostedQuery.CustomScorer(getSimilarity(searcher), context, this, subQueryScorer, boostVal);
     }
 
     @Override
@@ -105,7 +105,7 @@ public class BoostedQuery extends Query 
       if (!subQueryExpl.isMatch()) {
         return subQueryExpl;
       }
-      DocValues vals = boostVal.getValues(fcontext, readerContext.reader);
+      DocValues vals = boostVal.getValues(fcontext, readerContext);
       float sc = subQueryExpl.getValue() * vals.floatVal(doc);
       Explanation res = new ComplexExplanation(
         true, sc, BoostedQuery.this.toString() + ", product of:");
@@ -121,18 +121,16 @@ public class BoostedQuery extends Query 
     private final float qWeight;
     private final Scorer scorer;
     private final DocValues vals;
-    private final IndexReader reader;
-    private final IndexSearcher searcher;
+    private final AtomicReaderContext readerContext;
 
-    private CustomScorer(Similarity similarity, IndexSearcher searcher, IndexReader reader, BoostedQuery.BoostedWeight w,
+    private CustomScorer(Similarity similarity, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w,
         Scorer scorer, ValueSource vs) throws IOException {
       super(similarity);
       this.weight = w;
       this.qWeight = w.getValue();
       this.scorer = scorer;
-      this.reader = reader;
-      this.searcher = searcher; // for explain
-      this.vals = vs.getValues(weight.fcontext, reader);
+      this.readerContext = readerContext;
+      this.vals = vs.getValues(weight.fcontext, readerContext);
     }
 
     @Override
@@ -161,7 +159,7 @@ public class BoostedQuery extends Query 
     }
 
     public Explanation explain(int doc) throws IOException {
-      Explanation subQueryExpl = weight.qWeight.explain(ValueSource.readerToContext(weight.fcontext,reader) ,doc);
+      Explanation subQueryExpl = weight.qWeight.explain(readerContext ,doc);
       if (!subQueryExpl.isMatch()) {
         return subQueryExpl;
       }

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ByteFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ByteFieldSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ByteFieldSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ByteFieldSource.java Thu Jan 13 07:13:23 2011
@@ -16,7 +16,7 @@ package org.apache.solr.search.function;
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.cache.ByteValuesCreator;
 import org.apache.lucene.search.cache.CachedArray.ByteValues;
 
@@ -41,8 +41,8 @@ public class ByteFieldSource extends Num
     return "byte(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
-    final ByteValues vals = cache.getBytes(reader, field, creator);
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+    final ByteValues vals = cache.getBytes(readerContext.reader, field, creator);
     final byte[] arr = vals.values;
     
     return new DocValues() {

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ConstValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ConstValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ConstValueSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/ConstValueSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.solr.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 
 import java.io.IOException;
 import java.util.Map;
@@ -38,7 +38,7 @@ public class ConstValueSource extends Co
     return "const(" + constant + ")";
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     return new DocValues() {
       public float floatVal(int doc) {
         return constant;

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DocFreqValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DocFreqValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DocFreqValueSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DocFreqValueSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.solr.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.util.BytesRef;
@@ -239,7 +239,7 @@ public class DocFreqValueSource extends 
   }
 
   @Override
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     IndexSearcher searcher = (IndexSearcher)context.get("searcher");
     int docfreq = searcher.docFreq(new Term(indexedField, indexedBytes));
     return new ConstIntDocValues(docfreq, this);

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleConstValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleConstValueSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleConstValueSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleConstValueSource.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.solr.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 
 import java.io.IOException;
 import java.util.Map;
@@ -37,7 +37,7 @@ public class DoubleConstValueSource exte
     return "const(" + constant + ")";
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
     return new DocValues() {
       public float floatVal(int doc) {
         return fv;

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java Thu Jan 13 07:13:23 2011
@@ -18,6 +18,7 @@
 package org.apache.solr.search.function;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.search.cache.DoubleValuesCreator;
 import org.apache.lucene.search.cache.CachedArray.DoubleValues;
@@ -45,8 +46,8 @@ public class DoubleFieldSource extends N
     return "double(" + field + ')';
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
-    final DoubleValues vals = cache.getDoubles(reader, field, creator);
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+    final DoubleValues vals = cache.getDoubles(readerContext.reader, field, creator);
     final double[] arr = vals.values;
 	final Bits valid = vals.valid;
     

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DualFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DualFloatFunction.java?rev=1058431&r1=1058430&r2=1058431&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DualFloatFunction.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/function/DualFloatFunction.java Thu Jan 13 07:13:23 2011
@@ -17,7 +17,7 @@
 
 package org.apache.solr.search.function;
 
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.IndexSearcher;
 
 import java.io.IOException;
@@ -43,9 +43,9 @@ public abstract class DualFloatFunction 
     return name() + "(" + a.description() + "," + b.description() + ")";
   }
 
-  public DocValues getValues(Map context, IndexReader reader) throws IOException {
-    final DocValues aVals =  a.getValues(context, reader);
-    final DocValues bVals =  b.getValues(context, reader);
+  public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+    final DocValues aVals =  a.getValues(context, readerContext);
+    final DocValues bVals =  b.getValues(context, readerContext);
     return new DocValues() {
       public float floatVal(int doc) {
 	return func(doc, aVals, bVals);



Mime
View raw message