more code format
This commit is contained in:
parent
63d9b85631
commit
d8e32fb439
|
@ -59,7 +59,6 @@ enum {
|
|||
RANGE_FLG_NULL = 4,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
FI_STATUS_ALL = 1,
|
||||
FI_STATUS_EMPTY = 2,
|
||||
|
@ -97,10 +96,10 @@ typedef struct SFilterRange {
|
|||
char eflag;
|
||||
} SFilterRange;
|
||||
|
||||
typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t);
|
||||
typedef int32_t(*filter_desc_compare_func)(const void *, const void *);
|
||||
typedef bool(*filter_exec_func)(void*, int32_t, SColumnInfoData*, SColumnDataAgg*, int16_t, int32_t*);
|
||||
typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char*, void **);
|
||||
typedef bool (*rangeCompFunc)(const void *, const void *, const void *, const void *, __compar_fn_t);
|
||||
typedef int32_t (*filter_desc_compare_func)(const void *, const void *);
|
||||
typedef bool (*filter_exec_func)(void *, int32_t, SColumnInfoData *, SColumnDataAgg *, int16_t, int32_t *);
|
||||
typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char *, void **);
|
||||
|
||||
typedef struct SFilterRangeCompare {
|
||||
int64_t s;
|
||||
|
@ -109,8 +108,8 @@ typedef struct SFilterRangeCompare {
|
|||
} SFilterRangeCompare;
|
||||
|
||||
typedef struct SFilterRangeNode {
|
||||
struct SFilterRangeNode* prev;
|
||||
struct SFilterRangeNode* next;
|
||||
struct SFilterRangeNode *prev;
|
||||
struct SFilterRangeNode *next;
|
||||
union {
|
||||
SFilterRange ra;
|
||||
SFilterRangeCompare rc;
|
||||
|
@ -126,9 +125,9 @@ typedef struct SFilterRangeCtx {
|
|||
bool isrange;
|
||||
int16_t colId;
|
||||
__compar_fn_t pCompareFunc;
|
||||
SFilterRangeNode *rf; //freed
|
||||
SFilterRangeNode *rf; // freed
|
||||
SFilterRangeNode *rs;
|
||||
} SFilterRangeCtx ;
|
||||
} SFilterRangeCtx;
|
||||
|
||||
typedef struct SFilterVarCtx {
|
||||
int32_t type;
|
||||
|
@ -143,8 +142,8 @@ typedef struct SFilterVarCtx {
|
|||
|
||||
typedef struct SFilterField {
|
||||
uint16_t flag;
|
||||
void* desc;
|
||||
void* data;
|
||||
void *desc;
|
||||
void *data;
|
||||
} SFilterField;
|
||||
|
||||
typedef struct SFilterFields {
|
||||
|
@ -181,7 +180,7 @@ typedef struct SFilterGroupCtx {
|
|||
|
||||
typedef struct SFilterColCtx {
|
||||
uint32_t colIdx;
|
||||
void* ctx;
|
||||
void *ctx;
|
||||
} SFilterColCtx;
|
||||
|
||||
typedef struct SFilterCompare {
|
||||
|
@ -219,8 +218,8 @@ typedef struct SFltTreeStat {
|
|||
int32_t code;
|
||||
int8_t precision;
|
||||
bool scalarMode;
|
||||
SArray* nodeList;
|
||||
SFilterInfo* info;
|
||||
SArray *nodeList;
|
||||
SFilterInfo *info;
|
||||
} SFltTreeStat;
|
||||
|
||||
typedef struct SFltScalarCtx {
|
||||
|
@ -260,31 +259,117 @@ struct SFilterInfo {
|
|||
SFilterPCtx pctx;
|
||||
};
|
||||
|
||||
#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON)
|
||||
#define FILTER_NO_MERGE_DATA_TYPE(t) \
|
||||
((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON)
|
||||
#define FILTER_NO_MERGE_OPTR(o) ((o) == OP_TYPE_IS_NULL || (o) == OP_TYPE_IS_NOT_NULL || (o) == FILTER_DUMMY_EMPTY_OPTR)
|
||||
|
||||
#define MR_EMPTY_RES(ctx) (ctx->rs == NULL)
|
||||
|
||||
#define SET_AND_OPTR(ctx, o) do {if (o == OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_NULL) { if (!(ctx)->isrange) { (ctx)->notnull = true; } } else if (o != FILTER_DUMMY_EMPTY_OPTR) { (ctx)->isrange = true; (ctx)->notnull = false; } } while (0)
|
||||
#define SET_OR_OPTR(ctx,o) do {if (o == OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_NULL) { (ctx)->notnull = true; (ctx)->isrange = false; } else if (o != FILTER_DUMMY_EMPTY_OPTR) { if (!(ctx)->notnull) { (ctx)->isrange = true; } } } while (0)
|
||||
#define SET_AND_OPTR(ctx, o) \
|
||||
do { \
|
||||
if (o == OP_TYPE_IS_NULL) { \
|
||||
(ctx)->isnull = true; \
|
||||
} else if (o == OP_TYPE_IS_NOT_NULL) { \
|
||||
if (!(ctx)->isrange) { \
|
||||
(ctx)->notnull = true; \
|
||||
} \
|
||||
} else if (o != FILTER_DUMMY_EMPTY_OPTR) { \
|
||||
(ctx)->isrange = true; \
|
||||
(ctx)->notnull = false; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SET_OR_OPTR(ctx, o) \
|
||||
do { \
|
||||
if (o == OP_TYPE_IS_NULL) { \
|
||||
(ctx)->isnull = true; \
|
||||
} else if (o == OP_TYPE_IS_NOT_NULL) { \
|
||||
(ctx)->notnull = true; \
|
||||
(ctx)->isrange = false; \
|
||||
} else if (o != FILTER_DUMMY_EMPTY_OPTR) { \
|
||||
if (!(ctx)->notnull) { \
|
||||
(ctx)->isrange = true; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#define CHK_OR_OPTR(ctx) ((ctx)->isnull == true && (ctx)->notnull == true)
|
||||
#define CHK_AND_OPTR(ctx) ((ctx)->isnull == true && (((ctx)->notnull == true) || ((ctx)->isrange == true)))
|
||||
|
||||
|
||||
#define FILTER_GET_FLAG(st, f) (st & f)
|
||||
#define FILTER_SET_FLAG(st, f) st |= (f)
|
||||
#define FILTER_CLR_FLAG(st, f) st &= (~f)
|
||||
|
||||
#define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src)
|
||||
#define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) do { char *_t = (char *)(v); _t[0] = (op1); _t[1] = (op2); *(uint32_t *)(_t + 2) = (lidx); *(uint32_t *)(_t + 2 + sizeof(uint32_t)) = (ridx); } while (0)
|
||||
#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RANGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag,RANGE_FLG_EXCLUDE))))
|
||||
#define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0)
|
||||
#define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) \
|
||||
do { \
|
||||
char *_t = (char *)(v); \
|
||||
_t[0] = (op1); \
|
||||
_t[1] = (op2); \
|
||||
*(uint32_t *)(_t + 2) = (lidx); \
|
||||
*(uint32_t *)(_t + 2 + sizeof(uint32_t)) = (ridx); \
|
||||
} while (0)
|
||||
#define FILTER_GREATER(cr, sflag, eflag) \
|
||||
((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag, RANGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag, RANGE_FLG_EXCLUDE))))
|
||||
#define FILTER_COPY_RA(dst, src) \
|
||||
do { \
|
||||
(dst)->sflag = (src)->sflag; \
|
||||
(dst)->eflag = (src)->eflag; \
|
||||
(dst)->s = (src)->s; \
|
||||
(dst)->e = (src)->e; \
|
||||
} while (0)
|
||||
|
||||
#define RESET_RANGE(ctx, r) do { (r)->next = (ctx)->rf; (ctx)->rf = r; } while (0)
|
||||
#define FREE_RANGE(ctx, r) do { if ((r)->prev) { (r)->prev->next = (r)->next; } else { (ctx)->rs = (r)->next;} if ((r)->next) { (r)->next->prev = (r)->prev; } RESET_RANGE(ctx, r); } while (0)
|
||||
#define FREE_FROM_RANGE(ctx, r) do { SFilterRangeNode *_r = r; if ((_r)->prev) { (_r)->prev->next = NULL; } else { (ctx)->rs = NULL;} while (_r) {SFilterRangeNode *n = (_r)->next; RESET_RANGE(ctx, _r); _r = n; } } while (0)
|
||||
#define INSERT_RANGE(ctx, r, ra) do { SFilterRangeNode *n = filterNewRange(ctx, ra); n->prev = (r)->prev; if ((r)->prev) { (r)->prev->next = n; } else { (ctx)->rs = n; } (r)->prev = n; n->next = r; } while (0)
|
||||
#define APPEND_RANGE(ctx, r, ra) do { SFilterRangeNode *n = filterNewRange(ctx, ra); n->prev = (r); if (r) { (r)->next = n; } else { (ctx)->rs = n; } } while (0)
|
||||
#define RESET_RANGE(ctx, r) \
|
||||
do { \
|
||||
(r)->next = (ctx)->rf; \
|
||||
(ctx)->rf = r; \
|
||||
} while (0)
|
||||
#define FREE_RANGE(ctx, r) \
|
||||
do { \
|
||||
if ((r)->prev) { \
|
||||
(r)->prev->next = (r)->next; \
|
||||
} else { \
|
||||
(ctx)->rs = (r)->next; \
|
||||
} \
|
||||
if ((r)->next) { \
|
||||
(r)->next->prev = (r)->prev; \
|
||||
} \
|
||||
RESET_RANGE(ctx, r); \
|
||||
} while (0)
|
||||
#define FREE_FROM_RANGE(ctx, r) \
|
||||
do { \
|
||||
SFilterRangeNode *_r = r; \
|
||||
if ((_r)->prev) { \
|
||||
(_r)->prev->next = NULL; \
|
||||
} else { \
|
||||
(ctx)->rs = NULL; \
|
||||
} \
|
||||
while (_r) { \
|
||||
SFilterRangeNode *n = (_r)->next; \
|
||||
RESET_RANGE(ctx, _r); \
|
||||
_r = n; \
|
||||
} \
|
||||
} while (0)
|
||||
#define INSERT_RANGE(ctx, r, ra) \
|
||||
do { \
|
||||
SFilterRangeNode *n = filterNewRange(ctx, ra); \
|
||||
n->prev = (r)->prev; \
|
||||
if ((r)->prev) { \
|
||||
(r)->prev->next = n; \
|
||||
} else { \
|
||||
(ctx)->rs = n; \
|
||||
} \
|
||||
(r)->prev = n; \
|
||||
n->next = r; \
|
||||
} while (0)
|
||||
#define APPEND_RANGE(ctx, r, ra) \
|
||||
do { \
|
||||
SFilterRangeNode *n = filterNewRange(ctx, ra); \
|
||||
n->prev = (r); \
|
||||
if (r) { \
|
||||
(r)->next = n; \
|
||||
} else { \
|
||||
(ctx)->rs = n; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FLT_IS_COMPARISON_OPERATOR(_op) ((_op) >= OP_TYPE_GREATER_THAN && (_op) < OP_TYPE_IS_NOT_UNKNOWN)
|
||||
|
||||
|
@ -295,12 +380,36 @@ struct SFilterInfo {
|
|||
#define fltDebug(...) qDebug(__VA_ARGS__)
|
||||
#define fltTrace(...) qTrace(__VA_ARGS__)
|
||||
|
||||
|
||||
#define FLT_CHK_JMP(c) do { if (c) { goto _return; } } while (0)
|
||||
#define FLT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
||||
#define FLT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
||||
#define FLT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
||||
|
||||
#define FLT_CHK_JMP(c) \
|
||||
do { \
|
||||
if (c) { \
|
||||
goto _return; \
|
||||
} \
|
||||
} while (0)
|
||||
#define FLT_ERR_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
return _code; \
|
||||
} \
|
||||
} while (0)
|
||||
#define FLT_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
} \
|
||||
return _code; \
|
||||
} while (0)
|
||||
#define FLT_ERR_JRET(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = code; \
|
||||
goto _return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx]))
|
||||
#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx]))
|
||||
|
@ -313,7 +422,7 @@ struct SFilterInfo {
|
|||
#define FILTER_GET_COL_FIELD_DATA(fi, ri) (colDataGetData(((SColumnInfoData *)(fi)->data), (ri)))
|
||||
#define FILTER_GET_VAL_FIELD_TYPE(fi) (((SValueNode *)((fi)->desc))->node.resType.type)
|
||||
#define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data)
|
||||
#define FILTER_GET_TYPE(fl) ((fl) & FLD_TYPE_MAX)
|
||||
#define FILTER_GET_TYPE(fl) ((fl)&FLD_TYPE_MAX)
|
||||
|
||||
#define FILTER_GROUP_UNIT(i, g, uid) ((i)->units + (g)->unitIdxs[uid])
|
||||
#define FILTER_UNIT_LEFT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->left)
|
||||
|
@ -336,14 +445,37 @@ struct SFilterInfo {
|
|||
#define FILTER_UNIT_GET_R(i, idx) ((i)->unitRes[idx])
|
||||
#define FILTER_UNIT_SET_R(i, idx, v) (i)->unitRes[idx] = (v)
|
||||
|
||||
#define FILTER_PUSH_UNIT(colInfo, u) do { (colInfo).type = RANGE_TYPE_UNIT; (colInfo).dataType = FILTER_UNIT_DATA_TYPE(u);taosArrayPush((SArray *)((colInfo).info), &u);} while (0)
|
||||
#define FILTER_PUSH_VAR_HASH(colInfo, ha) do { (colInfo).type = RANGE_TYPE_VAR_HASH; (colInfo).info = ha;} while (0)
|
||||
#define FILTER_PUSH_CTX(colInfo, ctx) do { (colInfo).type = RANGE_TYPE_MR_CTX; (colInfo).info = ctx;} while (0)
|
||||
#define FILTER_PUSH_UNIT(colInfo, u) \
|
||||
do { \
|
||||
(colInfo).type = RANGE_TYPE_UNIT; \
|
||||
(colInfo).dataType = FILTER_UNIT_DATA_TYPE(u); \
|
||||
taosArrayPush((SArray *)((colInfo).info), &u); \
|
||||
} while (0)
|
||||
#define FILTER_PUSH_VAR_HASH(colInfo, ha) \
|
||||
do { \
|
||||
(colInfo).type = RANGE_TYPE_VAR_HASH; \
|
||||
(colInfo).info = ha; \
|
||||
} while (0)
|
||||
#define FILTER_PUSH_CTX(colInfo, ctx) \
|
||||
do { \
|
||||
(colInfo).type = RANGE_TYPE_MR_CTX; \
|
||||
(colInfo).info = ctx; \
|
||||
} while (0)
|
||||
|
||||
#define FILTER_COPY_IDX(dst, src, n) do { *(dst) = taosMemoryMalloc(sizeof(uint32_t) * n); memcpy(*(dst), src, sizeof(uint32_t) * n);} while (0)
|
||||
|
||||
#define FILTER_ADD_CTX_TO_GRES(gres, idx, ctx) do { if ((gres)->colCtxs == NULL) { (gres)->colCtxs = taosArrayInit(gres->colNum, sizeof(SFilterColCtx)); } SFilterColCtx cCtx = {idx, ctx}; taosArrayPush((gres)->colCtxs, &cCtx); } while (0)
|
||||
#define FILTER_COPY_IDX(dst, src, n) \
|
||||
do { \
|
||||
*(dst) = taosMemoryMalloc(sizeof(uint32_t) * n); \
|
||||
memcpy(*(dst), src, sizeof(uint32_t) * n); \
|
||||
} while (0)
|
||||
|
||||
#define FILTER_ADD_CTX_TO_GRES(gres, idx, ctx) \
|
||||
do { \
|
||||
if ((gres)->colCtxs == NULL) { \
|
||||
(gres)->colCtxs = taosArrayInit(gres->colNum, sizeof(SFilterColCtx)); \
|
||||
} \
|
||||
SFilterColCtx cCtx = {idx, ctx}; \
|
||||
taosArrayPush((gres)->colCtxs, &cCtx); \
|
||||
} while (0)
|
||||
|
||||
#define FILTER_ALL_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_ALL)
|
||||
#define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY)
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "query.h"
|
||||
#include "tcommon.h"
|
||||
#include "thash.h"
|
||||
#include "query.h"
|
||||
|
||||
typedef struct SOperatorValueType {
|
||||
int32_t opResType;
|
||||
|
@ -31,23 +31,28 @@ typedef struct SOperatorValueType {
|
|||
typedef struct SScalarCtx {
|
||||
int32_t code;
|
||||
bool dual;
|
||||
SArray *pBlockList; /* element is SSDataBlock* */
|
||||
SHashObj *pRes; /* element is SScalarParam */
|
||||
void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
||||
SArray* pBlockList; /* element is SSDataBlock* */
|
||||
SHashObj* pRes; /* element is SScalarParam */
|
||||
void* param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
||||
SOperatorValueType type;
|
||||
} SScalarCtx;
|
||||
|
||||
|
||||
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
||||
#define SCL_DEFAULT_OP_NUM 10
|
||||
|
||||
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||
#define SCL_IS_CONST_NODE(_node) \
|
||||
((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
||||
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
||||
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
|
||||
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode
|
||||
//*)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
||||
#define SCL_IS_NULL_VALUE_NODE(_node) \
|
||||
((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode*)_node)->node.resType.type))
|
||||
#define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN)
|
||||
#define SCL_DOWNGRADE_DATETYPE(_type) ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT)
|
||||
#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) (IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && ((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL))
|
||||
#define SCL_DOWNGRADE_DATETYPE(_type) \
|
||||
((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT)
|
||||
#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) \
|
||||
(IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && \
|
||||
((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL))
|
||||
|
||||
#define sclFatal(...) qFatal(__VA_ARGS__)
|
||||
#define sclError(...) qError(__VA_ARGS__)
|
||||
|
@ -56,9 +61,30 @@ typedef struct SScalarCtx {
|
|||
#define sclDebug(...) qDebug(__VA_ARGS__)
|
||||
#define sclTrace(...) qTrace(__VA_ARGS__)
|
||||
|
||||
#define SCL_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
||||
#define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
||||
#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
||||
#define SCL_ERR_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
return _code; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SCL_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
} \
|
||||
return _code; \
|
||||
} while (0)
|
||||
#define SCL_ERR_JRET(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = code; \
|
||||
goto _return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow);
|
||||
int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam);
|
||||
|
@ -68,7 +94,7 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode);
|
|||
#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes)
|
||||
#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision)
|
||||
|
||||
void sclFreeParam(SScalarParam *param);
|
||||
void sclFreeParam(SScalarParam* param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType)
|
|||
return p;
|
||||
}
|
||||
|
||||
typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType, int32_t* overflow);
|
||||
typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order);
|
||||
typedef void (*_bufConverteFunc)(char *buf, SScalarParam *pOut, int32_t outType, int32_t *overflow);
|
||||
typedef void (*_bin_scalar_fn_t)(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *output, int32_t order);
|
||||
_bin_scalar_fn_t getBinScalarOperatorFn(int32_t binOperator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,4 @@
|
|||
#include "scalar.h"
|
||||
#include "function.h"
|
||||
#include "functionMgt.h"
|
||||
#include "nodes.h"
|
||||
|
@ -5,25 +6,25 @@
|
|||
#include "sclInt.h"
|
||||
#include "sclvector.h"
|
||||
#include "tcommon.h"
|
||||
#include "tdatablock.h"
|
||||
#include "scalar.h"
|
||||
#include "tudf.h"
|
||||
#include "ttime.h"
|
||||
#include "tcompare.h"
|
||||
#include "tdatablock.h"
|
||||
#include "ttime.h"
|
||||
#include "tudf.h"
|
||||
|
||||
int32_t scalarGetOperatorParamNum(EOperatorType type) {
|
||||
if (OP_TYPE_IS_NULL == type || OP_TYPE_IS_NOT_NULL == type || OP_TYPE_IS_TRUE == type || OP_TYPE_IS_NOT_TRUE == type
|
||||
|| OP_TYPE_IS_FALSE == type || OP_TYPE_IS_NOT_FALSE == type || OP_TYPE_IS_UNKNOWN == type || OP_TYPE_IS_NOT_UNKNOWN == type
|
||||
|| OP_TYPE_MINUS == type) {
|
||||
if (OP_TYPE_IS_NULL == type || OP_TYPE_IS_NOT_NULL == type || OP_TYPE_IS_TRUE == type ||
|
||||
OP_TYPE_IS_NOT_TRUE == type || OP_TYPE_IS_FALSE == type || OP_TYPE_IS_NOT_FALSE == type ||
|
||||
OP_TYPE_IS_UNKNOWN == type || OP_TYPE_IS_NOT_UNKNOWN == type || OP_TYPE_MINUS == type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode) {
|
||||
int32_t sclConvertToTsValueNode(int8_t precision, SValueNode *valueNode) {
|
||||
char *timeStr = valueNode->datum.p;
|
||||
int32_t code = convertStringToTimestamp(valueNode->node.resType.type, valueNode->datum.p, precision, &valueNode->datum.i);
|
||||
int32_t code =
|
||||
convertStringToTimestamp(valueNode->node.resType.type, valueNode->datum.p, precision, &valueNode->datum.i);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -36,8 +37,8 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam) {
|
||||
SColumnInfoData* pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarParam *pParam) {
|
||||
SColumnInfoData *pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
if (pColumnData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
|
@ -60,7 +61,7 @@ int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarPara
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow) {
|
||||
int32_t doConvertDataType(SValueNode *pValueNode, SScalarParam *out, int32_t *overflow) {
|
||||
SScalarParam in = {.numOfRows = 1};
|
||||
int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -111,7 +112,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
int32_t overflow = 0;
|
||||
code = doConvertDataType(valueNode, &out, &overflow);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// sclError("convert data from %d to %d failed", in.type, out.type);
|
||||
// sclError("convert data from %d to %d failed", in.type, out.type);
|
||||
SCL_ERR_JRET(code);
|
||||
}
|
||||
|
||||
|
@ -213,7 +214,7 @@ void sclFreeParamList(SScalarParam *param, int32_t paramNum) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < paramNum; ++i) {
|
||||
SScalarParam* p = param + i;
|
||||
SScalarParam *p = param + i;
|
||||
sclFreeParam(p);
|
||||
}
|
||||
|
||||
|
@ -226,33 +227,33 @@ void sclDowngradeValueType(SValueNode *valueNode) {
|
|||
int8_t i8 = valueNode->datum.i;
|
||||
if (i8 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_TINYINT;
|
||||
*(int8_t*)&valueNode->typeData = i8;
|
||||
*(int8_t *)&valueNode->typeData = i8;
|
||||
break;
|
||||
}
|
||||
int16_t i16 = valueNode->datum.i;
|
||||
if (i16 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_SMALLINT;
|
||||
*(int16_t*)&valueNode->typeData = i16;
|
||||
*(int16_t *)&valueNode->typeData = i16;
|
||||
break;
|
||||
}
|
||||
int32_t i32 = valueNode->datum.i;
|
||||
if (i32 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_INT;
|
||||
*(int32_t*)&valueNode->typeData = i32;
|
||||
*(int32_t *)&valueNode->typeData = i32;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT:{
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint8_t u8 = valueNode->datum.i;
|
||||
if (u8 == valueNode->datum.i) {
|
||||
int8_t i8 = valueNode->datum.i;
|
||||
if (i8 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_TINYINT;
|
||||
*(int8_t*)&valueNode->typeData = i8;
|
||||
*(int8_t *)&valueNode->typeData = i8;
|
||||
} else {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_UTINYINT;
|
||||
*(uint8_t*)&valueNode->typeData = u8;
|
||||
*(uint8_t *)&valueNode->typeData = u8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -261,10 +262,10 @@ void sclDowngradeValueType(SValueNode *valueNode) {
|
|||
int16_t i16 = valueNode->datum.i;
|
||||
if (i16 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_SMALLINT;
|
||||
*(int16_t*)&valueNode->typeData = i16;
|
||||
*(int16_t *)&valueNode->typeData = i16;
|
||||
} else {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_USMALLINT;
|
||||
*(uint16_t*)&valueNode->typeData = u16;
|
||||
*(uint16_t *)&valueNode->typeData = u16;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -273,10 +274,10 @@ void sclDowngradeValueType(SValueNode *valueNode) {
|
|||
int32_t i32 = valueNode->datum.i;
|
||||
if (i32 == valueNode->datum.i) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_INT;
|
||||
*(int32_t*)&valueNode->typeData = i32;
|
||||
*(int32_t *)&valueNode->typeData = i32;
|
||||
} else {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_UINT;
|
||||
*(uint32_t*)&valueNode->typeData = u32;
|
||||
*(uint32_t *)&valueNode->typeData = u32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -286,7 +287,7 @@ void sclDowngradeValueType(SValueNode *valueNode) {
|
|||
float f = valueNode->datum.d;
|
||||
if (FLT_EQUAL(f, valueNode->datum.d)) {
|
||||
valueNode->node.resType.type = TSDB_DATA_TYPE_FLOAT;
|
||||
*(float*)&valueNode->typeData = f;
|
||||
*(float *)&valueNode->typeData = f;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -296,10 +297,10 @@ void sclDowngradeValueType(SValueNode *valueNode) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) {
|
||||
int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) {
|
||||
switch (nodeType(node)) {
|
||||
case QUERY_NODE_LEFT_VALUE: {
|
||||
SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, 0);
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, 0);
|
||||
param->numOfRows = pb->info.rows;
|
||||
break;
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
|
||||
ASSERT(param->columnData == NULL);
|
||||
param->numOfRows = 1;
|
||||
/*int32_t code = */sclCreateColumnInfoData(&valueNode->node.resType, 1, param);
|
||||
/*int32_t code = */ sclCreateColumnInfoData(&valueNode->node.resType, 1, param);
|
||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) {
|
||||
colDataAppendNULL(param->columnData, 0);
|
||||
} else {
|
||||
|
@ -349,8 +350,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
SColumnNode *ref = (SColumnNode *)node;
|
||||
|
||||
int32_t index = -1;
|
||||
for(int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
if (pb->info.blockId == ref->dataBlockId) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -358,7 +359,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
}
|
||||
|
||||
if (index == -1) {
|
||||
sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", ref->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", ref->dataBlockId,
|
||||
(int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
|
@ -368,13 +370,15 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
}
|
||||
|
||||
if (ref->slotId >= taosArrayGetSize(block->pDataBlock)) {
|
||||
sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock));
|
||||
sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId,
|
||||
(int32_t)taosArrayGetSize(block->pDataBlock));
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
SColumnInfoData *columnData = (SColumnInfoData *)taosArrayGet(block->pDataBlock, ref->slotId);
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter column info, slotId:%d, colId:%d, type:%d", ref->slotId, columnData->info.colId, columnData->info.type);
|
||||
qDebug("tagfilter column info, slotId:%d, colId:%d, type:%d", ref->slotId, columnData->info.colId,
|
||||
columnData->info.type);
|
||||
#endif
|
||||
param->numOfRows = block->info.rows;
|
||||
param->columnData = columnData;
|
||||
|
@ -409,7 +413,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarCtx *ctx, int32_t *paramNum, int32_t *rowNum) {
|
||||
int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarCtx *ctx, int32_t *paramNum,
|
||||
int32_t *rowNum) {
|
||||
int32_t code = 0;
|
||||
if (NULL == pParamList) {
|
||||
if (ctx->pBlockList) {
|
||||
|
@ -434,7 +439,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC
|
|||
SNode *tnode = NULL;
|
||||
int32_t i = 0;
|
||||
if (SCL_IS_CONST_CALC(ctx)) {
|
||||
WHERE_EACH (tnode, pParamList) {
|
||||
WHERE_EACH(tnode, pParamList) {
|
||||
if (!SCL_IS_CONST_NODE(tnode)) {
|
||||
WHERE_NEXT;
|
||||
} else {
|
||||
|
@ -499,7 +504,6 @@ int32_t sclGetNodeType(SNode *pNode, SScalarCtx *ctx) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void sclSetOperatorValueType(SOperatorNode *node, SScalarCtx *ctx) {
|
||||
ctx->type.opResType = node->node.resType.type;
|
||||
ctx->type.selfType = sclGetNodeType(node->pLeft, ctx);
|
||||
|
@ -577,7 +581,8 @@ _return:
|
|||
|
||||
int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||
sclError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||
sclError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList,
|
||||
node->pParameterList ? node->pParameterList->length : 0);
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
|
@ -621,7 +626,7 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
complete = false;
|
||||
continue;
|
||||
}
|
||||
char* p = colDataGetData(params[m].columnData, i);
|
||||
char *p = colDataGetData(params[m].columnData, i);
|
||||
GET_TYPED_DATA(value, bool, params[m].columnData->info.type, p);
|
||||
|
||||
if (LOGIC_COND_TYPE_AND == node->condType && (false == value)) {
|
||||
|
@ -636,7 +641,7 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
}
|
||||
|
||||
if (complete) {
|
||||
colDataAppend(output->columnData, i, (char*) &value, false);
|
||||
colDataAppend(output->columnData, i, (char *)&value, false);
|
||||
if (value) {
|
||||
numOfQualified++;
|
||||
}
|
||||
|
@ -663,7 +668,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
|
|||
// json not support in in operator
|
||||
if (nodeType(node->pLeft) == QUERY_NODE_VALUE) {
|
||||
SValueNode *valueNode = (SValueNode *)node->pLeft;
|
||||
if (valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)) {
|
||||
if (valueNode->node.resType.type == TSDB_DATA_TYPE_JSON &&
|
||||
(node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)) {
|
||||
SCL_RET(TSDB_CODE_QRY_JSON_IN_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -679,8 +685,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
|
|||
_bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(node->opType);
|
||||
|
||||
int32_t paramNum = scalarGetOperatorParamNum(node->opType);
|
||||
SScalarParam* pLeft = ¶ms[0];
|
||||
SScalarParam* pRight = paramNum > 1 ? ¶ms[1] : NULL;
|
||||
SScalarParam *pLeft = ¶ms[0];
|
||||
SScalarParam *pRight = paramNum > 1 ? ¶ms[1] : NULL;
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC);
|
||||
|
@ -692,7 +698,7 @@ _return:
|
|||
SCL_RET(code);
|
||||
}
|
||||
|
||||
EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||
EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||
if (opType <= OP_TYPE_CALC_MAX) {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == res) {
|
||||
|
@ -704,7 +710,7 @@ EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opTy
|
|||
res->node.resType.type = TSDB_DATA_TYPE_NULL;
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
*pNode = (SNode *)res;
|
||||
} else {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == res) {
|
||||
|
@ -718,17 +724,17 @@ EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opTy
|
|||
res->datum.b = false;
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
*pNode = (SNode *)res;
|
||||
}
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclAggFuncWalker(SNode* pNode, void* pContext) {
|
||||
EDealRes sclAggFuncWalker(SNode *pNode, void *pContext) {
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||
*(bool*)pContext = fmIsAggFunc(pFunc->funcId);
|
||||
if (*(bool*)pContext) {
|
||||
SFunctionNode *pFunc = (SFunctionNode *)pNode;
|
||||
*(bool *)pContext = fmIsAggFunc(pFunc->funcId);
|
||||
if (*(bool *)pContext) {
|
||||
return DEAL_RES_END;
|
||||
}
|
||||
}
|
||||
|
@ -736,27 +742,26 @@ EDealRes sclAggFuncWalker(SNode* pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
bool sclContainsAggFuncNode(SNode* pNode) {
|
||||
bool sclContainsAggFuncNode(SNode *pNode) {
|
||||
bool aggFunc = false;
|
||||
nodesWalkExpr(pNode, sclAggFuncWalker, (void *)&aggFunc);
|
||||
return aggFunc;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
int32_t code = 0;
|
||||
|
||||
if (node->pLeft && (QUERY_NODE_VALUE == nodeType(node->pLeft))) {
|
||||
SValueNode *valueNode = (SValueNode *)node->pLeft;
|
||||
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)
|
||||
&& (!sclContainsAggFuncNode(node->pRight))) {
|
||||
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) &&
|
||||
(!sclContainsAggFuncNode(node->pRight))) {
|
||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight)
|
||||
&& ((SExprNode*)node->pRight)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode*)node->pRight)->resType.precision, valueNode);
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight) &&
|
||||
((SExprNode *)node->pRight)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode *)node->pRight)->resType.precision, valueNode);
|
||||
if (code) {
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -770,14 +775,14 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
if (node->pRight && (QUERY_NODE_VALUE == nodeType(node->pRight))) {
|
||||
SValueNode *valueNode = (SValueNode *)node->pRight;
|
||||
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)
|
||||
&& (!sclContainsAggFuncNode(node->pLeft))) {
|
||||
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) &&
|
||||
(!sclContainsAggFuncNode(node->pLeft))) {
|
||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft)
|
||||
&& ((SExprNode*)node->pLeft)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode*)node->pLeft)->resType.precision, valueNode);
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft) &&
|
||||
((SExprNode *)node->pLeft)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode *)node->pLeft)->resType.precision, valueNode);
|
||||
if (code) {
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -791,13 +796,13 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
|
||||
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
|
||||
SNode* tnode = NULL;
|
||||
SNode *tnode = NULL;
|
||||
WHERE_EACH(tnode, listNode->pNodeList) {
|
||||
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
|
||||
if (node->opType == OP_TYPE_IN) {
|
||||
ERASE_NODE(listNode->pNodeList);
|
||||
continue;
|
||||
} else { //OP_TYPE_NOT_IN
|
||||
} else { // OP_TYPE_NOT_IN
|
||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
}
|
||||
|
@ -813,9 +818,9 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
||||
SFunctionNode *node = (SFunctionNode *)*pNode;
|
||||
SNode* tnode = NULL;
|
||||
SNode *tnode = NULL;
|
||||
if (!fmIsScalarFunc(node->funcId) && (!ctx->dual)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -851,12 +856,12 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
|||
res->isNull = true;
|
||||
} else {
|
||||
int32_t type = output.columnData->info.type;
|
||||
if (type == TSDB_DATA_TYPE_JSON){
|
||||
if (type == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t len = getJsonValueLen(output.columnData->pData);
|
||||
res->datum.p = taosMemoryCalloc(len, 1);
|
||||
memcpy(res->datum.p, output.columnData->pData, len);
|
||||
} else if (IS_VAR_DATA_TYPE(type)) {
|
||||
//res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1);
|
||||
// res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1);
|
||||
res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1, 1);
|
||||
res->node.resType.bytes = varDataTLen(output.columnData->pData);
|
||||
memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
|
||||
|
@ -866,13 +871,13 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
*pNode = (SNode *)res;
|
||||
|
||||
sclFreeParam(&output);
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
||||
SLogicConditionNode *node = (SLogicConditionNode *)*pNode;
|
||||
|
||||
SScalarParam output = {0};
|
||||
|
@ -905,13 +910,13 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
*pNode = (SNode *)res;
|
||||
|
||||
sclFreeParam(&output);
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
|
||||
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
||||
|
@ -949,13 +954,13 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
*pNode = (SNode *)res;
|
||||
|
||||
sclFreeParam(&output);
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
|
||||
EDealRes sclConstantsRewriter(SNode **pNode, void *pContext) {
|
||||
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
||||
|
||||
if (QUERY_NODE_FUNCTION == nodeType(*pNode)) {
|
||||
|
@ -973,7 +978,7 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclWalkFunction(SNode *pNode, SScalarCtx *ctx) {
|
||||
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
|
@ -990,7 +995,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclWalkLogic(SNode *pNode, SScalarCtx *ctx) {
|
||||
SLogicConditionNode *node = (SLogicConditionNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
|
@ -1007,7 +1012,7 @@ EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclWalkOperator(SNode *pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
|
@ -1024,18 +1029,19 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
|
||||
EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
|
||||
STargetNode *target = (STargetNode *)pNode;
|
||||
|
||||
if (target->dataBlockId >= taosArrayGetSize(ctx->pBlockList)) {
|
||||
sclError("target tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
sclError("target tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId,
|
||||
(int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
int32_t index = -1;
|
||||
for(int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) {
|
||||
SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i);
|
||||
if (pb->info.blockId == target->dataBlockId) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -1043,7 +1049,8 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
if (index == -1) {
|
||||
sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId,
|
||||
(int32_t)taosArrayGetSize(ctx->pBlockList));
|
||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -1051,7 +1058,8 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
|
|||
SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, index);
|
||||
|
||||
if (target->slotId >= taosArrayGetSize(block->pDataBlock)) {
|
||||
sclError("target slot not exist, dataBlockId:%d, slotId:%d, dataBlockNum:%d", target->dataBlockId, target->slotId, (int32_t)taosArrayGetSize(block->pDataBlock));
|
||||
sclError("target slot not exist, dataBlockId:%d, slotId:%d, dataBlockNum:%d", target->dataBlockId, target->slotId,
|
||||
(int32_t)taosArrayGetSize(block->pDataBlock));
|
||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -1074,8 +1082,9 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
|
||||
if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)|| QUERY_NODE_LEFT_VALUE == nodeType(pNode)) {
|
||||
EDealRes sclCalcWalker(SNode *pNode, void *pContext) {
|
||||
if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) ||
|
||||
QUERY_NODE_COLUMN == nodeType(pNode) || QUERY_NODE_LEFT_VALUE == nodeType(pNode)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1111,7 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
|
|||
}
|
||||
|
||||
int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) {
|
||||
SSDataBlock* pb = taosArrayGetP(pBlockList, 0);
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam));
|
||||
if (NULL == pLeft) {
|
||||
sclError("calloc %d failed", (int32_t)sizeof(SScalarParam));
|
||||
|
@ -1144,8 +1153,8 @@ _return:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t sclGetMinusOperatorResType(SOperatorNode* pOp) {
|
||||
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
|
||||
static int32_t sclGetMinusOperatorResType(SOperatorNode *pOp) {
|
||||
if (!IS_MATHABLE_TYPE(((SExprNode *)(pOp->pLeft))->resType.type)) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||
|
@ -1153,9 +1162,9 @@ static int32_t sclGetMinusOperatorResType(SOperatorNode* pOp) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sclGetMathOperatorResType(SOperatorNode* pOp) {
|
||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||
static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) {
|
||||
SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType;
|
||||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
|
||||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
|
||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
|
||||
|
@ -1175,12 +1184,12 @@ static int32_t sclGetMathOperatorResType(SOperatorNode* pOp) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sclGetCompOperatorResType(SOperatorNode* pOp) {
|
||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||
static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) {
|
||||
SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType;
|
||||
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
|
||||
((SExprNode*)(pOp->pRight))->resType = ldt;
|
||||
((SExprNode *)(pOp->pRight))->resType = ldt;
|
||||
} else if (nodesIsRegularOp(pOp)) {
|
||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
||||
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
@ -1191,9 +1200,9 @@ static int32_t sclGetCompOperatorResType(SOperatorNode* pOp) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sclGetJsonOperatorResType(SOperatorNode* pOp) {
|
||||
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
|
||||
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
|
||||
static int32_t sclGetJsonOperatorResType(SOperatorNode *pOp) {
|
||||
SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType;
|
||||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
@ -1206,20 +1215,15 @@ static int32_t sclGetJsonOperatorResType(SOperatorNode* pOp) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sclGetBitwiseOperatorResType(SOperatorNode* pOp) {
|
||||
static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) {
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, false, pRes); }
|
||||
|
||||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
||||
return sclCalcConstants(pNode, false, pRes);
|
||||
}
|
||||
|
||||
int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) {
|
||||
return sclCalcConstants(pNode, true, pRes);
|
||||
}
|
||||
int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, true, pRes); }
|
||||
|
||||
int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
||||
if (NULL == pNode || NULL == pBlockList) {
|
||||
|
@ -1264,9 +1268,9 @@ _return:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
||||
if (TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pLeft))->resType.type ||
|
||||
(NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pRight))->resType.type)) {
|
||||
int32_t scalarGetOperatorResultType(SOperatorNode *pOp) {
|
||||
if (TSDB_DATA_TYPE_BLOB == ((SExprNode *)(pOp->pLeft))->resType.type ||
|
||||
(NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode *)(pOp->pRight))->resType.type)) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
|
@ -1280,7 +1284,7 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
|
|||
case OP_TYPE_MINUS:
|
||||
return sclGetMinusOperatorResType(pOp);
|
||||
case OP_TYPE_ASSIGN:
|
||||
pOp->node.resType = ((SExprNode*)(pOp->pLeft))->resType;
|
||||
pOp->node.resType = ((SExprNode *)(pOp->pLeft))->resType;
|
||||
break;
|
||||
case OP_TYPE_BIT_AND:
|
||||
case OP_TYPE_BIT_OR:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "cJSON.h"
|
||||
#include "function.h"
|
||||
#include "scalar.h"
|
||||
#include "sclInt.h"
|
||||
|
@ -5,20 +6,17 @@
|
|||
#include "tdatablock.h"
|
||||
#include "tjson.h"
|
||||
#include "ttime.h"
|
||||
#include "cJSON.h"
|
||||
#include "vnode.h"
|
||||
|
||||
typedef float (*_float_fn)(float);
|
||||
typedef double (*_double_fn)(double);
|
||||
typedef double (*_double_fn_2)(double, double);
|
||||
typedef int (*_conv_fn)(int);
|
||||
typedef void (*_trim_fn)(char *, char*, int32_t, int32_t);
|
||||
typedef void (*_trim_fn)(char *, char *, int32_t, int32_t);
|
||||
typedef int16_t (*_len_fn)(char *, int32_t);
|
||||
|
||||
/** Math functions **/
|
||||
static double tlog(double v) {
|
||||
return log(v);
|
||||
}
|
||||
static double tlog(double v) { return log(v); }
|
||||
|
||||
static double tlog2(double v, double base) {
|
||||
double a = log(v);
|
||||
|
@ -47,7 +45,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -73,7 +71,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -86,7 +84,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -99,7 +97,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -112,7 +110,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
out[i] = (in[i] >= 0)? in[i] : -in[i];
|
||||
out[i] = (in[i] >= 0) ? in[i] : -in[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -133,7 +131,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) {
|
||||
static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _double_fn valFn) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
||||
SColumnInfoData *pInputData = pInput->columnData;
|
||||
|
@ -160,28 +158,26 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn_2 valFn) {
|
||||
static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput,
|
||||
_double_fn_2 valFn) {
|
||||
SColumnInfoData *pInputData[2];
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
_getDoubleValue_fn_t getValueFn[2];
|
||||
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
pInputData[i] = pInput[i].columnData;
|
||||
getValueFn[i]= getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i]));
|
||||
getValueFn[i] = getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i]));
|
||||
}
|
||||
|
||||
double *out = (double *)pOutputData->pData;
|
||||
double result;
|
||||
|
||||
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) ||
|
||||
IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
||||
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
||||
|
||||
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
if (pInput[0].numOfRows == pInput[1].numOfRows) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i) ||
|
||||
colDataIsNull_s(pInputData[1], i) ||
|
||||
hasNullType) {
|
||||
if (colDataIsNull_s(pInputData[0], i) || colDataIsNull_s(pInputData[1], i) || hasNullType) {
|
||||
colDataAppendNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -192,7 +188,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
out[i] = result;
|
||||
}
|
||||
}
|
||||
} else if (pInput[0].numOfRows == 1) { //left operand is constant
|
||||
} else if (pInput[0].numOfRows == 1) { // left operand is constant
|
||||
if (colDataIsNull_s(pInputData[0], 0) || hasNullType) {
|
||||
colDataAppendNNULL(pOutputData, 0, pInput[1].numOfRows);
|
||||
} else {
|
||||
|
@ -236,7 +232,8 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _float_fn f1, _double_fn d1) {
|
||||
static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _float_fn f1,
|
||||
_double_fn d1) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
||||
SColumnInfoData *pInputData = pInput->columnData;
|
||||
|
@ -288,14 +285,12 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
}
|
||||
|
||||
/** String functions **/
|
||||
static int16_t tlength(char *input, int32_t type) {
|
||||
return varDataLen(input);
|
||||
}
|
||||
static int16_t tlength(char *input, int32_t type) { return varDataLen(input); }
|
||||
|
||||
static int16_t tcharlength(char *input, int32_t type) {
|
||||
if (type == TSDB_DATA_TYPE_VARCHAR) {
|
||||
return varDataLen(input);
|
||||
} else { //NCHAR
|
||||
} else { // NCHAR
|
||||
return varDataLen(input) / TSDB_NCHAR_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +304,7 @@ static void tltrim(char *input, char *output, int32_t type, int32_t charLen) {
|
|||
}
|
||||
numOfSpaces++;
|
||||
}
|
||||
} else { //NCHAR
|
||||
} else { // NCHAR
|
||||
for (int32_t i = 0; i < charLen; ++i) {
|
||||
if (!iswspace(*((uint32_t *)varDataVal(input) + i))) {
|
||||
break;
|
||||
|
@ -339,7 +334,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) {
|
|||
}
|
||||
numOfSpaces++;
|
||||
}
|
||||
} else { //NCHAR
|
||||
} else { // NCHAR
|
||||
for (int32_t i = charLen - 1; i >= 0; --i) {
|
||||
if (!iswspace(*((uint32_t *)varDataVal(input) + i))) {
|
||||
break;
|
||||
|
@ -451,8 +446,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||
bool hasNull = false;
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
if (colDataIsNull_s(pInputData[i], k) ||
|
||||
IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) {
|
||||
if (colDataIsNull_s(pInputData[i], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) {
|
||||
colDataAppendNULL(pOutputData, k);
|
||||
hasNull = true;
|
||||
break;
|
||||
|
@ -463,7 +457,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
int16_t dataLen = 0;
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
int32_t rowIdx = (pInput[i].numOfRows == 1) ? 0 : k;
|
||||
|
@ -489,7 +482,6 @@ DONE:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
int32_t ret = TSDB_CODE_SUCCESS;
|
||||
SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *));
|
||||
|
@ -515,7 +507,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
int32_t numOfNulls = getNumOfNullEntries(pInputData[i], pInput[i].numOfRows);
|
||||
if (i == 0) {
|
||||
// calculate required separator space
|
||||
inputLen += (pInputData[0]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * (inputNum - 2) * factor;
|
||||
inputLen +=
|
||||
(pInputData[0]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * (inputNum - 2) * factor;
|
||||
} else if (pInput[i].numOfRows == 1) {
|
||||
inputLen += (pInputData[i]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * factor;
|
||||
} else {
|
||||
|
@ -528,8 +521,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
char *output = outputBuf;
|
||||
|
||||
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||
if (colDataIsNull_s(pInputData[0], k) ||
|
||||
IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0]))) {
|
||||
if (colDataIsNull_s(pInputData[0], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0]))) {
|
||||
colDataAppendNULL(pOutputData, k);
|
||||
continue;
|
||||
}
|
||||
|
@ -537,8 +529,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
int16_t dataLen = 0;
|
||||
bool hasNull = false;
|
||||
for (int32_t i = 1; i < inputNum; ++i) {
|
||||
if (colDataIsNull_s(pInputData[i], k) ||
|
||||
IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) {
|
||||
if (colDataIsNull_s(pInputData[i], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) {
|
||||
hasNull = true;
|
||||
break;
|
||||
}
|
||||
|
@ -551,9 +542,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
goto DONE;
|
||||
}
|
||||
|
||||
|
||||
if (i < inputNum - 1) {
|
||||
//insert the separator
|
||||
// insert the separator
|
||||
char *sep = (pInput[0].numOfRows == 1) ? colDataGetData(pInputData[0], 0) : colDataGetData(pInputData[0], k);
|
||||
ret = concatCopyHelper(sep, output, hasNchar, GET_PARAM_TYPE(&pInput[0]), &dataLen);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
|
@ -604,7 +594,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala
|
|||
for (int32_t j = 0; j < len; ++j) {
|
||||
*(varDataVal(output) + j) = convFn(*(varDataVal(input) + j));
|
||||
}
|
||||
} else { //NCHAR
|
||||
} else { // NCHAR
|
||||
for (int32_t j = 0; j < len / TSDB_NCHAR_SIZE; ++j) {
|
||||
*((uint32_t *)varDataVal(output) + j) = convFn(*((uint32_t *)varDataVal(input) + j));
|
||||
}
|
||||
|
@ -620,7 +610,6 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _trim_fn trimFn) {
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
||||
|
@ -682,7 +671,8 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? subPos - 1 : (subPos - 1) * TSDB_NCHAR_SIZE;
|
||||
startPosBytes = TMIN(startPosBytes, len);
|
||||
} else {
|
||||
startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE;
|
||||
startPosBytes =
|
||||
(GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE;
|
||||
startPosBytes = TMAX(startPosBytes, 0);
|
||||
}
|
||||
|
||||
|
@ -692,7 +682,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
}
|
||||
|
||||
varDataSetLen(output, resLen);
|
||||
colDataAppend(pOutputData, i , output, false);
|
||||
colDataAppend(pOutputData, i, output, false);
|
||||
output += varDataTLen(output);
|
||||
}
|
||||
|
||||
|
@ -710,8 +700,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
int64_t outputLen = GET_PARAM_BYTES(&pOutput[0]);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
char * convBuf = taosMemoryMalloc(inputLen);
|
||||
char * output = taosMemoryCalloc(1, outputLen + TSDB_NCHAR_SIZE);
|
||||
char *convBuf = taosMemoryMalloc(inputLen);
|
||||
char *output = taosMemoryCalloc(1, outputLen + TSDB_NCHAR_SIZE);
|
||||
char buf[400] = {0};
|
||||
|
||||
if (convBuf == NULL || output == NULL) {
|
||||
|
@ -727,7 +717,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
|
||||
char *input = colDataGetData(pInput[0].columnData, i);
|
||||
|
||||
switch(outputType) {
|
||||
switch (outputType) {
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||
memcpy(buf, varDataVal(input), varDataLen(input));
|
||||
|
@ -948,7 +938,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
case TSDB_DATA_TYPE_BINARY: {
|
||||
if (inputType == TSDB_DATA_TYPE_BOOL) {
|
||||
// NOTE: sprintf will append '\0' at the end of string
|
||||
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), *(int8_t *)input ? "true" : "false");
|
||||
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE),
|
||||
*(int8_t *)input ? "true" : "false");
|
||||
varDataSetLen(output, len);
|
||||
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||
int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE);
|
||||
|
@ -977,7 +968,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
int32_t len;
|
||||
if (inputType == TSDB_DATA_TYPE_BOOL) {
|
||||
char tmp[8] = {0};
|
||||
len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false" );
|
||||
len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false");
|
||||
bool ret = taosMbsToUcs4(tmp, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
|
@ -987,7 +978,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
varDataSetLen(output, len);
|
||||
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||
len = outputCharLen > varDataLen(input) ? varDataLen(input) : outputCharLen;
|
||||
bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output),
|
||||
outputLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
|
@ -1009,7 +1001,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
varDataSetLen(output, len);
|
||||
}
|
||||
|
||||
//for constant conversion, need to set proper length of pOutput description
|
||||
// for constant conversion, need to set proper length of pOutput description
|
||||
if (len < outputLen) {
|
||||
pOutput->columnData->info.bytes = len + VARSTR_HEADER_SIZE;
|
||||
}
|
||||
|
@ -1027,7 +1019,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
|
||||
pOutput->numOfRows = pInput->numOfRows;
|
||||
|
||||
_end:
|
||||
_end:
|
||||
taosMemoryFree(output);
|
||||
taosMemoryFree(convBuf);
|
||||
return code;
|
||||
|
@ -1037,7 +1029,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
||||
bool tzPresent = (inputNum == 2) ? true : false;
|
||||
char* tz;
|
||||
char *tz;
|
||||
int32_t tzLen;
|
||||
if (tzPresent) {
|
||||
tz = varDataVal(pInput[1].columnData->pData);
|
||||
|
@ -1079,7 +1071,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tmInfo);
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
||||
//add timezone string
|
||||
// add timezone string
|
||||
snprintf(buf + len, tzLen + 1, "%s", tz);
|
||||
len += tzLen;
|
||||
|
||||
|
@ -1095,7 +1087,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
if (tzInfo) {
|
||||
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||
} else {
|
||||
//search '-' backwards
|
||||
// search '-' backwards
|
||||
tzInfo = strrchr(buf, '-');
|
||||
if (tzInfo) {
|
||||
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||
|
@ -1151,25 +1143,25 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
char tmp[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||
SArray* pTagVals = taosArrayInit(8, sizeof(STagVal));
|
||||
STag* pTag = NULL;
|
||||
SArray *pTagVals = taosArrayInit(8, sizeof(STagVal));
|
||||
STag *pTag = NULL;
|
||||
|
||||
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||
tTagNew(pTagVals, 1, true, &pTag);
|
||||
}else{
|
||||
} else {
|
||||
char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[i];
|
||||
if (varDataLen(input) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){
|
||||
if (varDataLen(input) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||
taosArrayDestroy(pTagVals);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
memcpy(tmp, varDataVal(input), varDataLen(input));
|
||||
tmp[varDataLen(input)] = 0;
|
||||
if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){
|
||||
if (parseJsontoTagData(tmp, pTagVals, &pTag, NULL)) {
|
||||
tTagNew(pTagVals, 1, true, &pTag);
|
||||
}
|
||||
}
|
||||
|
||||
colDataAppend(pOutput->columnData, i, (const char*)pTag, false);
|
||||
colDataAppend(pOutput->columnData, i, (const char *)pTag, false);
|
||||
tTagFree(pTag);
|
||||
taosArrayDestroy(pTagVals);
|
||||
}
|
||||
|
@ -1186,8 +1178,8 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData);
|
||||
GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData);
|
||||
|
||||
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
||||
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||
int64_t factor =
|
||||
(timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||
|
||||
int64_t unit = timeUnit * 1000 / factor;
|
||||
|
||||
|
@ -1205,7 +1197,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
colDataAppendNULL(pOutput->columnData, i);
|
||||
continue;
|
||||
}
|
||||
//If converted value is less than 10digits in second, use value in second instead
|
||||
// If converted value is less than 10digits in second, use value in second instead
|
||||
int64_t timeValSec = timeVal / 1000000000;
|
||||
if (timeValSec < 1000000000) {
|
||||
timeVal = timeValSec;
|
||||
|
@ -1246,7 +1238,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
timeVal = timeVal / 1000 * 1000;
|
||||
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||
timeVal = timeVal / 1000000 * 1000000;
|
||||
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS){
|
||||
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||
timeVal = timeVal * factor;
|
||||
} else {
|
||||
colDataAppendNULL(pOutput->columnData, i);
|
||||
|
@ -1307,7 +1299,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||
timeVal = timeVal / 1000000000 / 86400 * 86400 * 1000000000;
|
||||
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||
timeVal = timeVal * factor / factor / 86400* 86400 * factor;
|
||||
timeVal = timeVal * factor / factor / 86400 * 86400 * factor;
|
||||
} else {
|
||||
colDataAppendNULL(pOutput->columnData, i);
|
||||
continue;
|
||||
|
@ -1322,7 +1314,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||
timeVal = timeVal / 1000000000 / 604800 * 604800 * 1000000000;
|
||||
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||
timeVal = timeVal * factor / factor / 604800 * 604800* factor;
|
||||
timeVal = timeVal * factor / factor / 604800 * 604800 * factor;
|
||||
} else {
|
||||
colDataAppendNULL(pOutput->columnData, i);
|
||||
continue;
|
||||
|
@ -1335,7 +1327,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
}
|
||||
}
|
||||
|
||||
//truncate the timestamp to db precision
|
||||
// truncate the timestamp to db precision
|
||||
switch (timePrec) {
|
||||
case TSDB_TIME_PRECISION_MILLI: {
|
||||
if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||
|
@ -1380,8 +1372,8 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData);
|
||||
}
|
||||
|
||||
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
||||
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||
int64_t factor =
|
||||
(timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||
|
||||
int32_t numOfRows = 0;
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
|
@ -1441,11 +1433,10 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
continue;
|
||||
}
|
||||
|
||||
int64_t result = (timeVal[0] >= timeVal[1]) ? (timeVal[0] - timeVal[1]) :
|
||||
(timeVal[1] - timeVal[0]);
|
||||
int64_t result = (timeVal[0] >= timeVal[1]) ? (timeVal[0] - timeVal[1]) : (timeVal[1] - timeVal[0]);
|
||||
|
||||
if (timeUnit < 0) { // if no time unit given use db precision
|
||||
switch(timePrec) {
|
||||
switch (timePrec) {
|
||||
case TSDB_TIME_PRECISION_MILLI: {
|
||||
result = result / 1000000;
|
||||
break;
|
||||
|
@ -1461,7 +1452,7 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
}
|
||||
} else {
|
||||
int64_t unit = timeUnit * 1000 / factor;
|
||||
switch(unit) {
|
||||
switch (unit) {
|
||||
case 0: { /* 1u or 1b */
|
||||
if (timePrec == TSDB_TIME_PRECISION_NANO && timeUnit == 1) {
|
||||
result = result / 1;
|
||||
|
@ -1694,7 +1685,7 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf
|
|||
}
|
||||
#endif
|
||||
|
||||
bool getTimePseudoFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||
bool getTimePseudoFuncEnv(SFunctionNode *UNUSED_PARAM(pFunc), SFuncExecEnv *pEnv) {
|
||||
pEnv->calcMemSize = sizeof(int64_t);
|
||||
return true;
|
||||
}
|
||||
|
@ -1719,13 +1710,13 @@ int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 3));
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 3));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 4));
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 4));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1813,12 +1804,12 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
break;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData->pData;
|
||||
int8_t *out = (int8_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1826,7 +1817,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *in = (int16_t *)pInputData->pData;
|
||||
int16_t *out = (int16_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1834,7 +1825,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *in = (int32_t *)pInputData->pData;
|
||||
int32_t *out = (int32_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1842,7 +1833,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t *in = (int64_t *)pInputData->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1850,7 +1841,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t *in = (uint8_t *)pInputData->pData;
|
||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1858,7 +1849,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t *in = (uint16_t *)pInputData->pData;
|
||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1866,7 +1857,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t *in = (uint32_t *)pInputData->pData;
|
||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1874,7 +1865,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t *in = (uint64_t *)pInputData->pData;
|
||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1882,7 +1873,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1890,7 +1881,7 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS
|
|||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double *in = (double *)pInputData->pData;
|
||||
double *out = (double *)pOutputData->pData;
|
||||
if((in[i] > *out) ^ isMinFunc) {
|
||||
if ((in[i] > *out) ^ isMinFunc) {
|
||||
*out = in[i];
|
||||
}
|
||||
break;
|
||||
|
@ -1928,7 +1919,7 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
break;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
|
@ -2026,7 +2017,7 @@ int32_t stddevScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
//int64_t count = 0, sum = 0, qSum = 0;
|
||||
// int64_t count = 0, sum = 0, qSum = 0;
|
||||
bool hasNull = false;
|
||||
|
||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||
|
@ -2155,7 +2146,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa
|
|||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
int64_t count = 0;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData->pData;
|
||||
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||
|
@ -2292,11 +2283,10 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa
|
|||
matrix12 /= matrix[1][1];
|
||||
|
||||
char buf[64] = {0};
|
||||
size_t len =
|
||||
snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02, matrix12);
|
||||
size_t len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02,
|
||||
matrix12);
|
||||
varDataSetLen(buf, len);
|
||||
colDataAppend(pOutputData, 0, buf, false);
|
||||
|
||||
}
|
||||
|
||||
pOutput->numOfRows = 1;
|
||||
|
@ -2469,7 +2459,7 @@ typedef enum {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
static int8_t getStateOpType(char* opStr) {
|
||||
static int8_t getStateOpType(char *opStr) {
|
||||
int8_t opType;
|
||||
if (strncasecmp(opStr, "LT", 2) == 0) {
|
||||
opType = STATE_OPER_LT;
|
||||
|
@ -2490,58 +2480,58 @@ static int8_t getStateOpType(char* opStr) {
|
|||
return opType;
|
||||
}
|
||||
|
||||
static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SScalarParam *pCondParam) {
|
||||
char* data = colDataGetData(pCol, index);
|
||||
char* param = pCondParam->columnData->pData;
|
||||
static bool checkStateOp(int8_t op, SColumnInfoData *pCol, int32_t index, SScalarParam *pCondParam) {
|
||||
char *data = colDataGetData(pCol, index);
|
||||
char *param = pCondParam->columnData->pData;
|
||||
int32_t paramType = GET_PARAM_TYPE(pCondParam);
|
||||
switch (pCol->info.type) {
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t v = *(int8_t*)data;
|
||||
int8_t v = *(int8_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t v = *(uint8_t*)data;
|
||||
uint8_t v = *(uint8_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t v = *(int16_t*)data;
|
||||
int16_t v = *(int16_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t v = *(uint16_t*)data;
|
||||
uint16_t v = *(uint16_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t v = *(int32_t*)data;
|
||||
int32_t v = *(int32_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t v = *(uint32_t*)data;
|
||||
uint32_t v = *(uint32_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t v = *(int64_t*)data;
|
||||
int64_t v = *(int64_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t v = *(uint64_t*)data;
|
||||
uint64_t v = *(uint64_t *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float v = *(float*)data;
|
||||
float v = *(float *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double v = *(double*)data;
|
||||
double v = *(double *)data;
|
||||
STATE_COMP(op, v, param, paramType);
|
||||
break;
|
||||
}
|
||||
|
@ -2572,7 +2562,7 @@ int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalar
|
|||
} else {
|
||||
count = 0;
|
||||
}
|
||||
colDataAppend(pOutputData, i, (char*)&out, false);
|
||||
colDataAppend(pOutputData, i, (char *)&out, false);
|
||||
}
|
||||
|
||||
pOutput->numOfRows = pInput->numOfRows;
|
||||
|
@ -2596,7 +2586,7 @@ int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SSca
|
|||
if (ret) {
|
||||
out = 0;
|
||||
}
|
||||
colDataAppend(pOutputData, i, (char*)&out, false);
|
||||
colDataAppend(pOutputData, i, (char *)&out, false);
|
||||
}
|
||||
|
||||
pOutput->numOfRows = pInput->numOfRows;
|
||||
|
@ -2605,7 +2595,7 @@ int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SSca
|
|||
|
||||
typedef enum { UNKNOWN_BIN = 0, USER_INPUT_BIN, LINEAR_BIN, LOG_BIN } EHistoBinType;
|
||||
|
||||
static int8_t getHistogramBinType(char* binTypeStr) {
|
||||
static int8_t getHistogramBinType(char *binTypeStr) {
|
||||
int8_t binType;
|
||||
if (strcasecmp(binTypeStr, "user_input") == 0) {
|
||||
binType = USER_INPUT_BIN;
|
||||
|
@ -2627,10 +2617,11 @@ typedef struct SHistoFuncBin {
|
|||
double percentage;
|
||||
} SHistoFuncBin;
|
||||
|
||||
static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* binDescStr, int8_t binType, bool normalized) {
|
||||
cJSON* binDesc = cJSON_Parse(binDescStr);
|
||||
static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *binDescStr, int8_t binType,
|
||||
bool normalized) {
|
||||
cJSON *binDesc = cJSON_Parse(binDescStr);
|
||||
int32_t numOfBins;
|
||||
double* intervals;
|
||||
double *intervals;
|
||||
if (cJSON_IsObject(binDesc)) { /* linaer/log bins */
|
||||
int32_t numOfParams = cJSON_GetArraySize(binDesc);
|
||||
int32_t startIndex;
|
||||
|
@ -2638,11 +2629,11 @@ static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* bin
|
|||
return false;
|
||||
}
|
||||
|
||||
cJSON* start = cJSON_GetObjectItem(binDesc, "start");
|
||||
cJSON* factor = cJSON_GetObjectItem(binDesc, "factor");
|
||||
cJSON* width = cJSON_GetObjectItem(binDesc, "width");
|
||||
cJSON* count = cJSON_GetObjectItem(binDesc, "count");
|
||||
cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||
cJSON *start = cJSON_GetObjectItem(binDesc, "start");
|
||||
cJSON *factor = cJSON_GetObjectItem(binDesc, "factor");
|
||||
cJSON *width = cJSON_GetObjectItem(binDesc, "width");
|
||||
cJSON *count = cJSON_GetObjectItem(binDesc, "count");
|
||||
cJSON *infinity = cJSON_GetObjectItem(binDesc, "infinity");
|
||||
|
||||
if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) {
|
||||
return false;
|
||||
|
@ -2719,7 +2710,7 @@ static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* bin
|
|||
}
|
||||
numOfBins = cJSON_GetArraySize(binDesc);
|
||||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||
cJSON* bin = binDesc->child;
|
||||
cJSON *bin = binDesc->child;
|
||||
if (bin == NULL) {
|
||||
taosMemoryFree(intervals);
|
||||
return false;
|
||||
|
@ -2764,7 +2755,7 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
int32_t totalCount = 0;
|
||||
|
||||
int8_t binType = getHistogramBinType(varDataVal(pInput[1].columnData->pData));
|
||||
char* binDesc = varDataVal(pInput[2].columnData->pData);
|
||||
char *binDesc = varDataVal(pInput[2].columnData->pData);
|
||||
int64_t normalized = *(int64_t *)(pInput[3].columnData->pData);
|
||||
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
@ -2777,7 +2768,7 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
continue;
|
||||
}
|
||||
|
||||
char* data = colDataGetData(pInputData, i);
|
||||
char *data = colDataGetData(pInputData, i);
|
||||
double v;
|
||||
GET_TYPED_DATA(v, double, type, data);
|
||||
|
||||
|
@ -2804,11 +2795,11 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
int32_t len;
|
||||
char buf[512] = {0};
|
||||
if (!normalized) {
|
||||
len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}",
|
||||
bins[k].lower, bins[k].upper, bins[k].count);
|
||||
len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}", bins[k].lower,
|
||||
bins[k].upper, bins[k].count);
|
||||
} else {
|
||||
len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}",
|
||||
bins[k].lower, bins[k].upper, bins[k].percentage);
|
||||
len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", bins[k].lower,
|
||||
bins[k].upper, bins[k].percentage);
|
||||
}
|
||||
varDataSetLen(buf, len);
|
||||
colDataAppend(pOutputData, k, buf, false);
|
||||
|
@ -2831,11 +2822,10 @@ int32_t selectScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
continue;
|
||||
}
|
||||
|
||||
char* data = colDataGetData(pInputData, i);
|
||||
char *data = colDataGetData(pInputData, i);
|
||||
colDataAppend(pOutputData, i, data, false);
|
||||
}
|
||||
|
||||
|
||||
pOutput->numOfRows = 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,19 +32,14 @@
|
|||
#endif
|
||||
#include "os.h"
|
||||
|
||||
#include "tglobal.h"
|
||||
#include "taos.h"
|
||||
#include "tdef.h"
|
||||
#include "tvariant.h"
|
||||
#include "tdatablock.h"
|
||||
#include "stub.h"
|
||||
#include "scalar.h"
|
||||
#include "filter.h"
|
||||
#include "nodes.h"
|
||||
#include "scalar.h"
|
||||
#include "stub.h"
|
||||
#include "taos.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tdef.h"
|
||||
#include "tglobal.h"
|
||||
#include "tlog.h"
|
||||
#include "tvariant.h"
|
||||
|
||||
|
@ -66,9 +61,8 @@ void flttInitLogFile() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vnode = (SValueNode *)node;
|
||||
vnode->node.resType.type = dataType;
|
||||
|
||||
|
@ -84,10 +78,11 @@ void flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
|||
*pNode = (SNode *)vnode;
|
||||
}
|
||||
|
||||
void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum, void *value) {
|
||||
void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum,
|
||||
void *value) {
|
||||
static uint64_t dbidx = 0;
|
||||
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode *rnode = (SColumnNode *)node;
|
||||
rnode->node.resType.type = dataType;
|
||||
rnode->node.resType.bytes = dataBytes;
|
||||
|
@ -106,7 +101,7 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
|
|||
if (NULL == *block) {
|
||||
SSDataBlock *res = createDataBlock();
|
||||
for (int32_t i = 0; i < 2; ++i) {
|
||||
SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1+i);
|
||||
SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1 + i);
|
||||
blockDataAppendColInfo(res, &idata);
|
||||
}
|
||||
|
||||
|
@ -133,7 +128,7 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
|
|||
SSDataBlock *res = *block;
|
||||
|
||||
int32_t idx = taosArrayGetSize(res->pDataBlock);
|
||||
SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1+idx);
|
||||
SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1 + idx);
|
||||
blockDataAppendColInfo(res, &idata);
|
||||
blockDataEnsureCapacity(res, rowNum);
|
||||
|
||||
|
@ -156,7 +151,7 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
|
|||
}
|
||||
|
||||
void flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
onode->node.resType.type = resType;
|
||||
onode->node.resType.bytes = tDataTypes[resType].bytes;
|
||||
|
@ -169,7 +164,7 @@ void flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode
|
|||
}
|
||||
|
||||
void flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||
onode->condType = opType;
|
||||
onode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -184,7 +179,7 @@ void flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeLi
|
|||
}
|
||||
|
||||
void flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeList *nodeList) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||
onode->condType = opType;
|
||||
onode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -196,7 +191,7 @@ void flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeL
|
|||
}
|
||||
|
||||
void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->dataType.type = resType;
|
||||
lnode->pNodeList = list;
|
||||
|
@ -204,12 +199,12 @@ void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
|||
*pNode = (SNode *)lnode;
|
||||
}
|
||||
|
||||
void initScalarParam(SScalarParam* pParam) {
|
||||
void initScalarParam(SScalarParam *pParam) {
|
||||
memset(pParam, 0, sizeof(SScalarParam));
|
||||
pParam->colAlloced = true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(timerangeTest, greater) {
|
||||
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL;
|
||||
|
@ -222,17 +217,17 @@ TEST(timerangeTest, greater) {
|
|||
flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval);
|
||||
|
||||
//SFilterInfo *filter = NULL;
|
||||
//int32_t code = filterInitFromNode(opNode1, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
//ASSERT_EQ(code, 0);
|
||||
// SFilterInfo *filter = NULL;
|
||||
// int32_t code = filterInitFromNode(opNode1, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
// ASSERT_EQ(code, 0);
|
||||
STimeWindow win = {0};
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange(opNode1, &win, &isStrict);
|
||||
ASSERT_EQ(code, 0);
|
||||
ASSERT_EQ(isStrict, true);
|
||||
ASSERT_EQ(win.skey, tsmall+1);
|
||||
ASSERT_EQ(win.skey, tsmall + 1);
|
||||
ASSERT_EQ(win.ekey, INT64_MAX);
|
||||
//filterFreeInfo(filter);
|
||||
// filterFreeInfo(filter);
|
||||
nodesDestroyNode(opNode1);
|
||||
}
|
||||
|
||||
|
@ -254,17 +249,17 @@ TEST(timerangeTest, greater_and_lower) {
|
|||
|
||||
flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2);
|
||||
|
||||
//SFilterInfo *filter = NULL;
|
||||
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
//ASSERT_EQ(code, 0);
|
||||
// SFilterInfo *filter = NULL;
|
||||
// int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
// ASSERT_EQ(code, 0);
|
||||
STimeWindow win = {0};
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange(logicNode, &win, &isStrict);
|
||||
ASSERT_EQ(isStrict, true);
|
||||
ASSERT_EQ(code, 0);
|
||||
ASSERT_EQ(win.skey, tsmall+1);
|
||||
ASSERT_EQ(win.ekey, tbig-1);
|
||||
//filterFreeInfo(filter);
|
||||
ASSERT_EQ(win.skey, tsmall + 1);
|
||||
ASSERT_EQ(win.ekey, tbig - 1);
|
||||
// filterFreeInfo(filter);
|
||||
nodesDestroyNode(logicNode);
|
||||
}
|
||||
|
||||
|
@ -286,9 +281,9 @@ TEST(timerangeTest, greater_equal_and_lower_equal) {
|
|||
|
||||
flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2);
|
||||
|
||||
//SFilterInfo *filter = NULL;
|
||||
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
//ASSERT_EQ(code, 0);
|
||||
// SFilterInfo *filter = NULL;
|
||||
// int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
// ASSERT_EQ(code, 0);
|
||||
STimeWindow win = {0};
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange(logicNode, &win, &isStrict);
|
||||
|
@ -296,11 +291,10 @@ TEST(timerangeTest, greater_equal_and_lower_equal) {
|
|||
ASSERT_EQ(code, 0);
|
||||
ASSERT_EQ(win.skey, tsmall);
|
||||
ASSERT_EQ(win.ekey, tbig);
|
||||
//filterFreeInfo(filter);
|
||||
// filterFreeInfo(filter);
|
||||
nodesDestroyNode(logicNode);
|
||||
}
|
||||
|
||||
|
||||
TEST(timerangeTest, greater_and_lower_not_strict) {
|
||||
SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
bool eRes[5] = {false, false, true, true, true};
|
||||
|
@ -336,31 +330,29 @@ TEST(timerangeTest, greater_and_lower_not_strict) {
|
|||
list[1] = logicNode2;
|
||||
flttMakeLogicNode(&logicNode1, LOGIC_COND_TYPE_OR, list, 2);
|
||||
|
||||
//SFilterInfo *filter = NULL;
|
||||
//int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
//ASSERT_EQ(code, 0);
|
||||
// SFilterInfo *filter = NULL;
|
||||
// int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP);
|
||||
// ASSERT_EQ(code, 0);
|
||||
STimeWindow win = {0};
|
||||
bool isStrict = false;
|
||||
int32_t code = filterGetTimeRange(logicNode1, &win, &isStrict);
|
||||
ASSERT_EQ(isStrict, false);
|
||||
ASSERT_EQ(code, 0);
|
||||
ASSERT_EQ(win.skey, tsmall1+1);
|
||||
ASSERT_EQ(win.ekey, tbig2-1);
|
||||
//filterFreeInfo(filter);
|
||||
ASSERT_EQ(win.skey, tsmall1 + 1);
|
||||
ASSERT_EQ(win.ekey, tbig2 - 1);
|
||||
// filterFreeInfo(filter);
|
||||
nodesDestroyNode(logicNode1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(columnTest, smallint_column_greater_double_value) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int16_t leftv[5]= {1, 2, 3, 4, 5};
|
||||
double rightv= 2.5;
|
||||
int16_t leftv[5] = {1, 2, 3, 4, 5};
|
||||
double rightv = 2.5;
|
||||
int8_t eRes[5] = {0, 0, 1, 1, 1};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||
|
@ -388,7 +380,7 @@ TEST(columnTest, smallint_column_greater_double_value) {
|
|||
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
||||
ASSERT_EQ(keep, true);
|
||||
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -396,7 +388,7 @@ TEST(columnTest, smallint_column_greater_double_value) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -410,13 +402,13 @@ TEST(columnTest, smallint_column_greater_double_value) {
|
|||
|
||||
TEST(columnTest, int_column_greater_smallint_value) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int32_t leftv[5]= {1, 3, 5, 7, 9};
|
||||
int16_t rightv= 4;
|
||||
int32_t leftv[5] = {1, 3, 5, 7, 9};
|
||||
int16_t rightv = 4;
|
||||
int8_t eRes[5] = {0, 0, 1, 1, 1};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||
|
@ -444,7 +436,7 @@ TEST(columnTest, int_column_greater_smallint_value) {
|
|||
keep = filterRangeExecute(filter, &stat, 1, rowNum);
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -452,7 +444,7 @@ TEST(columnTest, int_column_greater_smallint_value) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -467,21 +459,21 @@ TEST(columnTest, int_column_greater_smallint_value) {
|
|||
TEST(columnTest, int_column_in_double_list) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL;
|
||||
int32_t leftv[5] = {1, 2, 3, 4, 5};
|
||||
double rightv1 = 1.1,rightv2 = 2.2,rightv3 = 3.3;
|
||||
double rightv1 = 1.1, rightv2 = 2.2, rightv3 = 3.3;
|
||||
bool eRes[5] = {true, true, true, false, false};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv);
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv1);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv2);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv3);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT);
|
||||
flttMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode);
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
|
@ -489,7 +481,7 @@ TEST(columnTest, int_column_in_double_list) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -497,7 +489,7 @@ TEST(columnTest, int_column_in_double_list) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -516,8 +508,8 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
char leftv[5][5]= {0};
|
||||
char rightv[3][5]= {0};
|
||||
char leftv[5][5] = {0};
|
||||
char rightv[3][5] = {0};
|
||||
for (int32_t i = 0; i < 5; ++i) {
|
||||
leftv[i][2] = 'a' + i;
|
||||
leftv[i][3] = 'b' + i;
|
||||
|
@ -537,16 +529,16 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
varDataSetLen(rightv[i], 3);
|
||||
}
|
||||
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[0]);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[1]);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[2]);
|
||||
nodesListAppend(list, pRight);
|
||||
flttMakeListNode(&listNode,list, TSDB_DATA_TYPE_BINARY);
|
||||
flttMakeListNode(&listNode, list, TSDB_DATA_TYPE_BINARY);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode);
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
|
@ -554,7 +546,7 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -562,7 +554,7 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -577,7 +569,7 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
TEST(columnTest, binary_column_like_binary) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
char rightv[64] = {0};
|
||||
char leftv[5][5]= {0};
|
||||
char leftv[5][5] = {0};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
|
@ -590,7 +582,7 @@ TEST(columnTest, binary_column_like_binary) {
|
|||
varDataSetLen(leftv[i], 3);
|
||||
}
|
||||
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
|
||||
sprintf(&rightv[2], "%s", "__0");
|
||||
|
@ -603,7 +595,7 @@ TEST(columnTest, binary_column_like_binary) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -611,7 +603,7 @@ TEST(columnTest, binary_column_like_binary) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -625,7 +617,7 @@ TEST(columnTest, binary_column_like_binary) {
|
|||
|
||||
TEST(columnTest, binary_column_is_null) {
|
||||
SNode *pLeft = NULL, *opNode = NULL;
|
||||
char leftv[5][5]= {0};
|
||||
char leftv[5][5] = {0};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
|
@ -638,7 +630,7 @@ TEST(columnTest, binary_column_is_null) {
|
|||
varDataSetLen(leftv[i], 3);
|
||||
}
|
||||
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
|
||||
SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock);
|
||||
|
@ -651,7 +643,7 @@ TEST(columnTest, binary_column_is_null) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -659,7 +651,7 @@ TEST(columnTest, binary_column_is_null) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -673,7 +665,7 @@ TEST(columnTest, binary_column_is_null) {
|
|||
|
||||
TEST(columnTest, binary_column_is_not_null) {
|
||||
SNode *pLeft = NULL, *opNode = NULL;
|
||||
char leftv[5][5]= {0};
|
||||
char leftv[5][5] = {0};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
|
@ -686,7 +678,7 @@ TEST(columnTest, binary_column_is_not_null) {
|
|||
varDataSetLen(leftv[i], 3);
|
||||
}
|
||||
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
|
||||
SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock);
|
||||
|
@ -699,7 +691,7 @@ TEST(columnTest, binary_column_is_not_null) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -707,7 +699,7 @@ TEST(columnTest, binary_column_is_not_null) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -722,12 +714,12 @@ TEST(columnTest, binary_column_is_not_null) {
|
|||
TEST(opTest, smallint_column_greater_int_column) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int16_t leftv[5] = {1, -6, -2, 11, 101};
|
||||
int32_t rightv[5]= {0, -5, -4, 23, 100};
|
||||
int32_t rightv[5] = {0, -5, -4, 23, 100};
|
||||
bool eRes[5] = {true, false, true, false, true};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]);
|
||||
int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv);
|
||||
flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||
|
@ -737,7 +729,7 @@ TEST(opTest, smallint_column_greater_int_column) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -745,7 +737,7 @@ TEST(opTest, smallint_column_greater_int_column) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -760,12 +752,12 @@ TEST(opTest, smallint_column_greater_int_column) {
|
|||
TEST(opTest, smallint_value_add_int_column) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int32_t leftv = 1;
|
||||
int16_t rightv[5]= {0, -1, -4, -1, 100};
|
||||
int16_t rightv[5] = {0, -1, -4, -1, 100};
|
||||
bool eRes[5] = {true, false, true, false, true};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]);
|
||||
int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]);
|
||||
flttMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
|
||||
flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||
|
@ -776,7 +768,7 @@ TEST(opTest, smallint_value_add_int_column) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -784,7 +776,7 @@ TEST(opTest, smallint_value_add_int_column) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -798,8 +790,8 @@ TEST(opTest, smallint_value_add_int_column) {
|
|||
|
||||
TEST(opTest, bigint_column_multi_binary_column) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int64_t leftv[5]= {1, 2, 3, 4, 5};
|
||||
char rightv[5][5]= {0};
|
||||
int64_t leftv[5] = {1, 2, 3, 4, 5};
|
||||
char rightv[5][5] = {0};
|
||||
for (int32_t i = 0; i < 5; ++i) {
|
||||
rightv[i][2] = rightv[i][3] = '0';
|
||||
rightv[i][4] = '0' + i;
|
||||
|
@ -809,7 +801,7 @@ TEST(opTest, bigint_column_multi_binary_column) {
|
|||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]);
|
||||
int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, leftv);
|
||||
flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||
|
@ -820,7 +812,7 @@ TEST(opTest, bigint_column_multi_binary_column) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -828,7 +820,7 @@ TEST(opTest, bigint_column_multi_binary_column) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -842,8 +834,8 @@ TEST(opTest, bigint_column_multi_binary_column) {
|
|||
|
||||
TEST(opTest, smallint_column_and_binary_column) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int16_t leftv[5]= {1, 2, 3, 4, 5};
|
||||
char rightv[5][5]= {0};
|
||||
int16_t leftv[5] = {1, 2, 3, 4, 5};
|
||||
char rightv[5][5] = {0};
|
||||
for (int32_t i = 0; i < 5; ++i) {
|
||||
rightv[i][2] = rightv[i][3] = '0';
|
||||
rightv[i][4] = '0' + i;
|
||||
|
@ -853,7 +845,7 @@ TEST(opTest, smallint_column_and_binary_column) {
|
|||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]);
|
||||
int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv);
|
||||
flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
|
@ -864,7 +856,7 @@ TEST(opTest, smallint_column_and_binary_column) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -872,7 +864,7 @@ TEST(opTest, smallint_column_and_binary_column) {
|
|||
stat.min = 1;
|
||||
stat.numOfNull = 0;
|
||||
int8_t *rowRes = NULL;
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock));
|
||||
bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock));
|
||||
ASSERT_EQ(keep, false);
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -886,13 +878,13 @@ TEST(opTest, smallint_column_and_binary_column) {
|
|||
|
||||
TEST(opTest, smallint_column_or_float_column) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int16_t leftv[5]= {1, 2, 0, 4, 5};
|
||||
float rightv[5]= {2.0, 3.0, 0, 5.2, 6.0};
|
||||
int16_t leftv[5] = {1, 2, 0, 4, 5};
|
||||
float rightv[5] = {2.0, 3.0, 0, 5.2, 6.0};
|
||||
bool eRes[5] = {true, true, false, true, true};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]);
|
||||
int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv);
|
||||
flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_FLOAT, sizeof(float), rowNum, rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
|
@ -903,7 +895,7 @@ TEST(opTest, smallint_column_or_float_column) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -925,13 +917,13 @@ TEST(opTest, smallint_column_or_float_column) {
|
|||
|
||||
TEST(opTest, smallint_column_or_double_value) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||
int16_t leftv[5]= {0, 2, 3, 0, -1};
|
||||
double rightv= 10.2;
|
||||
int16_t leftv[5] = {0, 2, 3, 0, -1};
|
||||
double rightv = 10.2;
|
||||
bool eRes[5] = {true, true, true, true, true};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv);
|
||||
flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv);
|
||||
flttMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
|
@ -942,7 +934,7 @@ TEST(opTest, smallint_column_or_double_value) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -964,7 +956,7 @@ TEST(opTest, smallint_column_or_double_value) {
|
|||
|
||||
TEST(opTest, binary_column_is_true) {
|
||||
SNode *pLeft = NULL, *opNode = NULL;
|
||||
char leftv[5][5]= {0};
|
||||
char leftv[5][5] = {0};
|
||||
SSDataBlock *src = NULL;
|
||||
SScalarParam res;
|
||||
initScalarParam(&res);
|
||||
|
@ -977,7 +969,7 @@ TEST(opTest, binary_column_is_true) {
|
|||
varDataSetLen(leftv[i], 3);
|
||||
}
|
||||
|
||||
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
|
||||
flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
|
||||
flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL);
|
||||
|
@ -987,7 +979,7 @@ TEST(opTest, binary_column_is_true) {
|
|||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1012,14 +1004,14 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
|
|||
|
||||
SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL;
|
||||
SNode *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1= 3, rightv2= 3;
|
||||
double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1 = 3, rightv2 = 3;
|
||||
int8_t eRes[8] = {1, 1, 0, 0, 1, 1, 1, 1};
|
||||
SSDataBlock *src = NULL;
|
||||
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
|
||||
int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]);
|
||||
int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]);
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1);
|
||||
|
@ -1032,7 +1024,6 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
|
|||
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list);
|
||||
|
||||
|
||||
list = nodesMakeList();
|
||||
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
|
@ -1052,13 +1043,12 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
|
|||
nodesListAppend(list, logicNode2);
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list);
|
||||
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
int32_t code = filterInitFromNode(logicNode1, &filter, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1081,14 +1071,14 @@ TEST(filterModelogicTest, diff_columns_and_or_and) {
|
|||
TEST(filterModelogicTest, same_column_and_or_and) {
|
||||
SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL;
|
||||
SNode *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3};
|
||||
int32_t rightv1= 3, rightv2= 0, rightv3 = 2, rightv4 = -2;
|
||||
double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3};
|
||||
int32_t rightv1 = 3, rightv2 = 0, rightv3 = 2, rightv4 = -2;
|
||||
int8_t eRes[8] = {1, 1, 0, 0, 0, 1, 1, 0};
|
||||
SSDataBlock *src = NULL;
|
||||
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
|
||||
int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]);
|
||||
int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]);
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1);
|
||||
|
@ -1101,7 +1091,6 @@ TEST(filterModelogicTest, same_column_and_or_and) {
|
|||
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list);
|
||||
|
||||
|
||||
list = nodesMakeList();
|
||||
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
|
@ -1121,13 +1110,12 @@ TEST(filterModelogicTest, same_column_and_or_and) {
|
|||
nodesListAppend(list, logicNode2);
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list);
|
||||
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
int32_t code = filterInitFromNode(logicNode1, &filter, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1150,14 +1138,14 @@ TEST(filterModelogicTest, same_column_and_or_and) {
|
|||
TEST(filterModelogicTest, diff_columns_or_and_or) {
|
||||
SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL;
|
||||
SNode *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1= 3, rightv2= 3;
|
||||
double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1 = 3, rightv2 = 3;
|
||||
int8_t eRes[8] = {1, 0, 1, 1, 0, 0, 0, 0};
|
||||
SSDataBlock *src = NULL;
|
||||
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
|
||||
int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]);
|
||||
int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]);
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1);
|
||||
|
@ -1170,7 +1158,6 @@ TEST(filterModelogicTest, diff_columns_or_and_or) {
|
|||
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list);
|
||||
|
||||
|
||||
list = nodesMakeList();
|
||||
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
|
@ -1190,13 +1177,12 @@ TEST(filterModelogicTest, diff_columns_or_and_or) {
|
|||
nodesListAppend(list, logicNode2);
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list);
|
||||
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
int32_t code = filterInitFromNode(logicNode1, &filter, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1219,14 +1205,14 @@ TEST(filterModelogicTest, diff_columns_or_and_or) {
|
|||
TEST(filterModelogicTest, same_column_or_and_or) {
|
||||
SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL;
|
||||
SNode *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3};
|
||||
int32_t rightv1= 3, rightv2= 0, rightv3 = 2, rightv4 = -2;
|
||||
double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3};
|
||||
int32_t rightv1 = 3, rightv2 = 0, rightv3 = 2, rightv4 = -2;
|
||||
int8_t eRes[8] = {0, 0, 0, 1, 1, 1, 1, 1};
|
||||
SSDataBlock *src = NULL;
|
||||
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
|
||||
int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]);
|
||||
int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]);
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1);
|
||||
|
@ -1239,7 +1225,6 @@ TEST(filterModelogicTest, same_column_or_and_or) {
|
|||
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list);
|
||||
|
||||
|
||||
list = nodesMakeList();
|
||||
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
|
@ -1259,13 +1244,12 @@ TEST(filterModelogicTest, same_column_or_and_or) {
|
|||
nodesListAppend(list, logicNode2);
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list);
|
||||
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
int32_t code = filterInitFromNode(logicNode1, &filter, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1290,14 +1274,14 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
|||
|
||||
SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL;
|
||||
SNode *logicNode1 = NULL, *logicNode2 = NULL;
|
||||
double leftv1[8] = {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1[8]= {5, 8, 2, -3, 9,-7,10, 0}, rightv2[8]= {-3, 5, 8, 2, -9, 11, -4, 0};
|
||||
double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2};
|
||||
int32_t rightv1[8] = {5, 8, 2, -3, 9, -7, 10, 0}, rightv2[8] = {-3, 5, 8, 2, -9, 11, -4, 0};
|
||||
int8_t eRes[8] = {0, 1, 1, 0, 0, 1, 0, 0};
|
||||
SSDataBlock *src = NULL;
|
||||
|
||||
SNodeList* list = nodesMakeList();
|
||||
SNodeList *list = nodesMakeList();
|
||||
|
||||
int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]);
|
||||
int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]);
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
flttMakeColumnNode(&pRight1, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, rightv1);
|
||||
flttMakeOpNode(&opNode1, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1);
|
||||
|
@ -1310,7 +1294,6 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
|||
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list);
|
||||
|
||||
|
||||
list = nodesMakeList();
|
||||
|
||||
flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1);
|
||||
|
@ -1330,13 +1313,12 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
|||
nodesListAppend(list, logicNode2);
|
||||
flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list);
|
||||
|
||||
|
||||
SFilterInfo *filter = NULL;
|
||||
int32_t code = filterInitFromNode(logicNode1, &filter, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SColumnDataAgg stat = {0};
|
||||
SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock };
|
||||
SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
|
@ -1356,7 +1338,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
|
|||
blockDataDestroy(src);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@ FORMAT_DIR_LIST=(
|
|||
"${PRJ_ROOT_DIR}/source/libs/planner"
|
||||
# "${PRJ_ROOT_DIR}/source/libs/qcom"
|
||||
# "${PRJ_ROOT_DIR}/source/libs/qworker"
|
||||
# "${PRJ_ROOT_DIR}/source/libs/scalar"
|
||||
"${PRJ_ROOT_DIR}/source/libs/scalar"
|
||||
"${PRJ_ROOT_DIR}/source/libs/stream"
|
||||
# "${PRJ_ROOT_DIR}/source/libs/sync"
|
||||
"${PRJ_ROOT_DIR}/source/libs/tdb"
|
||||
|
|
Loading…
Reference in New Issue