boolean sortUsingCollator = methodResolutionService.isSortUsingCollator();
Comparator<Object> comparator = CollectionUtil.getComparator(evaluators, sortUsingCollator, sortDescending);
Object criteriaKeyBinding = methodResolutionService.getCriteriaKeyBinding(evaluators);
AggregationStateFactory factory;
if (ever) {
final AggregationStateMinMaxByEverSpec spec = new AggregationStateMinMaxByEverSpec(streamNum, evaluators, parent.isMax(), comparator, criteriaKeyBinding);
factory = new AggregationStateFactory() {
public AggregationState createAccess(MethodResolutionService methodResolutionService, int agentInstanceId, int groupId, int aggregationId, boolean join, Object groupKey) {
return methodResolutionService.makeAccessAggMinMaxEver(agentInstanceId, groupId, aggregationId, spec);
}
public ExprNode getAggregationExpression() {
return parent;
}
};
}
else {
final AggregationStateSortedSpec spec = new AggregationStateSortedSpec(streamNum, evaluators, comparator, criteriaKeyBinding);
factory = new AggregationStateFactory() {
public AggregationState createAccess(MethodResolutionService methodResolutionService, int agentInstanceId, int groupId, int aggregationId, boolean join, Object groupKey) {
if (join) {
return methodResolutionService.makeAccessAggSortedJoin(agentInstanceId, groupId, aggregationId, spec);
}
return methodResolutionService.makeAccessAggSortedNonJoin(agentInstanceId, groupId, aggregationId, spec);