You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/08/10 16:31:45 UTC

[GitHub] [lucene-solr] madrob opened a new pull request #1731: LUCENE-9451 Sort.rewrite does not always return this when unchanged

madrob opened a new pull request #1731:
URL: https://github.com/apache/lucene-solr/pull/1731


   https://issues.apache.org/jira/browse/LUCENE-9451 


----------------------------------------------------------------
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:
users@infra.apache.org



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


[GitHub] [lucene-solr] madrob commented on a change in pull request #1731: LUCENE-9451 Sort.rewrite does not always return this when unchanged

Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1731:
URL: https://github.com/apache/lucene-solr/pull/1731#discussion_r468031592



##########
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:
       This might be better as an object equality check instead of reference equality, I'm not sure.




----------------------------------------------------------------
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:
users@infra.apache.org



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


[GitHub] [lucene-solr] jpountz commented on a change in pull request #1731: LUCENE-9451 Sort.rewrite does not always return this when unchanged

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



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


[GitHub] [lucene-solr] madrob merged pull request #1731: LUCENE-9451 Sort.rewrite does not always return this when unchanged

Posted by GitBox <gi...@apache.org>.
madrob merged pull request #1731:
URL: https://github.com/apache/lucene-solr/pull/1731


   


----------------------------------------------------------------
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:
users@infra.apache.org



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