提交 2da4b674 编写于 作者: H Haojun Liao

[TD-225]

上级 067ee44b
...@@ -2481,7 +2481,7 @@ static void percentile_function(SQLFunctionCtx *pCtx) { ...@@ -2481,7 +2481,7 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
} }
double v = 0; double v = 0;
GET_TYPED_DATA(v, pCtx->inputType, data); GET_TYPED_DATA(v, double, pCtx->inputType, data);
if (v < GET_DOUBLE_VAL(&pInfo->minval)) { if (v < GET_DOUBLE_VAL(&pInfo->minval)) {
SET_DOUBLE_VAL(&pInfo->minval, v); SET_DOUBLE_VAL(&pInfo->minval, v);
...@@ -2525,7 +2525,7 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -2525,7 +2525,7 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) {
if (pInfo->stage == 0) { if (pInfo->stage == 0) {
double v = 0; double v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, double, pCtx->inputType, pData);
if (v < GET_DOUBLE_VAL(&pInfo->minval)) { if (v < GET_DOUBLE_VAL(&pInfo->minval)) {
SET_DOUBLE_VAL(&pInfo->minval, v); SET_DOUBLE_VAL(&pInfo->minval, v);
...@@ -2616,7 +2616,7 @@ static void apercentile_function(SQLFunctionCtx *pCtx) { ...@@ -2616,7 +2616,7 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
notNullElems += 1; notNullElems += 1;
double v = 0; double v = 0;
GET_TYPED_DATA(v, pCtx->inputType, data); GET_TYPED_DATA(v, double, pCtx->inputType, data);
tHistogramAdd(&pInfo->pHisto, v); tHistogramAdd(&pInfo->pHisto, v);
} }
...@@ -2641,7 +2641,7 @@ static void apercentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -2641,7 +2641,7 @@ static void apercentile_function_f(SQLFunctionCtx *pCtx, int32_t index) {
SAPercentileInfo *pInfo = getAPerctInfo(pCtx); SAPercentileInfo *pInfo = getAPerctInfo(pCtx);
double v = 0; double v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, double, pCtx->inputType, pData);
tHistogramAdd(&pInfo->pHisto, v); tHistogramAdd(&pInfo->pHisto, v);
...@@ -4064,7 +4064,7 @@ static void rate_function(SQLFunctionCtx *pCtx) { ...@@ -4064,7 +4064,7 @@ static void rate_function(SQLFunctionCtx *pCtx) {
notNullElems++; notNullElems++;
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, int64_t, pCtx->inputType, pData);
if ((INT64_MIN == pRateInfo->firstValue) || (INT64_MIN == pRateInfo->firstKey)) { if ((INT64_MIN == pRateInfo->firstValue) || (INT64_MIN == pRateInfo->firstKey)) {
pRateInfo->firstValue = v; pRateInfo->firstValue = v;
...@@ -4114,7 +4114,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -4114,7 +4114,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
TSKEY *primaryKey = pCtx->ptsList; TSKEY *primaryKey = pCtx->ptsList;
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, int64_t, pCtx->inputType, pData);
if ((INT64_MIN == pRateInfo->firstValue) || (INT64_MIN == pRateInfo->firstKey)) { if ((INT64_MIN == pRateInfo->firstValue) || (INT64_MIN == pRateInfo->firstKey)) {
pRateInfo->firstValue = v; pRateInfo->firstValue = v;
...@@ -4241,7 +4241,7 @@ static void irate_function(SQLFunctionCtx *pCtx) { ...@@ -4241,7 +4241,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
notNullElems++; notNullElems++;
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, int64_t, pCtx->inputType, pData);
// TODO: calc once if only call this function once ???? // TODO: calc once if only call this function once ????
if ((INT64_MIN == pRateInfo->lastKey) || (INT64_MIN == pRateInfo->lastValue)) { if ((INT64_MIN == pRateInfo->lastKey) || (INT64_MIN == pRateInfo->lastValue)) {
...@@ -4286,7 +4286,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) { ...@@ -4286,7 +4286,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
TSKEY *primaryKey = pCtx->ptsList; TSKEY *primaryKey = pCtx->ptsList;
int64_t v = 0; int64_t v = 0;
GET_TYPED_DATA(v, pCtx->inputType, pData); GET_TYPED_DATA(v, int64_t, pCtx->inputType, pData);
pRateInfo->firstKey = pRateInfo->lastKey; pRateInfo->firstKey = pRateInfo->lastKey;
pRateInfo->firstValue = pRateInfo->lastValue; pRateInfo->firstValue = pRateInfo->lastValue;
......
...@@ -7,25 +7,25 @@ extern "C" { ...@@ -7,25 +7,25 @@ extern "C" {
#include "taosdef.h" #include "taosdef.h"
#define GET_TYPED_DATA(_v, _type, _data) \ #define GET_TYPED_DATA(_v, _finalType, _type, _data) \
switch (_type) { \ switch (_type) { \
case TSDB_DATA_TYPE_TINYINT: \ case TSDB_DATA_TYPE_TINYINT: \
(_v) = GET_INT8_VAL(_data); \ (_v) = (_finalType)GET_INT8_VAL(_data); \
break; \ break; \
case TSDB_DATA_TYPE_SMALLINT: \ case TSDB_DATA_TYPE_SMALLINT: \
(_v) = GET_INT16_VAL(_data); \ (_v) = (_finalType)GET_INT16_VAL(_data); \
break; \ break; \
case TSDB_DATA_TYPE_BIGINT: \ case TSDB_DATA_TYPE_BIGINT: \
(_v) = (GET_INT64_VAL(_data)); \ (_v) = (_finalType)(GET_INT64_VAL(_data)); \
break; \ break; \
case TSDB_DATA_TYPE_FLOAT: \ case TSDB_DATA_TYPE_FLOAT: \
(_v) = GET_FLOAT_VAL(_data); \ (_v) = (_finalType)GET_FLOAT_VAL(_data); \
break; \ break; \
case TSDB_DATA_TYPE_DOUBLE: \ case TSDB_DATA_TYPE_DOUBLE: \
(_v) = GET_DOUBLE_VAL(_data); \ (_v) = (_finalType)GET_DOUBLE_VAL(_data); \
break; \ break; \
default: \ default: \
(_v) = GET_INT32_VAL(_data); \ (_v) = (_finalType)GET_INT32_VAL(_data); \
break; \ break; \
}; };
......
...@@ -237,8 +237,8 @@ int32_t taosGetLinearInterpolationVal(int32_t type, SPoint* point1, SPoint* poin ...@@ -237,8 +237,8 @@ int32_t taosGetLinearInterpolationVal(int32_t type, SPoint* point1, SPoint* poin
double v1 = -1; double v1 = -1;
double v2 = -1; double v2 = -1;
GET_TYPED_DATA(v1, type, point1->val); GET_TYPED_DATA(v1, double, type, point1->val);
GET_TYPED_DATA(v2, type, point2->val); GET_TYPED_DATA(v2, double, type, point2->val);
double r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); double r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册