You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Namgyu Kim (JIRA)" <ji...@apache.org> on 2019/07/02 17:38:00 UTC

[jira] [Commented] (LUCENE-8900) Simplify MultiSorter

    [ https://issues.apache.org/jira/browse/LUCENE-8900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16877180#comment-16877180 ] 

Namgyu Kim commented on LUCENE-8900:
------------------------------------

+1

This patch looks good. [~jpountz] :D
 I have some opinions about your patch.

1. In lessThan method in PriorityQueue, we can reduce the computation. (very minor difference)
 Before
{code:java}
public boolean lessThan(LeafAndDocID a, LeafAndDocID b) {
  for(int i=0;i<comparables.length;i++) {
    int cmp = reverseMuls[i] * Long.compare(a.valuesAsComparableLongs[i], b.valuesAsComparableLongs[i]);
    if (cmp != 0) {
      return cmp < 0;
    }
  }
  ...
}
{code}
After
{code:java}
public boolean lessThan(LeafAndDocID a, LeafAndDocID b) {
  for(int i=0;i<comparables.length;i++) {
    int cmp = Long.compare(a.valuesAsComparableLongs[i], b.valuesAsComparableLongs[i]);
    if (cmp != 0) {
      return (reverseMuls[i] * cmp) < 0;
    }
  }
  ...
}
{code}
 

2. About getComparableProviders method, it seems like we don't need to call the longValue() method.
 Before
{code:java}
case LONG:
case INT:
 {
  final long missingValue;
  if (sortField.getMissingValue() != null) {
    missingValue = ((Number) sortField.getMissingValue()).longValue(); // THIS
  } else {
    missingValue = 0L;
  }
 }
{code}
After
{code:java}
case LONG:
case INT:
 {
  final long missingValue;
  if (sortField.getMissingValue() != null) {
    missingValue = (Long) sortField.getMissingValue(); // THIS
  } else {
    missingValue = 0L;
  }
 }
{code}

> Simplify MultiSorter
> --------------------
>
>                 Key: LUCENE-8900
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8900
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Priority: Minor
>         Attachments: LUCENE-8900.patch
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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