I've been using version 0.9.0 (thanks for your work - it's a great tool) and I think I've found an issue with the multi-threading in aggregation.
With a list size of 3 and parallelism of 4, doAggregation() runs the parallel version but getAggregateValues() is called with a parallelism of 4 rather than 3 resulting in an array out of bounds exception like this:
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:400) ~[na:1.7.0_45]
at java.util.ArrayList.get(ArrayList.java:413) ~[na:1.7.0_45]
at net.sf.jagg.Aggregations.indexOfLastMatching(Aggregations.java:535) ~[jagg-core-0.9.0.jar:na]
at net.sf.jagg.AggregateRunner.call(AggregateRunner.java:92) ~[jagg-core-0.9.0.jar:na]
at net.sf.jagg.AggregateRunner.call(AggregateRunner.java:23) ~[jagg-core-0.9.0.jar:na]
I wonder if the code in doAggregation() should look like this:
int minParallelism = (myParallelism > size) ? size : myParallelism;
if (minParallelism > 1)
aggregatedList = getAggregateValues(listCopy, comparator, minParallelism);
else
aggregatedList = getAggregateValues(listCopy, comparator);
Anonymous
Good catch! I have checked in code that makes this change, plus an associated test case.
This change will be part of the next build of jAgg.