Gergely Fürnstáhl has posted comments on this change. ( http://gerrit.cloudera.org:8080/18413 )
Change subject: IMPALA-11205: Implement Statistical functions : CORR(), COVAR_SAMP() and COVAR_POP() ...................................................................... Patch Set 25: (1 comment) http://gerrit.cloudera.org:8080/#/c/18413/25/be/src/exprs/aggregate-functions-ir.cc File be/src/exprs/aggregate-functions-ir.cc: http://gerrit.cloudera.org:8080/#/c/18413/25/be/src/exprs/aggregate-functions-ir.cc@300 PS25, Line 300: struct CorrState { : int64_t count; // number of elements : double xavg; // average of x elements : double yavg; // average of y elements : double xvar; // n times the variance of x elements : double yvar; // n times the variance of y elements : double covar; // n times the covariance : }; > Yeah, that's right, we did something similar in our 12th patch where we did In Patchset12, you used CorrState for Covar calculations as well, which I agree is not great, wasteful and confusing My proposal is to still have 2 separate structs, but CorrState could utilize CovarState. Some sketch, you can use composition instead of inheritance as well. struct CovarState { int64_t count; // number of elements double xavg; // average of x elements double yavg; // average of y elements double covar; // n times the covariance void update(double x, double y) {...} void remove(double x, double y) {...} void merge(CovarState& other) {...} }; struct CorrState : public CovarState {\ double xvar; // n times the variance of x elements double yvar; // n times the variance of y elements void update(double x, double y) { double prevXavg = xavg; double prevYavg = yavg; CovarState::update(x,y); xvar = ... yvar = ... } ... }; -- To view, visit http://gerrit.cloudera.org:8080/18413 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I32ad627c953ba24d9cde2d5549bdd0d27a9c0d06 Gerrit-Change-Number: 18413 Gerrit-PatchSet: 25 Gerrit-Owner: Anonymous Coward <[email protected]> Gerrit-Reviewer: Anonymous Coward <[email protected]> Gerrit-Reviewer: Gergely Fürnstáhl <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Jian Zhang <[email protected]> Gerrit-Reviewer: Kurt Deschler <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]> Gerrit-Comment-Date: Wed, 15 Jun 2022 15:42:09 +0000 Gerrit-HasComments: Yes
