提交 93baf85a 编写于 作者: D dapan1121

feature/qnode

上级 8f7b375b
...@@ -91,6 +91,8 @@ typedef struct { ...@@ -91,6 +91,8 @@ typedef struct {
do { \ do { \
switch (_type) { \ switch (_type) { \
case TSDB_DATA_TYPE_BOOL: \ case TSDB_DATA_TYPE_BOOL: \
*(bool *)(_v) = (bool)(_data); \
break; \
case TSDB_DATA_TYPE_TINYINT: \ case TSDB_DATA_TYPE_TINYINT: \
*(int8_t *)(_v) = (int8_t)(_data); \ *(int8_t *)(_v) = (int8_t)(_data); \
break; \ break; \
......
...@@ -228,6 +228,7 @@ typedef struct SAggFunctionInfo { ...@@ -228,6 +228,7 @@ typedef struct SAggFunctionInfo {
typedef struct SScalarParam { typedef struct SScalarParam {
void* data; void* data;
bool colData;
int32_t num; int32_t num;
int32_t type; int32_t type;
int32_t bytes; int32_t bytes;
......
...@@ -141,6 +141,7 @@ typedef struct SLogicConditionNode { ...@@ -141,6 +141,7 @@ typedef struct SLogicConditionNode {
typedef struct SNodeListNode { typedef struct SNodeListNode {
ENodeType type; // QUERY_NODE_NODE_LIST ENodeType type; // QUERY_NODE_NODE_LIST
SDataType dataType;
SNodeList* pNodeList; SNodeList* pNodeList;
} SNodeListNode; } SNodeListNode;
......
...@@ -546,7 +546,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ...@@ -546,7 +546,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
if (tbMeta->tableType != TSDB_CHILD_TABLE) { if (tbMeta->tableType != TSDB_CHILD_TABLE) {
ctgReleaseDBCache(pCtg, dbCache); ctgReleaseDBCache(pCtg, dbCache);
ctgDebug("Got tbl from cache, type:%d, dbFName:%s, tbName:%s", tbMeta->tableType, dbFName, pTableName->tname); ctgDebug("Got meta from cache, type:%d, dbFName:%s, tbName:%s", tbMeta->tableType, dbFName, pTableName->tname);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -63,6 +63,8 @@ SNode* nodesMakeNode(ENodeType type) { ...@@ -63,6 +63,8 @@ SNode* nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SNodeListNode)); return makeNode(type, sizeof(SNodeListNode));
case QUERY_NODE_FILL: case QUERY_NODE_FILL:
return makeNode(type, sizeof(SFillNode)); return makeNode(type, sizeof(SFillNode));
case QUERY_NODE_COLUMN_REF:
return makeNode(type, sizeof(SColumnRefNode));
case QUERY_NODE_RAW_EXPR: case QUERY_NODE_RAW_EXPR:
return makeNode(type, sizeof(SRawExprNode)); return makeNode(type, sizeof(SRawExprNode));
case QUERY_NODE_SET_OPERATOR: case QUERY_NODE_SET_OPERATOR:
......
...@@ -1820,6 +1820,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) ...@@ -1820,6 +1820,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case TSDB_RELATION_LIKE: { case TSDB_RELATION_LIKE: {
return ret == 0; return ret == 0;
} }
case TSDB_RELATION_NOT_LIKE: {
return ret == 0;
}
case TSDB_RELATION_MATCH: { case TSDB_RELATION_MATCH: {
return ret == 0; return ret == 0;
} }
...@@ -1829,6 +1832,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) ...@@ -1829,6 +1832,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case TSDB_RELATION_IN: { case TSDB_RELATION_IN: {
return ret == 1; return ret == 1;
} }
case TSDB_RELATION_NOT_IN: {
return ret == 1;
}
default: default:
assert(false); assert(false);
......
...@@ -50,20 +50,28 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { ...@@ -50,20 +50,28 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
if (IS_VAR_DATA_TYPE(type)) { if (IS_VAR_DATA_TYPE(type)) {
len = varDataLen(out.data); len = varDataLen(out.data);
buf = varDataVal(out.data);
} else { } else {
len = tDataTypes[type].bytes; len = tDataTypes[type].bytes;
}
buf = out.data; buf = out.data;
}
} else { } else {
buf = nodesGetValueFromNode(valueNode); buf = nodesGetValueFromNode(valueNode);
if (IS_VAR_DATA_TYPE(type)) {
len = varDataLen(buf);
buf = varDataVal(buf);
} else {
len = valueNode->node.resType.bytes; 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, &dummy, sizeof(dummy))) {
sclError("taosHashPut failed"); sclError("taosHashPut failed");
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
cell = cell->pNext;
} }
tfree(out.data); tfree(out.data);
...@@ -108,6 +116,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t ...@@ -108,6 +116,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
param->num = 1; param->num = 1;
param->type = valueNode->node.resType.type; param->type = valueNode->node.resType.type;
param->bytes = valueNode->node.resType.bytes; param->bytes = valueNode->node.resType.bytes;
param->colData = false;
break; break;
} }
...@@ -121,6 +130,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t ...@@ -121,6 +130,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
SCL_ERR_RET(scalarGenerateSetFromList(&param->data, node, nodeList->dataType.type)); SCL_ERR_RET(scalarGenerateSetFromList(&param->data, node, nodeList->dataType.type));
param->num = 1; param->num = 1;
param->type = SCL_DATA_TYPE_DUMMY_HASH; param->type = SCL_DATA_TYPE_DUMMY_HASH;
param->colData = false;
break; break;
} }
...@@ -137,7 +147,14 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t ...@@ -137,7 +147,14 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
} }
SColumnInfoData *columnData = (SColumnInfoData *)taosArrayGet(ctx->pSrc->pDataBlock, ref->slotId); SColumnInfoData *columnData = (SColumnInfoData *)taosArrayGet(ctx->pSrc->pDataBlock, ref->slotId);
if (IS_VAR_DATA_TYPE(columnData->info.type)) {
param->data = columnData;
param->colData = true;
} else {
param->data = columnData->pData; param->data = columnData->pData;
param->colData = false;
}
param->num = ctx->pSrc->info.rows; param->num = ctx->pSrc->info.rows;
param->type = columnData->info.type; param->type = columnData->info.type;
param->bytes = columnData->info.bytes; param->bytes = columnData->info.bytes;
...@@ -366,6 +383,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp ...@@ -366,6 +383,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
output->type = node->node.resType.type; output->type = node->node.resType.type;
output->num = rowNum; output->num = rowNum;
output->bytes = tDataTypes[output->type].bytes;
output->data = calloc(rowNum, tDataTypes[output->type].bytes); output->data = calloc(rowNum, tDataTypes[output->type].bytes);
if (NULL == output->data) { if (NULL == output->data) {
sclError("calloc %d failed", (int32_t)rowNum * tDataTypes[output->type].bytes); sclError("calloc %d failed", (int32_t)rowNum * tDataTypes[output->type].bytes);
...@@ -378,21 +396,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp ...@@ -378,21 +396,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
SScalarParam* pLeft = &params[0]; SScalarParam* pLeft = &params[0];
SScalarParam* pRight = paramNum > 1 ? &params[1] : NULL; SScalarParam* pRight = paramNum > 1 ? &params[1] : NULL;
void *data = output->data;
for (int32_t i = 0; i < rowNum; ++i) {
OperatorFn(pLeft, pRight, output->data, TSDB_ORDER_ASC); OperatorFn(pLeft, pRight, output->data, TSDB_ORDER_ASC);
sclParamMoveNext(output, 1);
sclParamMoveNext(pLeft, 1);
if (pRight) {
sclParamMoveNext(pRight, 1);
}
}
output->data = data;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
_return: _return:
...@@ -506,7 +511,7 @@ EDealRes sclRewriteOperator(SNode** pNode, void* pContext) { ...@@ -506,7 +511,7 @@ EDealRes sclRewriteOperator(SNode** pNode, void* pContext) {
EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
if (QUERY_NODE_VALUE == nodeType(*pNode)) { if (QUERY_NODE_VALUE == nodeType(*pNode) || QUERY_NODE_NODE_LIST == nodeType(*pNode)) {
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
...@@ -588,7 +593,7 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) { ...@@ -588,7 +593,7 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) {
EDealRes sclCalcWalker(SNode* pNode, void* pContext) { EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
if (QUERY_NODE_VALUE == nodeType(pNode)) { if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) || QUERY_NODE_COLUMN_REF == nodeType(pNode)) {
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
...@@ -604,7 +609,7 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) { ...@@ -604,7 +609,7 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
return sclWalkOperator(pNode, pContext); return sclWalkOperator(pNode, pContext);
} }
sclError("invalid node type for calculating constants, type:%d", nodeType(pNode)); sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode));
SScalarCtx *ctx = (SScalarCtx *)pContext; SScalarCtx *ctx = (SScalarCtx *)pContext;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "querynodes.h" #include "querynodes.h"
#include "filterInt.h" #include "filterInt.h"
#include "query.h" #include "query.h"
#include "sclInt.h"
#include "tep.h"
//GET_TYPED_DATA(v, double, pRight->type, (char *)&((right)[i])); //GET_TYPED_DATA(v, double, pRight->type, (char *)&((right)[i]));
...@@ -93,6 +95,7 @@ double getVectorDoubleValue_FLOAT(void *src, int32_t index) { ...@@ -93,6 +95,7 @@ double getVectorDoubleValue_FLOAT(void *src, int32_t index) {
double getVectorDoubleValue_DOUBLE(void *src, int32_t index) { double getVectorDoubleValue_DOUBLE(void *src, int32_t index) {
return (double)*((double *)src + index); return (double)*((double *)src + index);
} }
_getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
_getDoubleValue_fn_t p = NULL; _getDoubleValue_fn_t p = NULL;
if(srcType==TSDB_DATA_TYPE_TINYINT) { if(srcType==TSDB_DATA_TYPE_TINYINT) {
...@@ -218,6 +221,12 @@ void* getVectorValueAddr_FLOAT(void *src, int32_t index) { ...@@ -218,6 +221,12 @@ void* getVectorValueAddr_FLOAT(void *src, int32_t index) {
void* getVectorValueAddr_DOUBLE(void *src, int32_t index) { void* getVectorValueAddr_DOUBLE(void *src, int32_t index) {
return (void*)((double *)src + index); return (void*)((double *)src + index);
} }
void* getVectorValueAddr_default(void *src, int32_t index) {
return src;
}
void* getVectorValueAddr_VAR(void *src, int32_t index) {
return colDataGet((SColumnInfoData *)src, index);
}
_getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
_getValueAddr_fn_t p = NULL; _getValueAddr_fn_t p = NULL;
...@@ -241,8 +250,12 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { ...@@ -241,8 +250,12 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
p = getVectorValueAddr_FLOAT; p = getVectorValueAddr_FLOAT;
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) { }else if(srcType==TSDB_DATA_TYPE_DOUBLE) {
p = getVectorValueAddr_DOUBLE; p = getVectorValueAddr_DOUBLE;
}else if(srcType==TSDB_DATA_TYPE_BINARY) {
p = getVectorValueAddr_VAR;
}else if(srcType==TSDB_DATA_TYPE_NCHAR) {
p = getVectorValueAddr_VAR;
}else { }else {
assert(0); p = getVectorValueAddr_default;
} }
return p; return p;
} }
...@@ -267,6 +280,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -267,6 +280,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) + 1; int32_t bufSize = varDataLen(input) + 1;
char *tmp = malloc(bufSize); char *tmp = malloc(bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("malloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -295,6 +309,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -295,6 +309,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1; int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1;
char *tmp = calloc(1, bufSize); char *tmp = calloc(1, bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("calloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -309,7 +324,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -309,7 +324,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp); int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp);
if (len < 0){ if (len < 0){
qError("castConvert taosUcs4ToMbs error 1"); sclError("castConvert taosUcs4ToMbs error 1");
tfree(tmp); tfree(tmp);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
...@@ -343,6 +358,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -343,6 +358,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) + 1; int32_t bufSize = varDataLen(input) + 1;
char *tmp = malloc(bufSize); char *tmp = malloc(bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("malloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -370,6 +386,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -370,6 +386,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1; int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1;
char *tmp = calloc(1, bufSize); char *tmp = calloc(1, bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("calloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -384,7 +401,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -384,7 +401,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp); int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp);
if (len < 0){ if (len < 0){
qError("castConvert taosUcs4ToMbs error 1"); sclError("castConvert taosUcs4ToMbs error 1");
tfree(tmp); tfree(tmp);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
...@@ -420,6 +437,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -420,6 +437,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) + 1; int32_t bufSize = varDataLen(input) + 1;
char *tmp = malloc(bufSize); char *tmp = malloc(bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("malloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -448,6 +466,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -448,6 +466,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1; int32_t bufSize = varDataLen(input) * TSDB_NCHAR_SIZE + 1;
char *tmp = calloc(1, bufSize); char *tmp = calloc(1, bufSize);
if (NULL == tmp) { if (NULL == tmp) {
sclError("calloc %d failed", bufSize);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
...@@ -462,7 +481,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -462,7 +481,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp); int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), tmp);
if (len < 0){ if (len < 0){
qError("castConvert taosUcs4ToMbs error 1"); sclError("castConvert taosUcs4ToMbs error 1");
tfree(tmp); tfree(tmp);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
...@@ -493,7 +512,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) { ...@@ -493,7 +512,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
} }
break; break;
default: default:
qError("invalid convert output type:%d", outType); sclError("invalid convert output type:%d", outType);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
...@@ -541,6 +560,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p ...@@ -541,6 +560,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (SCL_DATA_TYPE_DUMMY_HASH == pLeft->type || SCL_DATA_TYPE_DUMMY_HASH == pRight->type) {
return TSDB_CODE_SUCCESS;
}
SScalarParam *param1 = NULL, *paramOut1 = NULL; SScalarParam *param1 = NULL, *paramOut1 = NULL;
SScalarParam *param2 = NULL, *paramOut2 = NULL; SScalarParam *param2 = NULL, *paramOut2 = NULL;
int32_t code = 0; int32_t code = 0;
...@@ -604,6 +627,46 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or ...@@ -604,6 +627,46 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(double));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(double));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
double *output=(double*)out; double *output=(double*)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -637,12 +700,55 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or ...@@ -637,12 +700,55 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) + getVectorDoubleValueFnRight(pRight->data,0)); SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) + getVectorDoubleValueFnRight(pRight->data,0));
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(double));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(double));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
double *output=(double*)out; double *output=(double*)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -675,11 +781,54 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or ...@@ -675,11 +781,54 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) - getVectorDoubleValueFnRight(pRight->data,0)); SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) - getVectorDoubleValueFnRight(pRight->data,0));
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(double));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(double));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
double *output=(double*)out; double *output=(double*)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -713,12 +862,55 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_ ...@@ -713,12 +862,55 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) * getVectorDoubleValueFnRight(pRight->data,0)); SET_DOUBLE_VAL(output,getVectorDoubleValueFnLeft(pLeft->data,i) * getVectorDoubleValueFnRight(pRight->data,0));
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(double));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(double));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
double *output=(double*)out; double *output=(double*)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -759,12 +951,55 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t ...@@ -759,12 +951,55 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
SET_DOUBLE_VAL(output, getVectorDoubleValueFnLeft(pLeft->data, i) / right); SET_DOUBLE_VAL(output, getVectorDoubleValueFnLeft(pLeft->data, i) / right);
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_DOUBLE, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(double));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(double)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(double));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(double)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
double * output = (double *)out; double * output = (double *)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -831,6 +1066,9 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32 ...@@ -831,6 +1066,9 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
SET_DOUBLE_VAL(output, left - ((int64_t)(left / right)) * right); SET_DOUBLE_VAL(output, left - ((int64_t)(left / right)) * right);
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
...@@ -888,6 +1126,46 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t ...@@ -888,6 +1126,46 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(int64_t));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(int64_t)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(int64_t));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(int64_t)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
int64_t *output=(int64_t *)out; int64_t *output=(int64_t *)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -921,12 +1199,55 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t ...@@ -921,12 +1199,55 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
SET_BIGINT_VAL(output,getVectorBigintValueFnLeft(pLeft->data,i) & getVectorBigintValueFnRight(pRight->data,0)); SET_BIGINT_VAL(output,getVectorBigintValueFnLeft(pLeft->data,i) & getVectorBigintValueFnRight(pRight->data,0));
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1; int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->num, pRight->num) - 1;
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
SScalarParam leftParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pLeft->num};
SScalarParam rightParam = {.type = TSDB_DATA_TYPE_BIGINT, .num = pRight->num};
if (IS_VAR_DATA_TYPE(pLeft->type)) {
leftParam.data = calloc(leftParam.num, sizeof(int64_t));
if (NULL == leftParam.data) {
sclError("malloc %d failed", (int32_t)(leftParam.num * sizeof(int64_t)));
return;
}
if (pLeft->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
pLeft->data = colInfo->pData;
}
if (vectorConvertImpl(pLeft, &leftParam)) {
return;
}
pLeft = &leftParam;
}
if (IS_VAR_DATA_TYPE(pRight->type)) {
rightParam.data = calloc(rightParam.num, sizeof(int64_t));
if (NULL == rightParam.data) {
sclError("malloc %d failed", (int32_t)(rightParam.num * sizeof(int64_t)));
tfree(leftParam.data);
return;
}
if (pRight->colData) {
SColumnInfoData *colInfo = (SColumnInfoData *)pRight->data;
pRight->data = colInfo->pData;
}
if (vectorConvertImpl(pRight, &rightParam)) {
tfree(leftParam.data);
tfree(rightParam.data);
return;
}
pRight = &rightParam;
}
int64_t *output=(int64_t *)out; int64_t *output=(int64_t *)out;
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type); _getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type); _getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
...@@ -960,6 +1281,9 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ ...@@ -960,6 +1281,9 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
SET_BIGINT_VAL(output,getVectorBigintValueFnLeft(pLeft->data,i) | getVectorBigintValueFnRight(pRight->data,0)); SET_BIGINT_VAL(output,getVectorBigintValueFnLeft(pLeft->data,i) | getVectorBigintValueFnRight(pRight->data,0));
} }
} }
tfree(leftParam.data);
tfree(rightParam.data);
} }
...@@ -1039,7 +1363,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t ...@@ -1039,7 +1363,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
param2 = pRight; param2 = pRight;
} }
vectorCompareImpl(param1, param2, out, _ord, TSDB_RELATION_GREATER); vectorCompareImpl(param1, param2, out, _ord, optr);
} }
void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册