提交 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);
len = valueNode->node.resType.bytes; if (IS_VAR_DATA_TYPE(type)) {
len = varDataLen(buf);
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, &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);
param->data = columnData->pData; if (IS_VAR_DATA_TYPE(columnData->info.type)) {
param->data = columnData;
param->colData = true;
} else {
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);
...@@ -377,21 +395,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp ...@@ -377,21 +395,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
int32_t paramNum = scalarGetOperatorParamNum(node->opType); int32_t paramNum = scalarGetOperatorParamNum(node->opType);
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;
...@@ -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,10 +593,10 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) { ...@@ -588,10 +593,10 @@ 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;
} }
if (QUERY_NODE_FUNCTION == nodeType(pNode)) { if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
return sclWalkFunction(pNode, pContext); return sclWalkFunction(pNode, pContext);
} }
...@@ -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;
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册