[
https://issues.apache.org/jira/browse/BEAM-5074?focusedWorklogId=132077&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132077
]
ASF GitHub Bot logged work on BEAM-5074:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Aug/18 21:10
Start Date: 07/Aug/18 21:10
Worklog Time Spent: 10m
Work Description: apilloud closed pull request #6145: [BEAM-5074][SQL]
improve BeamSqlRowComparator
URL: https://github.com/apache/beam/pull/6145
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
index 466543568e3..92c43463d40 100644
---
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
+++
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
@@ -178,8 +178,8 @@ public int getCount() {
GlobalWindows.class.getSimpleName(), windowingStrategy));
}
- BeamSqlRowComparator comparator =
- new BeamSqlRowComparator(fieldIndices, orientation, nullsFirst);
+ ReversedBeamSqlRowComparator comparator =
+ new ReversedBeamSqlRowComparator(fieldIndices, orientation,
nullsFirst);
// first find the top (offset + count)
PCollection<List<Row>> rawStream =
@@ -317,7 +317,8 @@ public int compare(Row row1, Row row2) {
}
}
- fieldRet *= (orientation.get(i) ? -1 : 1);
+ fieldRet *= (orientation.get(i) ? 1 : -1);
+
if (fieldRet != 0) {
return fieldRet;
}
@@ -325,4 +326,18 @@ public int compare(Row row1, Row row2) {
return 0;
}
}
+
+ private static class ReversedBeamSqlRowComparator implements
Comparator<Row>, Serializable {
+ private final 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) {
+ 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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 132077)
Time Spent: 2h (was: 1h 50m)
> 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: 2h
> 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)