[td-13039] refactor scalar function.
This commit is contained in:
parent
21a0ee9284
commit
400989c040
|
@ -93,6 +93,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
|||
|
||||
int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
||||
void* tDecodeDataBlocks(const void* buf, SArray* blocks);
|
||||
void colDataDestroy(SColumnInfoData* pColData) ;
|
||||
|
||||
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||
// WARNING: do not use info.numOfCols,
|
||||
|
@ -100,13 +101,7 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
|||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
tfree(pColInfoData->varmeta.offset);
|
||||
} else {
|
||||
tfree(pColInfoData->nullbitmap);
|
||||
}
|
||||
|
||||
tfree(pColInfoData->pData);
|
||||
colDataDestroy(pColInfoData);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBlock->pDataBlock);
|
||||
|
|
|
@ -251,16 +251,9 @@ typedef struct SAggFunctionInfo {
|
|||
} SAggFunctionInfo;
|
||||
|
||||
typedef struct SScalarParam {
|
||||
void *data;
|
||||
union {
|
||||
SColumnInfoData *columnData;
|
||||
void *data;
|
||||
} orig;
|
||||
char *bitmap;
|
||||
bool dataInBlock;
|
||||
int32_t num;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
SColumnInfoData *columnData;
|
||||
SHashObj *pHashFilter;
|
||||
int32_t numOfRows;
|
||||
} SScalarParam;
|
||||
|
||||
typedef struct SScalarFunctionInfo {
|
||||
|
|
|
@ -1241,6 +1241,16 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
|
|||
return pageSize / (blockDataGetSerialRowSize(pBlock) + blockDataGetSerialMetaSize(pBlock));
|
||||
}
|
||||
|
||||
void colDataDestroy(SColumnInfoData* pColData) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->info.type)) {
|
||||
tfree(pColData->varmeta.offset);
|
||||
} else {
|
||||
tfree(pColData->nullbitmap);
|
||||
}
|
||||
|
||||
tfree(pColData->pData);
|
||||
}
|
||||
|
||||
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
|
||||
int64_t tbUid = pBlock->info.uid;
|
||||
int16_t numOfCols = pBlock->info.numOfCols;
|
||||
|
|
|
@ -3078,8 +3078,8 @@ static void arithmetic_function(SqlFunctionCtx *pCtx) {
|
|||
GET_RES_INFO(pCtx)->numOfRes += pCtx->size;
|
||||
//SScalarFunctionSupport *pSup = (SScalarFunctionSupport *)pCtx->param[1].pz;
|
||||
|
||||
SScalarParam output = {0};
|
||||
output.data = pCtx->pOutput;
|
||||
// SScalarParam output = {0};
|
||||
// output.data = pCtx->pOutput;
|
||||
|
||||
//evaluateExprNodeTree(pSup->pExprInfo->pExpr, pCtx->size, &output, pSup, getArithColumnData);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,12 @@ typedef struct SScalarCtx {
|
|||
#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(SScalarParam* in, SScalarParam* out, SValueNode* pValueNode);
|
||||
SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows);
|
||||
|
||||
int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx);
|
||||
bool sclIsNull(SScalarParam* param, int32_t idx);
|
||||
void sclSetNull(SScalarParam* param, int32_t idx);
|
||||
//int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx);
|
||||
//bool sclIsNull(SScalarParam* param, int32_t idx);
|
||||
//void sclSetNull(SScalarParam* param, int32_t idx);
|
||||
void sclFreeParam(SScalarParam *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1021,26 +1021,21 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
|
|||
if (node->opType == OP_TYPE_IN && (!IS_VAR_DATA_TYPE(type))) {
|
||||
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
|
||||
SListCell *cell = listNode->pNodeList->pHead;
|
||||
SScalarParam in = {.num = 1}, out = {.num = 1, .type = type};
|
||||
|
||||
SScalarParam in = {.columnData = calloc(1, sizeof(SColumnInfoData))}, out = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
out.columnData->info.type = type;
|
||||
|
||||
for (int32_t i = 0; i < listNode->pNodeList->length; ++i) {
|
||||
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
||||
in.type = valueNode->node.resType.type;
|
||||
in.bytes = valueNode->node.resType.bytes;
|
||||
in.data = nodesGetValueFromNode(valueNode);
|
||||
out.data = malloc(sizeof(int64_t));
|
||||
|
||||
code = vectorConvertImpl(&in, &out);
|
||||
code = doConvertDataType(&in, &out, valueNode);
|
||||
if (code) {
|
||||
fltError("convert from %d to %d failed", in.type, out.type);
|
||||
tfree(out.data);
|
||||
// fltError("convert from %d to %d failed", in.type, out.type);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
|
||||
len = tDataTypes[type].bytes;
|
||||
|
||||
filterAddField(info, NULL, &out.data, FLD_TYPE_VALUE, &right, len, true);
|
||||
|
||||
filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true);
|
||||
filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx);
|
||||
|
||||
SFilterGroup fgroup = {0};
|
||||
|
@ -1054,7 +1049,6 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
|
|||
filterAddFieldFromNode(info, node->pRight, &right);
|
||||
|
||||
FLT_ERR_RET(filterAddUnit(info, node->opType, &left, &right, &uidx));
|
||||
|
||||
SFilterGroup fgroup = {0};
|
||||
filterAddUnitToGroup(&fgroup, uidx);
|
||||
|
||||
|
@ -1080,7 +1074,6 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
|
|||
filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right.
|
||||
|
||||
t = FILTER_GET_FIELD(dst, right);
|
||||
|
||||
FILTER_SET_FLAG(t->flag, FLD_DATA_IS_HASH);
|
||||
} else {
|
||||
filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, varDataTLen(data), false);
|
||||
|
@ -1101,14 +1094,12 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u
|
|||
|
||||
int32_t filterAddUnitRight(SFilterInfo *info, uint8_t optr, SFilterFieldId *right, uint32_t uidx) {
|
||||
SFilterUnit *u = &info->units[uidx];
|
||||
|
||||
u->compare.optr2 = optr;
|
||||
u->right2 = *right;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRangeCtx *ctx, uint32_t cidx, SFilterGroup *g, int32_t optr, SArray *res) {
|
||||
SFilterFieldId left, right, right2;
|
||||
uint32_t uidx = 0;
|
||||
|
@ -1800,9 +1791,12 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
|||
if (dType->type == type) {
|
||||
assignVal(fi->data, nodesGetValueFromNode(var), dType->bytes, type);
|
||||
} else {
|
||||
SScalarParam in = {.data = nodesGetValueFromNode(var), .num = 1, .type = dType->type, .bytes = dType->bytes};
|
||||
SScalarParam out = {.data = fi->data, .num = 1, .type = type};
|
||||
if (vectorConvertImpl(&in, &out)) {
|
||||
SScalarParam in = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
SScalarParam out = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
out.columnData->info.type = type;
|
||||
|
||||
int32_t code = doConvertDataType(&in, &out, var);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("convert value to type[%d] failed", type);
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
@ -3676,18 +3670,18 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnData
|
|||
FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output));
|
||||
|
||||
taosArrayDestroy(pList);
|
||||
|
||||
*p = output.orig.data;
|
||||
output.orig.data = NULL;
|
||||
|
||||
sclFreeParam(&output);
|
||||
|
||||
int8_t *r = output.data;
|
||||
for (int32_t i = 0; i < output.num; ++i) {
|
||||
if (0 == *(r+i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// TODO Fix it
|
||||
// *p = output.orig.data;
|
||||
// output.orig.data = NULL;
|
||||
//
|
||||
// sclFreeParam(&output);
|
||||
//
|
||||
// int8_t *r = output.data;
|
||||
// for (int32_t i = 0; i < output.num; ++i) {
|
||||
// if (0 == *(r+i)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,35 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows) {
|
||||
SColumnInfoData* pColumnData = calloc(1, sizeof(SColumnInfoData));
|
||||
if (pColumnData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pColumnData->info.type = pType->type;
|
||||
pColumnData->info.bytes = pType->bytes;
|
||||
pColumnData->info.scale = pType->scale;
|
||||
pColumnData->info.precision = pType->precision;
|
||||
|
||||
int32_t code = blockDataEnsureColumnCapacity(pColumnData, numOfRows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tfree(pColumnData);
|
||||
return NULL;
|
||||
} else {
|
||||
return pColumnData;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t doConvertDataType(SScalarParam* in, SScalarParam* out, SValueNode* pValueNode) {
|
||||
in->columnData = createColumnInfoData(&pValueNode->node.resType, 1);
|
||||
colDataAppend(in->columnData, 0, nodesGetValueFromNode(pValueNode), false);
|
||||
|
||||
return vectorConvertImpl(in, out);
|
||||
}
|
||||
|
||||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
|
||||
if (NULL == pObj) {
|
||||
|
@ -28,10 +57,9 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
int32_t code = 0;
|
||||
SNodeListNode *nodeList = (SNodeListNode *)pNode;
|
||||
SListCell *cell = nodeList->pNodeList->pHead;
|
||||
SScalarParam in = {.num = 1}, out = {.num = 1, .type = type};
|
||||
int8_t dummy = 0;
|
||||
int32_t bufLen = 60;
|
||||
out.data = malloc(bufLen);
|
||||
|
||||
SScalarParam in = {.columnData = calloc(1, sizeof(SColumnInfoData))}, out = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
|
||||
int32_t len = 0;
|
||||
void *buf = NULL;
|
||||
|
||||
|
@ -39,22 +67,18 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
||||
|
||||
if (valueNode->node.resType.type != type) {
|
||||
in.type = valueNode->node.resType.type;
|
||||
in.bytes = valueNode->node.resType.bytes;
|
||||
in.data = nodesGetValueFromNode(valueNode);
|
||||
|
||||
code = vectorConvertImpl(&in, &out);
|
||||
doConvertDataType(&in, &out, valueNode);
|
||||
if (code) {
|
||||
sclError("convert 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);
|
||||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
len = varDataLen(out.data);
|
||||
buf = varDataVal(out.data);
|
||||
len = varDataLen(out.columnData->pData);
|
||||
buf = varDataVal(out.columnData->pData);
|
||||
} else {
|
||||
len = tDataTypes[type].bytes;
|
||||
buf = out.data;
|
||||
buf = out.columnData->pData;
|
||||
}
|
||||
} else {
|
||||
buf = nodesGetValueFromNode(valueNode);
|
||||
|
@ -63,11 +87,10 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
buf = varDataVal(buf);
|
||||
} else {
|
||||
len = valueNode->node.resType.bytes;
|
||||
buf = out.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (taosHashPut(pObj, buf, (size_t)len, &dummy, sizeof(dummy))) {
|
||||
if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) {
|
||||
sclError("taosHashPut failed");
|
||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -75,40 +98,14 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
cell = cell->pNext;
|
||||
}
|
||||
|
||||
tfree(out.data);
|
||||
*data = pObj;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
tfree(out.data);
|
||||
taosHashCleanup(pObj);
|
||||
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
FORCE_INLINE bool sclIsNull(SScalarParam* param, int32_t idx) {
|
||||
if (param->dataInBlock) {
|
||||
return colDataIsNull(param->orig.columnData, 0, idx, NULL);
|
||||
}
|
||||
|
||||
return param->bitmap ? colDataIsNull_f(param->bitmap, idx) : false;
|
||||
}
|
||||
|
||||
FORCE_INLINE void sclSetNull(SScalarParam* param, int32_t idx) {
|
||||
if (NULL == param->bitmap) {
|
||||
param->bitmap = calloc(BitmapLen(param->num), sizeof(char));
|
||||
if (NULL == param->bitmap) {
|
||||
sclError("calloc %d failed", param->num);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
colDataSetNull_f(param->bitmap, idx);
|
||||
}
|
||||
|
||||
|
||||
void sclFreeRes(SHashObj *res) {
|
||||
SScalarParam *p = NULL;
|
||||
void *pIter = taosHashIterate(res, NULL);
|
||||
|
@ -118,31 +115,26 @@ void sclFreeRes(SHashObj *res) {
|
|||
if (p) {
|
||||
sclFreeParam(p);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(res, pIter);
|
||||
}
|
||||
|
||||
taosHashCleanup(res);
|
||||
}
|
||||
|
||||
void sclFreeParamNoData(SScalarParam *param) {
|
||||
tfree(param->bitmap);
|
||||
// tfree(param->bitmap);
|
||||
}
|
||||
|
||||
|
||||
void sclFreeParam(SScalarParam *param) {
|
||||
sclFreeParamNoData(param);
|
||||
|
||||
if (!param->dataInBlock) {
|
||||
if (SCL_DATA_TYPE_DUMMY_HASH == param->type) {
|
||||
taosHashCleanup((SHashObj *)param->orig.data);
|
||||
} else {
|
||||
tfree(param->orig.data);
|
||||
}
|
||||
}
|
||||
// if (!param->dataInBlock) {
|
||||
// if (SCL_DATA_TYPE_DUMMY_HASH == param->type) {
|
||||
// taosHashCleanup((SHashObj *)param->orig.data);
|
||||
// } else {
|
||||
// tfree(param->orig.data);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) {
|
||||
if (TSDB_DATA_TYPE_NULL == pNode->node.resType.type) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -155,7 +147,6 @@ int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) {
|
|||
}
|
||||
|
||||
memcpy(*res, nodesGetValueFromNode(pNode), pNode->node.resType.bytes);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -163,19 +154,17 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
switch (nodeType(node)) {
|
||||
case QUERY_NODE_VALUE: {
|
||||
SValueNode *valueNode = (SValueNode *)node;
|
||||
//SCL_ERR_RET(sclCopyValueNodeValue(valueNode, ¶m->data));
|
||||
param->data = nodesGetValueFromNode(valueNode);
|
||||
param->orig.data = param->data;
|
||||
param->num = 1;
|
||||
param->type = valueNode->node.resType.type;
|
||||
param->bytes = valueNode->node.resType.bytes;
|
||||
if (TSDB_DATA_TYPE_NULL == param->type) {
|
||||
sclSetNull(param, 0);
|
||||
|
||||
param->numOfRows = 1;
|
||||
param->columnData = createColumnInfoData(&valueNode->node.resType, 1);
|
||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type) {
|
||||
colDataAppend(param->columnData, 0, NULL, true);
|
||||
} else {
|
||||
colDataAppend(param->columnData, 0, nodesGetValueFromNode(valueNode), false);
|
||||
}
|
||||
param->dataInBlock = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case QUERY_NODE_NODE_LIST: {
|
||||
SNodeListNode *nodeList = (SNodeListNode *)node;
|
||||
if (nodeList->pNodeList->length <= 0) {
|
||||
|
@ -183,15 +172,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
SCL_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
SCL_ERR_RET(scalarGenerateSetFromList(¶m->data, node, nodeList->dataType.type));
|
||||
param->orig.data = param->data;
|
||||
param->num = 1;
|
||||
param->type = SCL_DATA_TYPE_DUMMY_HASH;
|
||||
param->dataInBlock = false;
|
||||
|
||||
SCL_ERR_RET(scalarGenerateSetFromList((void**) ¶m->pHashFilter, node, nodeList->dataType.type));
|
||||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||
taosHashCleanup(param->orig.data);
|
||||
param->orig.data = NULL;
|
||||
taosHashCleanup(param->pHashFilter);
|
||||
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -210,21 +193,14 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
}
|
||||
|
||||
SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, ref->dataBlockId);
|
||||
|
||||
if (NULL == block || ref->slotId >= 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);
|
||||
param->data = NULL;
|
||||
param->orig.columnData = columnData;
|
||||
param->dataInBlock = true;
|
||||
|
||||
param->num = block->info.rows;
|
||||
param->type = columnData->info.type;
|
||||
param->bytes = columnData->info.bytes;
|
||||
|
||||
param->numOfRows = block->info.rows;
|
||||
param->columnData = columnData;
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_CONDITION:
|
||||
|
@ -234,9 +210,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
sclError("no result for node, type:%d, node:%p", nodeType(node), node);
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
*param = *res;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -244,39 +218,13 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
break;
|
||||
}
|
||||
|
||||
if (param->num > *rowNum) {
|
||||
if ((1 != param->num) && (1 < *rowNum)) {
|
||||
sclError("different row nums, rowNum:%d, newRowNum:%d", *rowNum, param->num);
|
||||
if (param->numOfRows > *rowNum) {
|
||||
if ((1 != param->numOfRows) && (1 < *rowNum)) {
|
||||
sclError("different row nums, rowNum:%d, newRowNum:%d", *rowNum, param->numOfRows);
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
*rowNum = param->num;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx) {
|
||||
SScalarParam *param = NULL;
|
||||
|
||||
for (int32_t i = 0; i < listNum; ++i) {
|
||||
param = params + i;
|
||||
|
||||
if (1 == param->num) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param->dataInBlock) {
|
||||
param->data = colDataGetData(param->orig.columnData, idx);
|
||||
} else if (idx) {
|
||||
if (IS_VAR_DATA_TYPE(param->type)) {
|
||||
param->data = (char *)(param->data) + varDataTLen(param->data);
|
||||
} else {
|
||||
param->data = (char *)(param->data) + tDataTypes[param->type].bytes;
|
||||
}
|
||||
} else {
|
||||
param->data = param->orig.data;
|
||||
}
|
||||
*rowNum = param->numOfRows;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -298,16 +246,13 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC
|
|||
}
|
||||
|
||||
SCL_ERR_JRET(sclInitParam(cell->pNode, ¶mList[i], ctx, rowNum));
|
||||
|
||||
cell = cell->pNext;
|
||||
}
|
||||
|
||||
*pParams = paramList;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
tfree(paramList);
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
@ -332,16 +277,13 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal
|
|||
}
|
||||
|
||||
*pParams = paramList;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
tfree(paramList);
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||
sclError("invalid function parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||
|
@ -359,18 +301,16 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu
|
|||
int32_t rowNum = 0;
|
||||
SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, &rowNum));
|
||||
|
||||
output->type = node->node.resType.type;
|
||||
output->data = calloc(rowNum, sizeof(tDataTypes[output->type].bytes));
|
||||
if (NULL == output->data) {
|
||||
sclError("calloc %d failed", (int32_t)(rowNum * sizeof(tDataTypes[output->type].bytes)));
|
||||
output->columnData->info.type = node->node.resType.type;
|
||||
output->columnData->info.bytes = tDataTypes[node->node.resType.type].bytes;
|
||||
|
||||
code = blockDataEnsureColumnCapacity(output->columnData, rowNum);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
sclError("calloc %d failed", (int32_t)(rowNum * output->columnData->info.bytes));
|
||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
output->orig.data = output->data;
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
sclMoveParamListData(output, 1, i);
|
||||
sclMoveParamListData(params, node->pParameterList->length, i);
|
||||
|
||||
code = (*ffpSet.process)(params, node->pParameterList->length, output);
|
||||
if (code) {
|
||||
sclError("scalar function exec failed, funcId:%d, code:%s", node->funcId, tstrerror(code));
|
||||
|
@ -385,11 +325,9 @@ _return:
|
|||
}
|
||||
|
||||
tfree(params);
|
||||
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
@ -409,28 +347,24 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
SScalarParam *params = NULL;
|
||||
int32_t rowNum = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, &rowNum));
|
||||
|
||||
output->type = node->node.resType.type;
|
||||
output->bytes = sizeof(bool);
|
||||
output->num = rowNum;
|
||||
output->data = calloc(rowNum, sizeof(bool));
|
||||
if (NULL == output->data) {
|
||||
int32_t type = node->node.resType.type;
|
||||
output->numOfRows = rowNum;
|
||||
|
||||
SDataType t = {.type = type, .bytes = tDataTypes[type].bytes};
|
||||
output->columnData = createColumnInfoData(&t, rowNum);
|
||||
if (output->columnData == NULL) {
|
||||
sclError("calloc %d failed", (int32_t)(rowNum * sizeof(bool)));
|
||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
output->orig.data = output->data;
|
||||
|
||||
bool value = false;
|
||||
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
sclMoveParamListData(output, 1, i);
|
||||
sclMoveParamListData(params, node->pParameterList->length, i);
|
||||
|
||||
for (int32_t m = 0; m < node->pParameterList->length; ++m) {
|
||||
GET_TYPED_DATA(value, bool, params[m].type, params[m].data);
|
||||
|
||||
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)) {
|
||||
break;
|
||||
} else if (LOGIC_COND_TYPE_OR == node->condType && value) {
|
||||
|
@ -440,11 +374,10 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
}
|
||||
}
|
||||
|
||||
*(bool *)output->data = value;
|
||||
colDataAppend(output->columnData, i, (char*) &value, false);
|
||||
}
|
||||
|
||||
_return:
|
||||
|
||||
for (int32_t i = 0; i < node->pParameterList->length; ++i) {
|
||||
sclFreeParamNoData(params + i);
|
||||
}
|
||||
|
@ -459,16 +392,11 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
|
|||
int32_t code = 0;
|
||||
|
||||
SCL_ERR_RET(sclInitOperatorParams(¶ms, node, ctx, &rowNum));
|
||||
|
||||
output->type = node->node.resType.type;
|
||||
output->num = rowNum;
|
||||
output->bytes = tDataTypes[output->type].bytes;
|
||||
output->data = calloc(rowNum, tDataTypes[output->type].bytes);
|
||||
if (NULL == output->data) {
|
||||
sclError("calloc %d failed", (int32_t)rowNum * tDataTypes[output->type].bytes);
|
||||
output->columnData = createColumnInfoData(&node->node.resType, rowNum);
|
||||
if (output->columnData == NULL) {
|
||||
sclError("calloc failed, size:%d", (int32_t)rowNum * node->node.resType.bytes);
|
||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
output->orig.data = output->data;
|
||||
|
||||
_bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(node->opType);
|
||||
|
||||
|
@ -479,18 +407,14 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
|
|||
OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC);
|
||||
|
||||
_return:
|
||||
|
||||
|
||||
for (int32_t i = 0; i < paramNum; ++i) {
|
||||
sclFreeParamNoData(params + i);
|
||||
}
|
||||
|
||||
tfree(params);
|
||||
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
||||
SFunctionNode *node = (SFunctionNode *)*pNode;
|
||||
SScalarParam output = {0};
|
||||
|
@ -510,11 +434,12 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
res->node.resType = node->node.resType;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(output.type)) {
|
||||
res->datum.p = output.data;
|
||||
output.data = NULL;
|
||||
int32_t type = output.columnData->info.type;
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
res->datum.p = output.columnData->pData;
|
||||
output.columnData->pData = NULL;
|
||||
} else {
|
||||
memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes);
|
||||
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes);
|
||||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
|
@ -527,8 +452,8 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
||||
SLogicConditionNode *node = (SLogicConditionNode *)*pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
SScalarParam output = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
ctx->code = sclExecLogic(node, ctx, &output);
|
||||
if (ctx->code) {
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -544,11 +469,12 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
res->node.resType = node->node.resType;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(output.type)) {
|
||||
res->datum.p = output.data;
|
||||
output.data = NULL;
|
||||
int32_t type = output.columnData->info.type;
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
res->datum.p = output.columnData->pData;
|
||||
output.columnData->pData = NULL;
|
||||
} else {
|
||||
memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes);
|
||||
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes);
|
||||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
|
@ -561,8 +487,8 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
SScalarParam output = {.columnData = calloc(1, sizeof(SColumnInfoData))};
|
||||
ctx->code = sclExecOperator(node, ctx, &output);
|
||||
if (ctx->code) {
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -578,22 +504,21 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
|
|||
|
||||
res->node.resType = node->node.resType;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(output.type)) {
|
||||
res->datum.p = output.data;
|
||||
output.data = NULL;
|
||||
int32_t type = output.columnData->info.type;
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
res->datum.p = output.columnData->pData;
|
||||
output.columnData->pData = NULL;
|
||||
} else {
|
||||
memcpy(nodesGetValueFromNode(res), output.data, tDataTypes[output.type].bytes);
|
||||
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes);
|
||||
}
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
|
||||
sclFreeParam(&output);
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
|
||||
if (QUERY_NODE_VALUE == nodeType(*pNode) || QUERY_NODE_NODE_LIST == nodeType(*pNode)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
@ -614,13 +539,10 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
|
|||
}
|
||||
|
||||
sclError("invalid node type for calculating constants, type:%d", nodeType(*pNode));
|
||||
|
||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
||||
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
@ -638,7 +560,6 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) {
|
||||
SLogicConditionNode *node = (SLogicConditionNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
@ -656,7 +577,6 @@ EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
@ -699,27 +619,26 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < res->num; ++i) {
|
||||
sclMoveParamListData(res, 1, i);
|
||||
|
||||
colDataAppend(col, i, res->data, sclIsNull(res, i));
|
||||
for (int32_t i = 0; i < res->numOfRows; ++i) {
|
||||
if (colDataIsNull(res->columnData, res->numOfRows, i, NULL)) {
|
||||
colDataAppend(col, i, NULL, true);
|
||||
} else {
|
||||
char *p = colDataGetData(res->columnData, i);
|
||||
colDataAppend(col, i, p, false);
|
||||
}
|
||||
}
|
||||
|
||||
sclFreeParam(res);
|
||||
|
||||
taosHashRemove(ctx->pRes, (void *)&target->pExpr, POINTER_BYTES);
|
||||
|
||||
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)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
||||
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||
return sclWalkFunction(pNode, ctx);
|
||||
}
|
||||
|
@ -737,14 +656,10 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
|
|||
}
|
||||
|
||||
sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode));
|
||||
|
||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
||||
if (NULL == pNode) {
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
|
@ -759,15 +674,11 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
|||
}
|
||||
|
||||
nodesRewriteNodePostOrder(&pNode, sclConstantsRewriter, (void *)&ctx);
|
||||
|
||||
SCL_ERR_JRET(ctx.code);
|
||||
|
||||
*pRes = pNode;
|
||||
|
||||
_return:
|
||||
|
||||
sclFreeRes(ctx.pRes);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -786,7 +697,6 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
}
|
||||
|
||||
nodesWalkNodePostOrder(pNode, sclCalcWalker, (void *)&ctx);
|
||||
|
||||
SCL_ERR_JRET(ctx.code);
|
||||
|
||||
if (pDst) {
|
||||
|
@ -796,18 +706,14 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
SCL_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
sclMoveParamListData(res, 1, 0);
|
||||
|
||||
// sclMoveParamListData(res, 1, 0);
|
||||
*pDst = *res;
|
||||
|
||||
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||
}
|
||||
|
||||
_return:
|
||||
|
||||
//nodesDestroyNode(pNode);
|
||||
sclFreeRes(ctx.pRes);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
#include "sclvector.h"
|
||||
|
||||
static void assignBasicParaInfo(struct SScalarParam* dst, const struct SScalarParam* src) {
|
||||
dst->type = src->type;
|
||||
dst->bytes = src->bytes;
|
||||
dst->num = src->num;
|
||||
// dst->type = src->type;
|
||||
// dst->bytes = src->bytes;
|
||||
// dst->num = src->num;
|
||||
}
|
||||
|
||||
static void tceil(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assignBasicParaInfo(pOutput, pLeft);
|
||||
assert(numOfInput == 1);
|
||||
|
||||
#if 0
|
||||
switch (pLeft->bytes) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float* p = (float*) pLeft->data;
|
||||
|
@ -31,12 +31,14 @@ static void tceil(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *
|
|||
default:
|
||||
memcpy(pOutput->data, pLeft->data, pLeft->num* pLeft->bytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void tfloor(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assignBasicParaInfo(pOutput, pLeft);
|
||||
assert(numOfInput == 1);
|
||||
|
||||
#if 0
|
||||
switch (pLeft->bytes) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float* p = (float*) pLeft->data;
|
||||
|
@ -59,12 +61,13 @@ static void tfloor(SScalarParam* pOutput, size_t numOfInput, const SScalarParam
|
|||
default:
|
||||
memcpy(pOutput->data, pLeft->data, pLeft->num* pLeft->bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tabs(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assignBasicParaInfo(pOutput, pLeft);
|
||||
assert(numOfInput == 1);
|
||||
|
||||
#if 0
|
||||
switch (pLeft->bytes) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float* p = (float*) pLeft->data;
|
||||
|
@ -117,12 +120,13 @@ static void _tabs(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *
|
|||
default:
|
||||
memcpy(pOutput->data, pLeft->data, pLeft->num* pLeft->bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tround(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assignBasicParaInfo(pOutput, pLeft);
|
||||
assert(numOfInput == 1);
|
||||
|
||||
#if 0
|
||||
switch (pLeft->bytes) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float* p = (float*) pLeft->data;
|
||||
|
@ -143,22 +147,24 @@ static void tround(SScalarParam* pOutput, size_t numOfInput, const SScalarParam
|
|||
default:
|
||||
memcpy(pOutput->data, pLeft->data, pLeft->num* pLeft->bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tlength(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assert(numOfInput == 1);
|
||||
|
||||
#if 0
|
||||
int64_t* out = (int64_t*) pOutput->data;
|
||||
char* s = pLeft->data;
|
||||
|
||||
for(int32_t i = 0; i < pLeft->num; ++i) {
|
||||
out[i] = varDataLen(POINTER_SHIFT(s, i * pLeft->bytes));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tconcat(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
assert(numOfInput > 0);
|
||||
|
||||
#if 0
|
||||
int32_t rowLen = 0;
|
||||
int32_t num = 1;
|
||||
for(int32_t i = 0; i < numOfInput; ++i) {
|
||||
|
@ -186,6 +192,7 @@ static void tconcat(SScalarParam* pOutput, size_t numOfInput, const SScalarParam
|
|||
|
||||
rstart += rowLen;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tltrim(SScalarParam* pOutput, size_t numOfInput, const SScalarParam *pLeft) {
|
||||
|
@ -262,13 +269,12 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf
|
|||
}
|
||||
|
||||
static void setScalarFuncParam(SScalarParam* param, int32_t type, int32_t bytes, void* pInput, int32_t numOfRows) {
|
||||
param->bytes = bytes;
|
||||
param->type = type;
|
||||
param->num = numOfRows;
|
||||
param->data = pInput;
|
||||
// param->bytes = bytes;
|
||||
// param->type = type;
|
||||
// param->num = numOfRows;
|
||||
// param->data = pInput;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int32_t evaluateExprNodeTree(tExprNode* pExprs, int32_t numOfRows, SScalarFuncParam* pOutput, void* param,
|
||||
char* (*getSourceDataBlock)(void*, const char*, int32_t)) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -261,7 +261,7 @@ TEST(constantTest, bigint_add_bigint) {
|
|||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE);
|
||||
ASSERT_EQ(v->datum.d, (scltLeftV + scltRightV));
|
||||
ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV));
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ TEST(constantTest, double_sub_bigint) {
|
|||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE);
|
||||
ASSERT_EQ(v->datum.d, (scltLeftVd - scltRightV));
|
||||
ASSERT_FLOAT_EQ(v->datum.d, (scltLeftVd - scltRightV));
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
|
@ -959,7 +959,6 @@ TEST(columnTest, bigint_column_multi_binary_column) {
|
|||
scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv);
|
||||
scltMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||
|
||||
|
||||
SArray *blockList = taosArrayInit(1, POINTER_BYTES);
|
||||
taosArrayPush(blockList, &src);
|
||||
SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
|
||||
|
|
Loading…
Reference in New Issue