This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch ishan/upgrade-to-lucene-10
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/ishan/upgrade-to-lucene-10 by 
this push:
     new 494b6b48037 make solr/modules/ltr/src/java compile
494b6b48037 is described below

commit 494b6b48037aa0e24e0444e66d3ffd5b1fe67af7
Author: Christine Poerschke <[email protected]>
AuthorDate: Wed Jan 29 18:44:35 2025 +0000

    make solr/modules/ltr/src/java compile
---
 .../src/java/org/apache/solr/ltr/LTRRescorer.java  |  8 +++---
 .../java/org/apache/solr/ltr/LTRScoringQuery.java  | 30 +++++++++++++---------
 .../java/org/apache/solr/ltr/feature/Feature.java  | 17 +++++++++---
 .../solr/ltr/feature/FieldLengthFeature.java       |  3 +--
 .../apache/solr/ltr/feature/FieldValueFeature.java |  3 +--
 .../solr/ltr/feature/OriginalScoreFeature.java     |  3 +--
 .../org/apache/solr/ltr/feature/SolrFeature.java   |  3 +--
 .../org/apache/solr/ltr/feature/ValueFeature.java  |  3 +--
 .../ltr/interleaving/LTRInterleavingRescorer.java  |  4 +--
 9 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java
index a6b45342d9e..a21c107438c 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java
@@ -123,7 +123,7 @@ public class LTRRescorer extends Rescorer {
       return firstPassTopDocs;
     }
     final ScoreDoc[] firstPassResults = 
getFirstPassDocsRanked(firstPassTopDocs);
-    topN = Math.toIntExact(Math.min(topN, firstPassTopDocs.totalHits.value));
+    topN = Math.toIntExact(Math.min(topN, firstPassTopDocs.totalHits.value()));
 
     final ScoreDoc[] reranked = rerank(searcher, topN, firstPassResults);
 
@@ -148,7 +148,7 @@ public class LTRRescorer extends Rescorer {
     final ScoreDoc[] hits = firstPassTopDocs.scoreDocs;
     Arrays.sort(hits, docComparator);
 
-    assert firstPassTopDocs.totalHits.relation == TotalHits.Relation.EQUAL_TO;
+    assert firstPassTopDocs.totalHits.relation() == 
TotalHits.Relation.EQUAL_TO;
     return hits;
   }
 
@@ -180,7 +180,7 @@ public class LTRRescorer extends Rescorer {
       // We advanced to another segment
       if (readerContext != null) {
         docBase = readerContext.docBase;
-        scorer = modelWeight.scorer(readerContext);
+        scorer = modelWeight.modelScorer(readerContext);
       }
       if (scoreSingleHit(topN, docBase, hitUpto, hit, docID, scorer, 
reranked)) {
         logSingleHit(indexSearcher, modelWeight, hit.doc, scoringQuery);
@@ -299,7 +299,7 @@ public class LTRRescorer extends Rescorer {
     final int n = ReaderUtil.subIndex(docid, leafContexts);
     final LeafReaderContext atomicContext = leafContexts.get(n);
     final int deBasedDoc = docid - atomicContext.docBase;
-    final LTRScoringQuery.ModelWeight.ModelScorer r = 
modelWeight.scorer(atomicContext);
+    final LTRScoringQuery.ModelWeight.ModelScorer r = 
modelWeight.modelScorer(atomicContext);
     if ((r == null) || (r.iterator().advance(deBasedDoc) != deBasedDoc)) {
       return new LTRScoringQuery.FeatureInfo[0];
     } else {
diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
index 8731cccb346..6174552138b 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/LTRScoringQuery.java
@@ -40,12 +40,14 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryVisitor;
 import org.apache.lucene.search.ScoreMode;
 import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.ScorerSupplier;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.solr.ltr.feature.Feature;
 import org.apache.solr.ltr.model.LTRScoringModel;
 import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.util.SolrDefaultScorerSupplier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -465,7 +467,7 @@ public class LTRScoringQuery extends Query implements 
Accountable {
         Explanation e = 
ltrScoringModel.getNormalizerExplanation(explanations[f.getIndex()], idx);
         featureExplanations.add(e);
       }
-      final ModelScorer bs = scorer(context);
+      final ModelScorer bs = modelScorer(context);
       bs.iterator().advance(doc);
 
       final float finalScore = bs.score();
@@ -485,12 +487,16 @@ public class LTRScoringQuery extends Query implements 
Accountable {
     }
 
     @Override
-    public ModelScorer scorer(LeafReaderContext context) throws IOException {
+    public ScorerSupplier scorerSupplier(LeafReaderContext context) throws 
IOException {
+      return new SolrDefaultScorerSupplier(modelScorer(context));
+    }
+
+    public ModelScorer modelScorer(LeafReaderContext context) throws 
IOException {
 
       final List<Feature.FeatureWeight.FeatureScorer> featureScorers =
           new 
ArrayList<Feature.FeatureWeight.FeatureScorer>(extractedFeatureWeights.length);
       for (final Feature.FeatureWeight featureWeight : 
extractedFeatureWeights) {
-        final Feature.FeatureWeight.FeatureScorer scorer = 
featureWeight.scorer(context);
+        final Feature.FeatureWeight.FeatureScorer scorer = 
featureWeight.featureScorer(context);
         if (scorer != null) {
           featureScorers.add(scorer);
         }
@@ -518,7 +524,6 @@ public class LTRScoringQuery extends Query implements 
Accountable {
       }
 
       public ModelScorer(Weight weight, 
List<Feature.FeatureWeight.FeatureScorer> featureScorers) {
-        super(weight);
         docInfo = new DocInfo();
         for (final Feature.FeatureWeight.FeatureScorer subScorer : 
featureScorers) {
           subScorer.setDocInfo(docInfo);
@@ -564,14 +569,13 @@ public class LTRScoringQuery extends Query implements 
Accountable {
         private int activeDoc = -1;
 
         private SparseModelScorer(
-            Weight weight, List<Feature.FeatureWeight.FeatureScorer> 
featureScorers) {
-          super(weight);
+            Weight unusedWeight, List<Feature.FeatureWeight.FeatureScorer> 
featureScorers) {
           if (featureScorers.size() <= 1) {
             throw new IllegalArgumentException("There must be at least 2 
subScorers");
           }
           subScorers = new DisiPriorityQueue(featureScorers.size());
           for (final Scorer scorer : featureScorers) {
-            final DisiWrapper w = new DisiWrapper(scorer);
+            final DisiWrapper w = new DisiWrapper(scorer, false /* impacts */);
             subScorers.add(w);
           }
 
@@ -594,8 +598,9 @@ public class LTRScoringQuery extends Query implements 
Accountable {
           reset();
           if (activeDoc == targetDoc) {
             for (DisiWrapper w = topList; w != null; w = w.next) {
-              final Scorer subScorer = w.scorer;
-              Feature.FeatureWeight scFW = (Feature.FeatureWeight) 
subScorer.getWeight();
+              final Feature.FeatureWeight.FeatureScorer subScorer =
+                  (Feature.FeatureWeight.FeatureScorer) w.scorer;
+              Feature.FeatureWeight scFW = subScorer.getWeight();
               final int featureId = scFW.getIndex();
               featuresInfo[featureId].setValue(subScorer.score());
               featuresInfo[featureId].setUsed(true);
@@ -662,8 +667,7 @@ public class LTRScoringQuery extends Query implements 
Accountable {
         private final List<Feature.FeatureWeight.FeatureScorer> featureScorers;
 
         private DenseModelScorer(
-            Weight weight, List<Feature.FeatureWeight.FeatureScorer> 
featureScorers) {
-          super(weight);
+            Weight unusedWeight, List<Feature.FeatureWeight.FeatureScorer> 
featureScorers) {
           this.featureScorers = featureScorers;
         }
 
@@ -680,7 +684,9 @@ public class LTRScoringQuery extends Query implements 
Accountable {
             for (final Scorer scorer : featureScorers) {
               if (scorer.docID() == activeDoc) {
                 freq++;
-                Feature.FeatureWeight scFW = (Feature.FeatureWeight) 
scorer.getWeight();
+                Feature.FeatureWeight.FeatureScorer featureScorer =
+                    (Feature.FeatureWeight.FeatureScorer) scorer;
+                Feature.FeatureWeight scFW = featureScorer.getWeight();
                 final int featureId = scFW.getIndex();
                 featuresInfo[featureId].setValue(scorer.score());
                 featuresInfo[featureId].setUsed(true);
diff --git a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/Feature.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
index f3fe61c3fb5..00f3854ba05 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
@@ -26,6 +26,7 @@ import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryVisitor;
 import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.ScorerSupplier;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.RamUsageEstimator;
@@ -33,6 +34,7 @@ import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.ltr.DocInfo;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.macro.MacroExpander;
+import org.apache.solr.util.SolrDefaultScorerSupplier;
 import org.apache.solr.util.SolrPluginUtils;
 
 /**
@@ -267,8 +269,12 @@ public abstract class Feature extends Query implements 
Accountable {
       return Feature.this.getDefaultValue();
     }
 
+    public abstract FeatureScorer featureScorer(LeafReaderContext context) 
throws IOException;
+
     @Override
-    public abstract FeatureScorer scorer(LeafReaderContext context) throws 
IOException;
+    public ScorerSupplier scorerSupplier(LeafReaderContext context) throws 
IOException {
+      return new SolrDefaultScorerSupplier(featureScorer(context));
+    }
 
     @Override
     public boolean isCacheable(LeafReaderContext ctx) {
@@ -277,7 +283,7 @@ public abstract class Feature extends Query implements 
Accountable {
 
     @Override
     public Explanation explain(LeafReaderContext context, int doc) throws 
IOException {
-      final FeatureScorer r = scorer(context);
+      final FeatureScorer r = featureScorer(context);
       float score = getDefaultValue();
       if (r != null) {
         r.iterator().advance(doc);
@@ -306,10 +312,11 @@ public abstract class Feature extends Query implements 
Accountable {
 
       protected final String name;
       private DocInfo docInfo;
+      private final Feature.FeatureWeight weight;
       protected final DocIdSetIterator itr;
 
       public FeatureScorer(Feature.FeatureWeight weight, DocIdSetIterator itr) 
{
-        super(weight);
+        this.weight = weight;
         this.itr = itr;
         name = weight.getName();
         docInfo = null;
@@ -332,6 +339,10 @@ public abstract class Feature extends Query implements 
Accountable {
         return itr.docID();
       }
 
+      public Feature.FeatureWeight getWeight() {
+        return weight;
+      }
+
       @Override
       public DocIdSetIterator iterator() {
         return itr;
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldLengthFeature.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldLengthFeature.java
index e5c565d9dc0..54f20ffb90e 100644
--- 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldLengthFeature.java
+++ 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldLengthFeature.java
@@ -113,8 +113,7 @@ public class FieldLengthFeature extends Feature {
       super(FieldLengthFeature.this, searcher, request, originalQuery, efi);
     }
 
-    @Override
-    public FeatureScorer scorer(LeafReaderContext context) throws IOException {
+    public FeatureScorer featureScorer(LeafReaderContext context) throws 
IOException {
       NumericDocValues norms = context.reader().getNormValues(field);
       if (norms == null) {
         return new ValueFeatureScorer(
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java
index 02e2fabb5bf..15ad93d43bd 100644
--- 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java
+++ 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/FieldValueFeature.java
@@ -148,8 +148,7 @@ public class FieldValueFeature extends Feature {
      * @return FeatureScorer for the current segment and field
      * @throws IOException as defined by abstract class Feature
      */
-    @Override
-    public FeatureScorer scorer(LeafReaderContext context) throws IOException {
+    public FeatureScorer featureScorer(LeafReaderContext context) throws 
IOException {
       if (schemaField != null
           && (!schemaField.stored() || useDocValuesForStored)
           && schemaField.hasDocValues()) {
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/OriginalScoreFeature.java
 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/OriginalScoreFeature.java
index e2b4e8d93ad..2b15685bba1 100644
--- 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/OriginalScoreFeature.java
+++ 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/OriginalScoreFeature.java
@@ -84,8 +84,7 @@ public class OriginalScoreFeature extends Feature {
       return "OriginalScoreFeature [query:" + originalQuery.toString() + "]";
     }
 
-    @Override
-    public FeatureScorer scorer(LeafReaderContext context) throws IOException {
+    public FeatureScorer featureScorer(LeafReaderContext context) throws 
IOException {
 
       final Scorer originalScorer = w.scorer(context);
       return new OriginalScoreScorer(this, originalScorer);
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/SolrFeature.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/SolrFeature.java
index 5c696b6f96f..9a5ca4bd94c 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/SolrFeature.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/SolrFeature.java
@@ -224,8 +224,7 @@ public class SolrFeature extends Feature {
       }
     }
 
-    @Override
-    public FeatureScorer scorer(LeafReaderContext context) throws IOException {
+    public FeatureScorer featureScorer(LeafReaderContext context) throws 
IOException {
       Scorer solrScorer = solrQueryWeight.scorer(context);
       if (solrScorer == null) {
         return null;
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/ValueFeature.java 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/ValueFeature.java
index 2c13262c84d..5781f658af2 100644
--- a/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/ValueFeature.java
+++ b/solr/modules/ltr/src/java/org/apache/solr/ltr/feature/ValueFeature.java
@@ -140,8 +140,7 @@ public class ValueFeature extends Feature {
       }
     }
 
-    @Override
-    public FeatureScorer scorer(LeafReaderContext context) throws IOException {
+    public FeatureScorer featureScorer(LeafReaderContext context) throws 
IOException {
       if (featureValue != null) {
         return new ValueFeatureScorer(
             this, featureValue, 
DocIdSetIterator.all(DocIdSetIterator.NO_MORE_DOCS));
diff --git 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/interleaving/LTRInterleavingRescorer.java
 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/interleaving/LTRInterleavingRescorer.java
index f0c90558eeb..78803afd933 100644
--- 
a/solr/modules/ltr/src/java/org/apache/solr/ltr/interleaving/LTRInterleavingRescorer.java
+++ 
b/solr/modules/ltr/src/java/org/apache/solr/ltr/interleaving/LTRInterleavingRescorer.java
@@ -72,7 +72,7 @@ public class LTRInterleavingRescorer extends LTRRescorer {
       System.arraycopy(
           firstPassTopDocs.scoreDocs, 0, firstPassResults, 0, 
firstPassTopDocs.scoreDocs.length);
     }
-    topN = Math.toIntExact(Math.min(topN, firstPassTopDocs.totalHits.value));
+    topN = Math.toIntExact(Math.min(topN, firstPassTopDocs.totalHits.value()));
 
     ScoreDoc[][] reRankedPerModel =
         rerank(searcher, topN, getFirstPassDocsRanked(firstPassTopDocs));
@@ -144,7 +144,7 @@ public class LTRInterleavingRescorer extends LTRRescorer {
         docBase = readerContext.docBase;
         for (int i = 0; i < modelWeights.length; i++) {
           if (modelWeights[i] != null) {
-            scorers[i] = modelWeights[i].scorer(readerContext);
+            scorers[i] = modelWeights[i].modelScorer(readerContext);
           }
         }
       }

Reply via email to