void AggregatorSum::reduce(AqlValue const& cmpValue) { if (!invalid) { if (cmpValue.isNull(true)) { // ignore `null` values here return; } if (cmpValue.isNumber()) { double const number = cmpValue.toDouble(trx); if (!std::isnan(number) && number != HUGE_VAL && number != -HUGE_VAL) { sum += number; return; } } } invalid = true; }
void AggregatorVarianceBase::reduce(AqlValue const& cmpValue) { if (!invalid) { if (cmpValue.isNull(true)) { // ignore `null` values here return; } if (cmpValue.isNumber()) { double const number = cmpValue.toDouble(trx); if (!std::isnan(number) && number != HUGE_VAL && number != -HUGE_VAL) { double const delta = number - mean; ++count; mean += delta / count; sum += delta * (number - mean); return; } } } invalid = true; }