提交 c3a38aec 编写于 作者: F Fabian Hueske

Minor changes for SortedGrouping

上级 698bcc6f
......@@ -137,29 +137,7 @@ public class Grouping<T> {
* @see Order
*/
public SortedGrouping<T> sortGroup(int field, Order order) {
int pos;
int[] groupSortKeyPositions;
Order[] groupSortOrders ;
if (!dataSet.getType().isTupleType()) {
throw new InvalidProgramException("Specifying order keys via field positions is only valid for tuple data types");
return new SortedGrouping<T>(this.dataSet, this.keys, field, order);
}
if (field >= dataSet.getType().getArity()) {
throw new IllegalArgumentException("Order key out of tuple bounds.");
}
groupSortKeyPositions = new int[1];
groupSortOrders = new Order[1];
pos = 0;
groupSortKeyPositions[pos] = field;
groupSortOrders[pos] = order;
return new SortedGrouping<T>(this.dataSet, this.keys, groupSortKeyPositions, groupSortOrders);
}
// public <K extends Comparable<K>> Grouping<T> sortGroup(KeySelector<T, K> keyExtractor, Order order) {
// throw new UnsupportedOperationException("Group sorting not supported for KeyExtractor functions.");
// }
}
......@@ -35,15 +35,19 @@ public class SortedGrouping<T> extends Grouping<T> {
private int[] groupSortKeyPositions;
private Order[] groupSortOrders ;
public SortedGrouping(DataSet<T> set, Keys<T> keys, int[] groupSortKeyPositions, Order[] groupSortOrders) {
public SortedGrouping(DataSet<T> set, Keys<T> keys, int field, Order order) {
super(set, keys);
if (groupSortKeyPositions == null || groupSortKeyPositions.length == 0 || groupSortOrders == null || groupSortOrders.length == 0) {
throw new InvalidProgramException("Key positions and sort orders must be specified in order to create a SortedGrouping.");
if (!dataSet.getType().isTupleType()) {
throw new InvalidProgramException("Specifying order keys via field positions is only valid for tuple data types");
}
if (field >= dataSet.getType().getArity()) {
throw new IllegalArgumentException("Order key out of tuple bounds.");
}
this.groupSortKeyPositions = groupSortKeyPositions;
this.groupSortOrders = groupSortOrders;
this.groupSortKeyPositions = new int[]{field};
this.groupSortOrders = new Order[]{order};
}
protected int[] getGroupSortKeyPositions() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册