[TD-4614]<feature> refactor hash code
This commit is contained in:
parent
ad78a984e8
commit
9e993339d8
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue