未验证 提交 669f228b 编写于 作者: H haojun Liao 提交者: GitHub

Merge pull request #1040 from taosdata/master-lihui

[#1039 TBASE-816]
......@@ -3817,31 +3817,29 @@ static void getStatics_f(int64_t *primaryKey, float *data, int32_t numOfRow, dou
int16_t *minIndex, int16_t *maxIndex, int32_t *numOfNull) {
float fmin = DBL_MAX;
float fmax = -DBL_MAX;
float fminIndex = 0;
float fmaxIndex = 0;
double dsum = 0;
*minIndex = 0;
*maxIndex = 0;
assert(numOfRow <= INT16_MAX);
for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull(&data[i], TSDB_DATA_TYPE_FLOAT)) {
if (isNull((const char*) &data[i], TSDB_DATA_TYPE_FLOAT)) {
(*numOfNull) += 1;
continue;
}
float fv = 0;
*(int32_t*)(&fv) = *(int32_t*)(&(data[i]));
//*sum += data[i];
fv = GET_FLOAT_VAL(&(data[i]));
dsum += fv;
if (fmin > fv) {
fmin = fv;
fminIndex = i;
minIndex = i;
}
if (fmax < fv) {
fmax = fv;
fmaxIndex = i;
maxIndex = i;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_FLOAT)) {
......@@ -3855,46 +3853,46 @@ static void getStatics_f(int64_t *primaryKey, float *data, int32_t numOfRow, dou
}
double csum = 0;
*(int64_t*)(&csum) = *(int64_t*)sum;
csum = GET_DOUBLE_VAL(sum);
csum += dsum;
*(int64_t*)(sum) = *(int64_t*)(&csum);
*(int32_t*)max = *(int32_t*)(&fmax);
*(int32_t*)min = *(int32_t*)(&fmin);
*(int32_t*)minIndex = *(int32_t*)(&fminIndex);
*(int32_t*)maxIndex = *(int32_t*)(&fmaxIndex);
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN(sum, &csum);
SET_DOUBLE_VAL_ALIGN(max, &fmax);
SET_DOUBLE_VAL_ALIGN(min, &fmin);
#else
*sum = csum;
*max = fmax;
*min = fmin;
#endif
}
static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, double *min, double *max, double *sum,
int16_t *minIndex, int16_t *maxIndex, int32_t *numOfNull) {
double dmin = DBL_MAX;
double dmax = -DBL_MAX;
double dminIndex = 0;
double dmaxIndex = 0;
double dsum = 0;
*minIndex = 0;
*maxIndex = 0;
assert(numOfRow <= INT16_MAX);
for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull(&data[i], TSDB_DATA_TYPE_DOUBLE)) {
if (isNull((const char*) &data[i], TSDB_DATA_TYPE_DOUBLE)) {
(*numOfNull) += 1;
continue;
}
double dv = 0;
*(int64_t*)(&dv) = *(int64_t*)(&(data[i]));
//*sum += data[i];
dv = GET_DOUBLE_VAL(&(data[i]));
dsum += dv;
if (dmin > dv) {
dmin = dv;
dminIndex = i;
minIndex = i;
}
if (dmax < dv) {
dmax = dv;
dmaxIndex = i;
maxIndex = i;
}
// if (isNull(&lastVal, TSDB_DATA_TYPE_DOUBLE)) {
......@@ -3908,14 +3906,19 @@ static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, do
}
double csum = 0;
*(int64_t*)(&csum) = *(int64_t*)sum;
csum = GET_DOUBLE_VAL(sum);
csum += dsum;
*(int64_t*)(sum) = *(int64_t*)(&csum);
*(int64_t*)max = *(int64_t*)(&dmax);
*(int64_t*)min = *(int64_t*)(&dmin);
*(int64_t*)minIndex = *(int64_t*)(&dminIndex);
*(int64_t*)maxIndex = *(int64_t*)(&dmaxIndex);
#ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN(sum, &csum);
SET_DOUBLE_VAL_ALIGN(max, &dmax);
SET_DOUBLE_VAL_ALIGN(min, &dmin);
#else
*sum = csum;
*max = dmax;
*min = dmin;
#endif
}
void getStatistics(char *priData, char *data, int32_t size, int32_t numOfRow, int32_t type, int64_t *min, int64_t *max,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册