void AggregatorMin::reduce(AqlValue const& cmpValue) { if (value.isEmpty() || (!cmpValue.isNull(true) && AqlValue::Compare(trx, value, cmpValue, true) > 0)) { // the value `null` itself will not be used in MIN() to compare lower than // e.g. value `false` value.destroy(); value = cmpValue.clone(); } }
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; }