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 f98f7037a7b remove or tweak ScoreAndDoc use
f98f7037a7b is described below
commit f98f7037a7b01d0121da2ac6de3db86251df358b
Author: Christine Poerschke <[email protected]>
AuthorDate: Fri Jan 24 17:02:29 2025 +0000
remove or tweak ScoreAndDoc use
---
.../solr/handler/component/QueryComponent.java | 31 +++++-----------------
.../solr/search/CollapsingQParserPlugin.java | 16 +++++------
.../apache/solr/search/RankQueryTestPlugin.java | 27 +++++--------------
3 files changed, 18 insertions(+), 56 deletions(-)
diff --git
a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index ce9aa546484..f2e4ebaaf46 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -540,7 +540,12 @@ public class QueryComponent extends SearchComponent {
}
doc -= currentLeaf.docBase; // adjust for what segment this is in
- leafComparator.setScorer(new ScoreAndDoc(doc, score));
+ leafComparator.setScorer(new Scorable() {
+ @Override
+ public float score() {
+ return score;
+ }
+ });
leafComparator.copy(0, doc);
Object val = comparator.value(0);
if (null != ft) val = ft.marshalSortValue(val);
@@ -1740,28 +1745,4 @@ public class QueryComponent extends SearchComponent {
return localQueryID;
}
- /**
- * Fake scorer for a single document
- *
- * <p>TODO: when SOLR-5595 is fixed, this wont be needed, as we dont need to
recompute sort values
- * here from the comparator
- */
- protected static class ScoreAndDoc extends Scorable {
- final int docid;
- final float score;
-
- ScoreAndDoc(int docid, float score) {
- this.docid = docid;
- this.score = score;
- }
-
- public int docID() {
- return docid;
- }
-
- @Override
- public float score() throws IOException {
- return score;
- }
- }
}
diff --git
a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index 305ec074903..d17b2c1270d 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -571,10 +571,6 @@ public class CollapsingQParserPlugin extends QParserPlugin
{
public float score() {
return score;
}
-
- public int docID() {
- return docId;
- }
}
/**
@@ -1551,7 +1547,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
// (our supper class may have set the "real" scorer on our leafDelegate
// and it may have an incorrect docID)
leafDelegate.setScorer(currentGroupState);
- leafDelegate.collect(currentGroupState.docID());
+ leafDelegate.collect(currentGroupState.docId);
}
/**
@@ -1604,7 +1600,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
}
public int getCurrentGroup() {
- assert -1 < docID();
+ assert -1 < this.docId;
return this.currentGroup;
}
@@ -1620,7 +1616,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
}
public boolean hasBoostedDocs() {
- assert -1 < docID();
+ assert -1 < this.docId;
return groupHasBoostedDocs;
}
@@ -1630,7 +1626,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
* collected)
*/
public boolean isCurrentDocCollectable() {
- return (-1 < docID() && !groupHasBoostedDocs);
+ return (-1 < this.docId && !groupHasBoostedDocs);
}
}
}
@@ -1667,7 +1663,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
final boolean isBoosted = isBoostedAdvanceExact(contextDoc);
- if (-1 < currentGroupState.docID() && docGroup ==
currentGroupState.getCurrentGroup()) {
+ if (-1 < currentGroupState.docId && docGroup ==
currentGroupState.getCurrentGroup()) {
// we have an existing group, and contextDoc is in that group.
if (isBoosted) {
@@ -1892,7 +1888,7 @@ public class CollapsingQParserPlugin extends
QParserPlugin {
final boolean isBoosted = isBoostedAdvanceExact(contextDoc);
- if (-1 < currentGroupState.docID() && docGroup ==
currentGroupState.getCurrentGroup()) {
+ if (-1 < currentGroupState.docId && docGroup ==
currentGroupState.getCurrentGroup()) {
// we have an existing group, and contextDoc is in that group.
if (isBoosted) {
diff --git a/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
b/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
index 8185fe1878b..9c9178c1bcb 100644
--- a/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
@@ -452,7 +452,12 @@ public class RankQueryTestPlugin extends QParserPlugin {
}
doc -= currentLeaf.docBase; // adjust for what segment this is in
- leafComparator.setScorer(new ScoreAndDoc(doc, score));
+ leafComparator.setScorer(new Scorable() {
+ @Override
+ public float score() {
+ return score;
+ }
+ });
leafComparator.copy(0, doc);
Object val = comparator.value(0);
if (null != ft) val = ft.marshalSortValue(val);
@@ -466,26 +471,6 @@ public class RankQueryTestPlugin extends QParserPlugin {
}
}
- private static class ScoreAndDoc extends Scorable {
-
- final int docid;
- final float score;
-
- ScoreAndDoc(int docid, float score) {
- this.docid = docid;
- this.score = score;
- }
-
- public int docID() {
- return docid;
- }
-
- @Override
- public float score() {
- return score;
- }
- }
-
@Override
@SuppressWarnings({"unchecked"})
public void merge(ResponseBuilder rb, ShardRequest sreq) {