提交 9e993339 编写于 作者: Y yihaoDeng

[TD-4614]<feature> refactor hash code

上级 ad78a984
......@@ -150,12 +150,9 @@ int16_t getNewResColId(SSqlCmd* pCmd) {
// formate "type | size | value"
bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType) {
bool ret = false;
if (!pList || pList->size <= 0) {
if (!pList || pList->size <= 0 || colType < 0) {
return ret;
}
//if (colType == TSDB_DATA_TYPE_DOUBLE || colType == TSDB_DATA_TYPE_FLOAT) {
// return ret;
//}
tSqlExprItem* item = (tSqlExprItem *)taosArrayGet(pList, 0);
int32_t firstTokenType = item->pNode->token.type;
......@@ -8069,18 +8066,23 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
return TSDB_CODE_SUCCESS;
} else if (pSqlExpr->tokenId == TK_SET) {
int32_t type = -1;
int32_t colType = -1;
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
if (pCols != NULL) {
SColIndex* idx = taosArrayGet(pCols, 0);
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex);
if (pSchema != NULL) {
type = pSchema->type;
colType = pSchema->type;
}
}
tVariant *pVal;
if (serializeExprListToVariant(pSqlExpr->pParam, &pVal, type) == false) {
if (colType >= TSDB_DATA_TYPE_TINYINT && colType <= TSDB_DATA_TYPE_BIGINT) {
colType = TSDB_DATA_TYPE_BIGINT;
} else if (colType == TSDB_DATA_TYPE_FLOAT || colType == TSDB_DATA_TYPE_DOUBLE) {
colType = TSDB_DATA_TYPE_DOUBLE;
}
if (serializeExprListToVariant(pSqlExpr->pParam, &pVal, colType) == false) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "not support filter expression");
}
*pExpr = calloc(1, sizeof(tExprNode));
......
......@@ -20,6 +20,9 @@
#define ROTL32(x, r) ((x) << (r) | (x) >> (32u - (r)))
#define DLT (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON)
#define BASE 1000
#define FMIX32(h) \
do { \
(h) ^= (h) >> 16; \
......@@ -87,7 +90,10 @@ uint32_t taosFloatHash(const char *key, uint32_t UNUSED_PARAM(len)) {
if (FLT_EQUAL(f, 0.0)) {
return 0;
}
int t = (int)round(f);
if (f >= (FLT_MAX/BASE - DLT) || f <= (FLT_MIN/BASE - DLT)){
return 0x7fc00000;
}
int t = (int)round(BASE * (f + DLT));
return (uint32_t)t;
}
uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) {
......@@ -99,7 +105,10 @@ uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) {
if (FLT_EQUAL(f, 0.0)) {
return 0;
}
int t = (int)(round(f));
if (f >= (DBL_MAX/BASE - DLT) || f <= (DBL_MIN/BASE - DLT)){
return 0x7fc00000;
}
int t = (int)(round(BASE * (f + DLT)));
return (uint32_t)t;
}
uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册