Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
6.1.1
-
None
-
2021-5
Description
This task is a prerequisite for MCOL-4361 and is intended to make the patch MCOL-4361 much smaller.
This code in corr::nextValue() in utils/regr/corr.cpp:
static_any::any& valIn_y = valsIn[0].columnData;
|
static_any::any& valIn_x = valsIn[1].columnData;
|
struct corr_data* data = (struct corr_data*)context->getUserData()->data; |
double valx = 0.0; |
double valy = 0.0; |
|
valx = convertAnyTo<double>(valIn_x); |
valy = convertAnyTo<double>(valIn_y); |
|
// For decimal types, we need to move the decimal point. |
uint32_t scaley = valsIn[0].scale;
|
|
if (valy != 0 && scaley > 0) |
{
|
valy /= pow(10.0, (double)scaley); |
}
|
...
|
// For decimal types, we need to move the decimal point. |
uint32_t scalex = valsIn[1].scale;
|
|
if (valx != 0 && scalex > 0) |
{
|
valx /= pow(10.0, (double)scalex); |
}
|
repeats a fair amount of time at least in this files:
- utils/regr/corr.cpp
- utils/regr/covar_pop.cpp
- utils/regr/covar_samp.cpp
- utils/regr/regr_avgx.cpp
- utils/regr/regr_avgy.cpp
- utils/regr/regr_intercept.cpp
- utils/regr/regr_r2.cpp
- utils/regr/regr_slope.cpp
- utils/regr/regr_sxx.cpp
- utils/regr/regr_sxy.cpp
- utils/regr/regr_syy.cpp
- utils/udfsdk/avg_mode.cpp
- utils/udfsdk/avgx.cpp
- utils/udfsdk/mcsv1_udaf.h
- utils/udfsdk/ssq.cpp
Let's implement a method mcsv1_UDAF::toDouble() with approximately this content:
double toDouble(ColumnDatum &datum) const |
{
|
double val = convertAnyTo<double>(datum.columnData); |
if (val != 0 && datum.scale > 0) |
val /= pow(10.0, (double) scale); |
return val; |
}
|
and reuse it in the mentioned files, so the code in corr.cpp and other similar files can be replaced just to these two lines:
double valy = toDouble(valsIn[0]); |
double valx = toDouble(valsIn[1]); |
Later, during MCOL-4361 work, the pow() call will be replaced to a dictionary lookup.
Attachments
Issue Links
- blocks
-
MCOL-4361 Replace pow(10.0, (double)scale) expressions with a static dictionary lookup.
- Closed