Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1585#discussion_r52282118
--- Diff:
flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java
---
@@ -36,27 +40,58 @@
*/
public class SortPartitionOperator<T> extends SingleInputOperator<T, T,
SortPartitionOperator<T>> {
- private int[] sortKeyPositions;
+ private List<Keys<T>> keys;
- private Order[] sortOrders;
+ private List<Order> orders;
private final String sortLocationName;
+ private boolean useKeySelector;
- public SortPartitionOperator(DataSet<T> dataSet, int sortField, Order
sortOrder, String sortLocationName) {
+ private SortPartitionOperator(DataSet<T> dataSet, String
sortLocationName) {
super(dataSet, dataSet.getType());
+
+ keys = new ArrayList<>();
+ orders = new ArrayList<>();
this.sortLocationName = sortLocationName;
+ }
+
+
+ public SortPartitionOperator(DataSet<T> dataSet, int sortField, Order
sortOrder, String sortLocationName) {
+ this(dataSet, sortLocationName);
+ this.useKeySelector = false;
+
+ ensureSortableKey(sortField);
- int[] flatOrderKeys = getFlatFields(sortField);
- this.appendSorting(flatOrderKeys, sortOrder);
+ keys.add(new Keys.ExpressionKeys<>(sortField, getType()));
+ orders.add(sortOrder);
}
public SortPartitionOperator(DataSet<T> dataSet, String sortField,
Order sortOrder, String sortLocationName) {
- super(dataSet, dataSet.getType());
- this.sortLocationName = sortLocationName;
+ this(dataSet, sortLocationName);
+ this.useKeySelector = false;
+
+ ensureSortableKey(sortField);
+
+ keys.add(new Keys.ExpressionKeys<>(sortField, getType()));
+ orders.add(sortOrder);
+ }
+
+ public SortPartitionOperator(DataSet<T> dataSet, Keys<T> sortKey, Order
sortOrder, String sortLocationName) {
--- End diff --
Change the `sortKey` parameter type to `SelectorFunctionKeys` (or accept
the `KeySelector` and create the `SelectorFunctionKeys` in the constructor.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---