Skip to content

Commit fd201eb

Browse files
author
Nathan Marz
committed
error checking on ComboList, and fix bug in Aggregator so that it sets the correct group during aggregate
1 parent f248d79 commit fd201eb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/jvm/storm/trident/operation/impl/GroupedAggregator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public void aggregate(Object[] arr, TridentTuple tuple, TridentCollector collect
5656
} else {
5757
curr = val.get(group);
5858
}
59+
groupColl.currGroup = group;
5960
_agg.aggregate(curr, input, groupColl);
6061

6162
}

src/jvm/storm/trident/tuple/ComboList.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
import java.io.Serializable;
44
import java.util.AbstractList;
55
import java.util.List;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
67

78

89
public class ComboList extends AbstractList<Object> {
910
public static class Factory implements Serializable {
1011
Pointer[] index;
11-
int numLists;
12+
int[] sizes;
1213

1314
public Factory(int... sizes) {
14-
numLists = sizes.length;
15+
this.sizes = sizes;
1516
int total = 0;
1617
for(int size: sizes) {
1718
total+=size;
@@ -29,8 +30,14 @@ public Factory(int... sizes) {
2930
}
3031

3132
public ComboList create(List[] delegates) {
32-
if(delegates.length!=numLists) {
33-
throw new RuntimeException("Expected " + numLists + " lists, but instead got " + delegates.length + " lists");
33+
if(delegates.length!=sizes.length) {
34+
throw new RuntimeException("Expected " + sizes.length + " lists, but instead got " + delegates.length + " lists");
35+
}
36+
for(int i=0; i<delegates.length; i++) {
37+
List l = delegates[i];
38+
if(l==null || l.size() != sizes[i]) {
39+
throw new RuntimeException("Got unexpected delegates to ComboList: " + ToStringBuilder.reflectionToString(delegates));
40+
}
3441
}
3542
return new ComboList(delegates, index);
3643
}

0 commit comments

Comments
 (0)