//@formatter:off
final AxisInfo[] axisInfos = new AxisInfo[] { new AxisInfo(cellSet.getAxes().get(rowsIndex)),
new AxisInfo(cellSet.getAxes().get(rowsIndex + 1 & 1)) };
//@formatter:on
List<TotalNode>[][] totals = new List[2][];
TotalsListsBuilder builder = null;
for (int index = 0; index < 2; index++) {
final int second = index + 1 & 1;
TotalAggregator[] aggregators = new TotalAggregator[axisInfos[second].maxDepth + 1];
for (int i = 1; i < aggregators.length - 1; i++) {
List<String> aggs = query.getAggregators(axisInfos[second].uniqueLevelNames.get(i - 1));
String totalFunctionName = aggs != null && aggs.size() > 0 ? aggs.get(0) : null;
aggregators[i] =
StringUtils.isNotBlank(totalFunctionName)
? TotalAggregator.newInstanceByFunctionName(totalFunctionName)
: null;
}
List<String> aggs = query.getAggregators(axisInfos[second].axis.getAxisOrdinal().name());
String totalFunctionName = aggs != null && aggs.size() > 0 ? aggs.get(0) : null;
aggregators[0] =
StringUtils.isNotBlank(totalFunctionName) ? TotalAggregator.newInstanceByFunctionName(totalFunctionName)
: null;
builder = new TotalsListsBuilder(selectedMeasures, aggregators, cellSet, axisInfos[index], axisInfos[second]);
totals[index] = builder.buildTotalsLists();
}
result.setLeftOffset(axisInfos[0].maxDepth);
result.setRowTotalsLists(totals[1]);
result.setColTotalsLists(totals[0]);
}