jpountz commented on a change in pull request #1731:
URL: https://github.com/apache/lucene-solr/pull/1731#discussion_r469225237



##########
File path: lucene/core/src/java/org/apache/lucene/search/Sort.java
##########
@@ -177,12 +177,12 @@ public Sort rewrite(IndexSearcher searcher) throws 
IOException {
     SortField[] rewrittenSortFields = new SortField[fields.length];
     for (int i = 0; i < fields.length; i++) {
       rewrittenSortFields[i] = fields[i].rewrite(searcher);
-      if (fields[i] != rewrittenSortFields[i]) {
+      if (! fields[i].equals(rewrittenSortFields[i])) {

Review comment:
       this should remain a reference equality check

##########
File path: lucene/core/src/test/org/apache/lucene/search/TestSort.java
##########
@@ -878,4 +878,22 @@ public void testMultiSort() throws IOException {
     ir.close();
     dir.close();
   }
+
+  public void testRewrite() throws IOException {
+    try (Directory dir = newDirectory()) {
+      RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
+      IndexSearcher searcher = newSearcher(writer.getReader());
+      writer.close();
+
+      LongValuesSource longSource = LongValuesSource.constant(1L);
+      Sort sort = new Sort(longSource.getSortField(false));
+
+      assertSame(sort, sort.rewrite(searcher));
+
+      DoubleValuesSource doubleSource = DoubleValuesSource.constant(1.0);
+      sort = new Sort(doubleSource.getSortField(false));
+
+      assertSame(sort, sort.rewrite(searcher));
+    }
+  }

Review comment:
       This test looks like it belongs to 
TestDoubleValuesSource/TestLongValuesSource more than it belongs to TestSort?

##########
File path: lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java
##########
@@ -456,13 +456,16 @@ public String toString() {
 
     @Override
     public SortField rewrite(IndexSearcher searcher) throws IOException {
-      DoubleValuesSortField rewritten = new 
DoubleValuesSortField(producer.rewrite(searcher), reverse);
+      DoubleValuesSource rewrittenSource = producer.rewrite(searcher);
+      if (rewrittenSource == producer) {

Review comment:
       Reference equality is the right check.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to