counts.ensureCapacity(groupIdsBlock.getGroupCount());
samples.ensureCapacity(groupIdsBlock.getGroupCount());
sums.ensureCapacity(groupIdsBlock.getGroupCount());
m2s.ensureCapacity(groupIdsBlock.getGroupCount());
means.ensureCapacity(groupIdsBlock.getGroupCount());
BlockCursor values = valuesBlock.cursor();
BlockCursor sampleWeights = sampleWeightBlock.get().cursor();
BlockCursor masks = null;
if (maskBlock.isPresent()) {
masks = maskBlock.get().cursor();
}
OnlineVarianceCalculator calculator = new OnlineVarianceCalculator();
for (int position = 0; position < groupIdsBlock.getPositionCount(); position++) {
long groupId = groupIdsBlock.getGroupId(position);
checkState(masks == null || masks.advanceNextPosition(), "failed to advance mask cursor");
checkState(sampleWeights.advanceNextPosition(), "failed to advance weight cursor");
checkState(values.advanceNextPosition(), "failed to advance values cursor");
long weight = values.isNull() ? 0 : SimpleAggregationFunction.computeSampleWeight(masks, sampleWeights);
if (!values.isNull() && weight > 0) {