提交 e619a292 编写于 作者: C Cary Xu

feat: column support 63K and row support 64k

上级 405597e5
...@@ -83,10 +83,10 @@ struct SSchema; ...@@ -83,10 +83,10 @@ struct SSchema;
#define TSDB_FUNC_SCALAR_NAME_MAX_LEN 16 #define TSDB_FUNC_SCALAR_NAME_MAX_LEN 16
typedef struct { typedef struct {
int16_t type; int16_t type;
int16_t bytes; uint16_t bytes;
int32_t numOfRows; int32_t numOfRows;
char* data; char *data;
} tExprOperandInfo; } tExprOperandInfo;
typedef void (*_expr_scalar_function_t)(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order); typedef void (*_expr_scalar_function_t)(int16_t functionId, tExprOperandInfo* pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order);
...@@ -149,9 +149,9 @@ typedef struct tExprNode { ...@@ -149,9 +149,9 @@ typedef struct tExprNode {
TAOS_FIELD *pType; TAOS_FIELD *pType;
}; };
int16_t resultType; int16_t resultType;
int16_t resultBytes; uint16_t resultBytes;
int32_t precision; int32_t precision;
} tExprNode; } tExprNode;
typedef struct SExprTraverseSupp { typedef struct SExprTraverseSupp {
......
...@@ -55,7 +55,8 @@ typedef struct SSqlExpr { ...@@ -55,7 +55,8 @@ typedef struct SSqlExpr {
int32_t interBytes; // inter result buffer size int32_t interBytes; // inter result buffer size
int16_t colType; // table column type int16_t colType; // table column type
int16_t colBytes; // table column bytes,it should be int32_t, because it is too small for globale merge stage, pQueryAttr->interBytesForGlobal uint16_t colBytes; // table column bytes,it should be int32_t, because it is too small for globale merge stage,
// pQueryAttr->interBytesForGlobal
int16_t numOfParams; // argument value of each function int16_t numOfParams; // argument value of each function
tVariant param[3]; // parameters are not more than 3 tVariant param[3]; // parameters are not more than 3
......
...@@ -891,7 +891,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { ...@@ -891,7 +891,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) {
} else if (expr->nodeType == TSQL_NODE_COL) { } else if (expr->nodeType == TSQL_NODE_COL) {
SSchema* pSchema = expr->pSchema; SSchema* pSchema = expr->pSchema;
tbufWriteInt16(bw, pSchema->colId); tbufWriteInt16(bw, pSchema->colId);
tbufWriteInt16(bw, pSchema->bytes); tbufWriteUint16(bw, pSchema->bytes);
tbufWriteUint8(bw, pSchema->type); tbufWriteUint8(bw, pSchema->type);
tbufWriteString(bw, pSchema->name); tbufWriteString(bw, pSchema->name);
...@@ -908,7 +908,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { ...@@ -908,7 +908,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) {
} }
} }
tbufWriteInt16(bw, expr->resultType); tbufWriteInt16(bw, expr->resultType);
tbufWriteInt16(bw, expr->resultBytes); tbufWriteUint16(bw, expr->resultBytes);
} }
void exprTreeToBinary(SBufferWriter* bw, tExprNode* expr) { void exprTreeToBinary(SBufferWriter* bw, tExprNode* expr) {
...@@ -963,7 +963,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { ...@@ -963,7 +963,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) {
pExpr->pSchema = pSchema; pExpr->pSchema = pSchema;
pSchema->colId = tbufReadInt16(br); pSchema->colId = tbufReadInt16(br);
pSchema->bytes = tbufReadInt16(br); pSchema->bytes = tbufReadUint16(br);
pSchema->type = tbufReadUint8(br); pSchema->type = tbufReadUint8(br);
tbufReadToString(br, pSchema->name, TSDB_COL_NAME_LEN); tbufReadToString(br, pSchema->name, TSDB_COL_NAME_LEN);
...@@ -982,7 +982,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { ...@@ -982,7 +982,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) {
} }
} }
pExpr->resultType = tbufReadInt16(br); pExpr->resultType = tbufReadInt16(br);
pExpr->resultBytes = tbufReadInt16(br); pExpr->resultBytes = tbufReadUint16(br);
CLEANUP_EXECUTE_TO(anchor, false); CLEANUP_EXECUTE_TO(anchor, false);
return pExpr; return pExpr;
} }
...@@ -1288,10 +1288,10 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) { ...@@ -1288,10 +1288,10 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) {
} }
char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
tVariantDump(child->pVal, payload, resultType, true); tVariantDump(child->pVal, payload, resultType, true);
int16_t resultBytes = varDataTLen(payload); uint16_t resultBytes = varDataTLen(payload);
free(payload); free(payload);
child->resultType = resultType; child->resultType = resultType;
child->resultBytes = (int16_t)(resultBytes); child->resultBytes = resultBytes;
} }
} }
} else { } else {
...@@ -1308,7 +1308,7 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) { ...@@ -1308,7 +1308,7 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) {
} }
pExpr->resultType = resultType; pExpr->resultType = resultType;
int16_t resultBytes = 0; uint16_t resultBytes = 0;
for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) {
tExprNode *child = pExpr->_func.pChildren[i]; tExprNode *child = pExpr->_func.pChildren[i];
if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) {
...@@ -1360,10 +1360,10 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { ...@@ -1360,10 +1360,10 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) {
} }
char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
tVariantDump(child->pVal, payload, resultType, true); tVariantDump(child->pVal, payload, resultType, true);
int16_t resultBytes = varDataTLen(payload); uint16_t resultBytes = varDataTLen(payload);
free(payload); free(payload);
child->resultType = resultType; child->resultType = resultType;
child->resultBytes = (int16_t)(resultBytes); child->resultBytes = resultBytes;
} }
} }
} else { } else {
...@@ -1380,7 +1380,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { ...@@ -1380,7 +1380,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) {
} }
pExpr->resultType = resultType; pExpr->resultType = resultType;
int16_t resultBytes = 0; uint16_t resultBytes = 0;
for (int32_t i = 1; i < pExpr->_func.numChildren; ++i) { for (int32_t i = 1; i < pExpr->_func.numChildren; ++i) {
tExprNode *child = pExpr->_func.pChildren[i]; tExprNode *child = pExpr->_func.pChildren[i];
if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) { if (resultBytes <= resultBytes + child->resultBytes - VARSTR_HEADER_SIZE) {
...@@ -1390,7 +1390,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { ...@@ -1390,7 +1390,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) {
} }
} }
tExprNode* wsNode = pExpr->_func.pChildren[0]; tExprNode* wsNode = pExpr->_func.pChildren[0];
int16_t wsResultBytes = wsNode->resultBytes - VARSTR_HEADER_SIZE; uint16_t wsResultBytes = wsNode->resultBytes - VARSTR_HEADER_SIZE;
resultBytes += wsResultBytes * (pExpr->_func.numChildren - 2); resultBytes += wsResultBytes * (pExpr->_func.numChildren - 2);
pExpr->resultBytes = resultBytes + VARSTR_HEADER_SIZE; pExpr->resultBytes = resultBytes + VARSTR_HEADER_SIZE;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -1406,7 +1406,7 @@ int32_t exprValidateStringLengthNode(tExprNode *pExpr) { ...@@ -1406,7 +1406,7 @@ int32_t exprValidateStringLengthNode(tExprNode *pExpr) {
if (child1->nodeType == TSQL_NODE_VALUE) { if (child1->nodeType == TSQL_NODE_VALUE) {
child1->resultType = (int16_t)child1->pVal->nType; child1->resultType = (int16_t)child1->pVal->nType;
child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE);
} }
if (!IS_VAR_DATA_TYPE(child1->resultType)) { if (!IS_VAR_DATA_TYPE(child1->resultType)) {
...@@ -1428,7 +1428,7 @@ int32_t exprValidateStringLowerUpperTrimNode(char* msgBuf, tExprNode *pExpr) { ...@@ -1428,7 +1428,7 @@ int32_t exprValidateStringLowerUpperTrimNode(char* msgBuf, tExprNode *pExpr) {
if (child1->nodeType == TSQL_NODE_VALUE) { if (child1->nodeType == TSQL_NODE_VALUE) {
child1->resultType = (int16_t)child1->pVal->nType; child1->resultType = (int16_t)child1->pVal->nType;
child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE);
} }
if (!IS_VAR_DATA_TYPE(child1->resultType)) { if (!IS_VAR_DATA_TYPE(child1->resultType)) {
...@@ -1450,7 +1450,7 @@ int32_t exprValidateStringSubstrNode(char* msgBuf, tExprNode *pExpr) { ...@@ -1450,7 +1450,7 @@ int32_t exprValidateStringSubstrNode(char* msgBuf, tExprNode *pExpr) {
if (child1->nodeType == TSQL_NODE_VALUE) { if (child1->nodeType == TSQL_NODE_VALUE) {
child1->resultType = (int16_t)child1->pVal->nType; child1->resultType = (int16_t)child1->pVal->nType;
child1->resultBytes = (int16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE); child1->resultBytes = (uint16_t)(child1->pVal->nLen + VARSTR_HEADER_SIZE);
} }
if (!IS_VAR_DATA_TYPE(child1->resultType)) { if (!IS_VAR_DATA_TYPE(child1->resultType)) {
...@@ -1629,7 +1629,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1629,7 +1629,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
} }
child->nodeType = TSQL_NODE_VALUE; child->nodeType = TSQL_NODE_VALUE;
child->resultType = TSDB_DATA_TYPE_TIMESTAMP; child->resultType = TSDB_DATA_TYPE_TIMESTAMP;
child->resultBytes = (int16_t)tDataTypes[child->resultType].bytes; child->resultBytes = (uint16_t)tDataTypes[child->resultType].bytes;
child->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); child->pVal = (tVariant *)tcalloc(1, sizeof(tVariant));
if (!child->pVal) { if (!child->pVal) {
...@@ -1662,7 +1662,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1662,7 +1662,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
child->pVal->i64 = convertTimePrecision(timeVal, TSDB_TIME_PRECISION_MILLI, pExpr->precision); child->pVal->i64 = convertTimePrecision(timeVal, TSDB_TIME_PRECISION_MILLI, pExpr->precision);
} }
pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP; pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP;
pExpr->resultBytes = (int16_t)tDataTypes[pExpr->resultType].bytes; pExpr->resultBytes = (uint16_t)tDataTypes[pExpr->resultType].bytes;
break; break;
} }
case TSDB_FUNC_SCALAR_TIMEZONE: { case TSDB_FUNC_SCALAR_TIMEZONE: {
...@@ -1769,7 +1769,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1769,7 +1769,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
child1->pVal->i64 = (int64_t)pExpr->precision; child1->pVal->i64 = (int64_t)pExpr->precision;
pExpr->resultType = TSDB_DATA_TYPE_BIGINT; pExpr->resultType = TSDB_DATA_TYPE_BIGINT;
pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
break; break;
} }
case TSDB_FUNC_SCALAR_TIMETRUNCATE: { case TSDB_FUNC_SCALAR_TIMETRUNCATE: {
...@@ -1835,7 +1835,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1835,7 +1835,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
} }
child2->nodeType = TSQL_NODE_VALUE; child2->nodeType = TSQL_NODE_VALUE;
child2->resultType = TSDB_DATA_TYPE_BIGINT; child2->resultType = TSDB_DATA_TYPE_BIGINT;
child2->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; child2->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
child2->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); child2->pVal = (tVariant *)tcalloc(1, sizeof(tVariant));
if (!child2->pVal) { if (!child2->pVal) {
...@@ -1846,7 +1846,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1846,7 +1846,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
child2->pVal->i64 = (int64_t)pExpr->precision; child2->pVal->i64 = (int64_t)pExpr->precision;
pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP; pExpr->resultType = TSDB_DATA_TYPE_TIMESTAMP;
pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
break; break;
} }
case TSDB_FUNC_SCALAR_TIMEDIFF: { case TSDB_FUNC_SCALAR_TIMEDIFF: {
...@@ -1924,7 +1924,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1924,7 +1924,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
} }
childPrec->nodeType = TSQL_NODE_VALUE; childPrec->nodeType = TSQL_NODE_VALUE;
childPrec->resultType = TSDB_DATA_TYPE_BIGINT; childPrec->resultType = TSDB_DATA_TYPE_BIGINT;
childPrec->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; childPrec->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
childPrec->pVal = (tVariant *)tcalloc(1, sizeof(tVariant)); childPrec->pVal = (tVariant *)tcalloc(1, sizeof(tVariant));
if (!childPrec->pVal) { if (!childPrec->pVal) {
...@@ -1937,7 +1937,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { ...@@ -1937,7 +1937,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) {
free(child); free(child);
pExpr->resultType = TSDB_DATA_TYPE_BIGINT; pExpr->resultType = TSDB_DATA_TYPE_BIGINT;
pExpr->resultBytes = (int16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; pExpr->resultBytes = (uint16_t)tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
break; break;
} }
default: { default: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册