variance-uda.cc
// TODO: this can be used as the actual variance finalize function once the return type
// doesn't need to match the intermediate type in Impala 2.0.
this can be used as the actual variance finalize function once the return type
doesn't need to match the intermediate type in Impala 2.0.
this can be used as the actual variance finalize function once the return type doesn ' t need to match the intermediate type in Impala 2 . 0 .
DoubleVal KnuthVarianceFinalize(const StringVal& state_sv) {
  if (state_sv.is_null) return DoubleVal::null();
  KnuthVarianceState* state = reinterpret_cast<KnuthVarianceState*>(state_sv.ptr);
  if (state->count == 0 || state->count == 1) return DoubleVal::null();
  double variance_n = state->m2 / state->count;
  double variance = variance_n * state->count / (state->count - 1);
  return DoubleVal(variance);
}
DoubleVal KnuthVarianceFinalize ( const StringVal & state_sv ) { if ( state_sv . is_null ) return DoubleVal :: null ( ) ; KnuthVarianceState * state = reinterpret_cast < KnuthVarianceState * > ( state_sv . ptr ) ; if ( state -> count == 0 || state -> count == 1 ) return DoubleVal :: null ( ) ; double variance_n = state -> m2 / state -> count ; double variance = variance_n * state -> count / ( state -> count - 1 ) ; return DoubleVal ( variance ) ; }
TODO: this can be used as the actual variance finalize function once the return type
doesn't need to match the intermediate type in Impala 2.0.
TODO : this can be used as the actual variance finalize function once the return type doesn ' t need to match the intermediate type in Impala 2 . 0 .