[ 
https://issues.apache.org/jira/browse/BEAM-5074?focusedWorklogId=132042&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132042
 ]

ASF GitHub Bot logged work on BEAM-5074:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Aug/18 20:02
            Start Date: 07/Aug/18 20:02
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #6145: 
[BEAM-5074][SQL] improve BeamSqlRowComparator
URL: https://github.com/apache/beam/pull/6145#discussion_r208366301
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
 ##########
 @@ -317,12 +317,31 @@ public int compare(Row row1, Row row2) {
           }
         }
 
-        fieldRet *= (orientation.get(i) ? -1 : 1);
+        fieldRet *= (orientation.get(i) ? 1 : -1);
+
         if (fieldRet != 0) {
           return fieldRet;
         }
       }
       return 0;
     }
   }
+
+  private static class ReversedBeamSqlRowComparator implements 
Comparator<Row>, Serializable {
+    private BeamSqlRowComparator comparator;
+
+    public ReversedBeamSqlRowComparator(
+        List<Integer> fieldsIndices, List<Boolean> orientation, List<Boolean> 
nullsFirst) {
+      comparator = new BeamSqlRowComparator(fieldsIndices, orientation, 
nullsFirst);
+    }
+
+    @Override
+    public int compare(Row row1, Row row2) {
+      int ret = comparator.compare(row1, row2);
 
 Review comment:
   nit: You can simplify this function as `return comparator.compare(row2, 
row1);`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 132042)
    Time Spent: 1.5h  (was: 1h 20m)

> Make BeamSqlRowComparator more general
> --------------------------------------
>
>                 Key: BEAM-5074
>                 URL: https://issues.apache.org/jira/browse/BEAM-5074
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>             Fix For: Not applicable
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> BeamSqlRowComparator returns reversed comparison results (if a < b in terms 
> of value, BeamSqlRowComparator returns a > b). 
>  
> Make it return forward results and have a reversed comparator to do the 
> current thing.
>  



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

Reply via email to