Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7c1e4d31
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7c1e4d31
编写于
2月 21, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
8ebc7914
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
242 addition
and
248 deletion
+242
-248
include/libs/scalar/filter.h
include/libs/scalar/filter.h
+3
-10
include/libs/scalar/scalar.h
include/libs/scalar/scalar.h
+5
-0
include/util/compare.h
include/util/compare.h
+3
-0
include/util/thash.h
include/util/thash.h
+4
-0
source/common/src/tcompare.c
source/common/src/tcompare.c
+0
-149
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+1
-0
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+55
-74
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+3
-3
source/util/src/compare.c
source/util/src/compare.c
+156
-0
source/util/src/thashutil.c
source/util/src/thashutil.c
+12
-12
未找到文件。
include/libs/scalar/filter.h
浏览文件 @
7c1e4d31
...
...
@@ -12,16 +12,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
SCALA
R_H
#define TDENGINE_
SCALA
R_H
#ifndef TDENGINE_
FILTE
R_H
#define TDENGINE_
FILTE
R_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "function.h"
#include "nodes.h"
typedef
struct
SFilterInfo
SFilterInfo
;
typedef
struct
SFilterColumnParam
{
...
...
@@ -30,12 +27,8 @@ typedef struct SFilterColumnParam{
}
SFilterColumnParam
;
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
);
int32_t
scalarCalculate
(
SNode
*
pNode
,
SSDataBlock
*
pSrc
,
SScalarParam
*
pDst
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_
SCALA
R_H
#endif // TDENGINE_
FILTE
R_H
\ No newline at end of file
include/libs/scalar/scalar.h
浏览文件 @
7c1e4d31
...
...
@@ -21,12 +21,17 @@ extern "C" {
#include "function.h"
#include "nodes.h"
#include "querynodes.h"
typedef
struct
SFilterInfo
SFilterInfo
;
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
);
int32_t
scalarCalculate
(
SNode
*
pNode
,
SSDataBlock
*
pSrc
,
SScalarParam
*
pDst
);
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
);
int32_t
vectorGetConvertType
(
int32_t
type1
,
int32_t
type2
);
int32_t
vectorConvertImpl
(
SScalarParam
*
pIn
,
SScalarParam
*
pOut
);
#ifdef __cplusplus
...
...
include/util/compare.h
浏览文件 @
7c1e4d31
...
...
@@ -100,6 +100,9 @@ int32_t compareUint64ValDesc(const void *pLeft, const void *pRight);
int32_t
compareLenPrefixedStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareLenPrefixedWStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
);
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
optr
);
#ifdef __cplusplus
}
#endif
...
...
include/util/thash.h
浏览文件 @
7c1e4d31
...
...
@@ -55,6 +55,8 @@ uint32_t taosIntHash_64(const char *key, uint32_t len);
_hash_fn_t
taosGetDefaultHashFunction
(
int32_t
type
);
_equal_fn_t
taosGetDefaultEqualFunction
(
int32_t
type
);
typedef
struct
SHashNode
{
struct
SHashNode
*
next
;
uint32_t
hashVal
;
// the hash value of key
...
...
@@ -258,6 +260,8 @@ void* taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen);
*/
void
taosHashRelease
(
SHashObj
*
pHashObj
,
void
*
p
);
void
taosHashSetEqualFp
(
SHashObj
*
pHashObj
,
_equal_fn_t
fp
);
#ifdef __cplusplus
}
...
...
source/common/src/tcompare.c
浏览文件 @
7c1e4d31
...
...
@@ -15,155 +15,6 @@
#include "tcompare.h"
int32_t
compareStrPatternMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
assert
(
varDataLen
(
pRight
)
<=
TSDB_MAX_FIELD_LEN
);
char
*
pattern
=
calloc
(
varDataLen
(
pRight
)
+
1
,
sizeof
(
char
));
memcpy
(
pattern
,
varDataVal
(
pRight
),
varDataLen
(
pRight
));
size_t
sz
=
varDataLen
(
pLeft
);
char
*
buf
=
malloc
(
sz
+
1
);
memcpy
(
buf
,
varDataVal
(
pLeft
),
sz
);
buf
[
sz
]
=
0
;
int32_t
ret
=
patternMatch
(
pattern
,
buf
,
sz
,
&
pInfo
);
free
(
buf
);
free
(
pattern
);
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
}
int32_t
compareStrPatternNotMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
compareStrPatternMatch
(
pLeft
,
pRight
)
?
0
:
1
;
}
int32_t
compareWStrPatternMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
assert
(
varDataLen
(
pRight
)
<=
TSDB_MAX_FIELD_LEN
*
TSDB_NCHAR_SIZE
);
wchar_t
*
pattern
=
calloc
(
varDataLen
(
pRight
)
+
1
,
sizeof
(
wchar_t
));
memcpy
(
pattern
,
varDataVal
(
pRight
),
varDataLen
(
pRight
));
int32_t
ret
=
WCSPatternMatch
(
pattern
,
varDataVal
(
pLeft
),
varDataLen
(
pLeft
)
/
TSDB_NCHAR_SIZE
,
&
pInfo
);
free
(
pattern
);
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
}
int32_t
compareWStrPatternNotMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
compareWStrPatternMatch
(
pLeft
,
pRight
)
?
0
:
1
;
}
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
optr
)
{
__compar_fn_t
comparFn
=
NULL
;
if
(
optr
==
TSDB_RELATION_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
setChkInBytes1
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
setChkInBytes2
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
setChkInBytes4
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
setChkInBytes8
;
default:
assert
(
0
);
}
}
if
(
optr
==
TSDB_RELATION_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
setChkNotInBytes1
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
setChkNotInBytes2
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
setChkNotInBytes4
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
setChkNotInBytes8
;
default:
assert
(
0
);
}
}
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
comparFn
=
compareInt8Val
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
comparFn
=
compareInt16Val
;
break
;
case
TSDB_DATA_TYPE_INT
:
comparFn
=
compareInt32Val
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
comparFn
=
compareInt64Val
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
comparFn
=
compareFloatVal
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
comparFn
=
compareDoubleVal
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
{
if
(
optr
==
TSDB_RELATION_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
/* normal relational comparFn */
comparFn
=
compareLenPrefixedStr
;
}
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
TSDB_RELATION_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
comparFn
=
compareWStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_LIKE
)
{
comparFn
=
compareWStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
comparFn
=
compareLenPrefixedWStr
;
}
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
comparFn
=
compareUint8Val
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
comparFn
=
compareUint16Val
;
break
;
case
TSDB_DATA_TYPE_UINT
:
comparFn
=
compareUint32Val
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
comparFn
=
compareUint64Val
;
break
;
default:
comparFn
=
compareInt32Val
;
break
;
}
return
comparFn
;
}
__compar_fn_t
getKeyComparFunc
(
int32_t
keyType
,
int32_t
order
)
{
__compar_fn_t
comparFn
=
NULL
;
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
7c1e4d31
...
...
@@ -25,6 +25,7 @@ extern "C" {
#include "common.h"
#include "scalar.h"
#include "querynodes.h"
#include "query.h"
#define FILTER_DEFAULT_GROUP_SIZE 4
#define FILTER_DEFAULT_UNIT_SIZE 4
...
...
source/libs/scalar/src/filter.c
浏览文件 @
7c1e4d31
...
...
@@ -36,28 +36,27 @@ OptrStr gOptrStr[] = {
{
TSDB_RELATION_OR
,
"or"
},
{
TSDB_RELATION_NOT
,
"not"
},
{
TSDB_RELATION_MATCH
,
"match"
},
{
TSDB_RELATION_NMATCH
,
"nmatch"
},
{
TSDB_RELATION_CONTAINS
,
"contains"
},
{
TSDB_RELATION_NMATCH
,
"nmatch"
}
};
bool
filterRangeCompGi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
maxv
,
minr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
//
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return
result
>=
0
;
}
bool
filterRangeCompGe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
maxv
,
minr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
//
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return
result
>
0
;
}
bool
filterRangeCompLi
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
minv
,
maxr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
//
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return
result
<=
0
;
}
bool
filterRangeCompLe
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
int32_t
result
=
cfunc
(
minv
,
maxr
);
if
(
result
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
//
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return
result
<
0
;
}
bool
filterRangeCompii
(
const
void
*
minv
,
const
void
*
maxv
,
const
void
*
minr
,
const
void
*
maxr
,
__compar_fn_t
cfunc
)
{
...
...
@@ -1299,7 +1298,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
SListCell
*
cell
=
node
->
pParameterList
->
pHead
;
for
(
int32_t
i
=
0
;
i
<
node
->
pParameterList
->
length
;
++
i
)
{
nodesWalkNode
(
cell
->
pNode
,
fltTreeToGroup
,
(
void
*
)
pContext
);
FLT_ERR_JRET
(
ctx
.
code
);
FLT_ERR_JRET
(
ctx
->
code
);
}
return
DEAL_RES_IGNORE_CHILD
;
...
...
@@ -1316,7 +1315,7 @@ EDealRes fltTreeToGroup(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
scl
Error
(
"invalid node type for filter, type:%d"
,
nodeType
(
pNode
));
flt
Error
(
"invalid node type for filter, type:%d"
,
nodeType
(
pNode
));
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
...
...
@@ -1427,11 +1426,12 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_VALUE
].
num
;
++
i
)
{
SFilterField
*
field
=
&
info
->
fields
[
FLD_TYPE_VALUE
].
fields
[
i
];
if
(
field
->
desc
)
{
SVariant
*
var
=
field
->
desc
;
if
(
var
->
nType
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
if
(
dType
->
type
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
qDebug
(
"VAL%d => [type:TS][val:[%"
PRIi64
"] - [%"
PRId64
"]]"
,
i
,
*
(
int64_t
*
)
field
->
data
,
*
(((
int64_t
*
)
field
->
data
)
+
1
));
}
else
{
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
var
->
nType
,
var
->
i64
);
//TODO
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
//TODO
}
}
else
if
(
field
->
data
)
{
qDebug
(
"VAL%d => [type:NIL][val:NIL]"
,
i
);
//TODO
...
...
@@ -1448,7 +1448,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SFilterField
*
left
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
SColumnRefNode
*
refNode
=
(
SColumnRefNode
*
)
left
->
desc
;
if
(
unit
->
compare
.
optr
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr
<=
TSDB_RELATION_
CONTAINS
){
if
(
unit
->
compare
.
optr
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr
<=
TSDB_RELATION_
NMATCH
){
len
=
sprintf
(
str
,
"UNIT[%d] => [%d][%d] %s ["
,
i
,
refNode
->
tupleId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr
].
str
);
}
...
...
@@ -1467,7 +1467,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
if
(
unit
->
compare
.
optr2
)
{
strcat
(
str
,
" && "
);
if
(
unit
->
compare
.
optr2
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr2
<=
TSDB_RELATION_
CONTAINS
){
if
(
unit
->
compare
.
optr2
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr2
<=
TSDB_RELATION_
NMATCH
){
sprintf
(
str
+
strlen
(
str
),
"[%d][%d] %s ["
,
refNode
->
tupleId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr2
].
str
);
}
...
...
@@ -1785,7 +1785,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
uint32_t
type
=
FILTER_UNIT_DATA_TYPE
(
unit
);
SFilterField
*
fi
=
right
;
SVa
riant
*
var
=
fi
->
desc
;
SVa
lueNode
*
var
=
(
SValueNode
*
)
fi
->
desc
;
if
(
var
==
NULL
)
{
assert
(
fi
->
data
!=
NULL
);
...
...
@@ -1804,20 +1804,23 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
continue
;
}
SDataType
*
dType
=
&
var
->
node
.
resType
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
size_t
len
=
(
var
->
nType
==
TSDB_DATA_TYPE_BINARY
||
var
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
?
var
->
nLen
:
MAX_NUM_STR_SIZE
;
size_t
len
=
(
dType
->
type
==
TSDB_DATA_TYPE_BINARY
||
dType
->
type
==
TSDB_DATA_TYPE_NCHAR
)
?
dType
->
bytes
:
MAX_NUM_STR_SIZE
;
fi
->
data
=
calloc
(
1
,
len
+
1
+
VARSTR_HEADER_SIZE
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
size_t
len
=
(
var
->
nType
==
TSDB_DATA_TYPE_BINARY
||
var
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
?
var
->
nLen
:
MAX_NUM_STR_SIZE
;
size_t
len
=
(
dType
->
type
==
TSDB_DATA_TYPE_BINARY
||
dType
->
type
==
TSDB_DATA_TYPE_NCHAR
)
?
dType
->
bytes
:
MAX_NUM_STR_SIZE
;
fi
->
data
=
calloc
(
1
,
(
len
+
1
)
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
);
}
else
if
(
type
!=
TSDB_DATA_TYPE_JSON
){
if
(
var
->
nType
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
//TIME RANGE
fi
->
data
=
calloc
(
var
->
nLen
,
tDataTypes
[
type
].
bytes
);
for
(
int32_t
a
=
0
;
a
<
var
->
nLen
;
++
a
)
{
if
(
dType
->
type
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
//TIME RANGE
/*
fi->data = calloc(dType->bytes, tDataTypes[type].bytes);
for (int32_t a = 0; a < dType->bytes; ++a) {
int64_t *v = taosArrayGet(var->arr, a);
assignVal((char *)fi->data + a * tDataTypes[type].bytes, (char *)v, 0, type);
}
*/
continue
;
}
else
{
fi
->
data
=
calloc
(
1
,
sizeof
(
int64_t
));
...
...
@@ -1829,13 +1832,10 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
if
(
type
!=
TSDB_DATA_TYPE_JSON
){
bool
converted
=
false
;
char
extInfo
=
0
;
if
(
tVariantDumpEx
(
var
,
(
char
*
)
fi
->
data
,
type
,
true
,
&
converted
,
&
extInfo
))
{
if
(
converted
)
{
filterHandleValueExtInfo
(
unit
,
extInfo
);
continue
;
}
qError
(
"dump value to type[%d] failed"
,
type
);
SScalarParam
in
=
{.
data
=
nodesGetValueFromNode
(
var
),
.
num
=
1
,
.
type
=
dType
->
type
,
.
bytes
=
dType
->
bytes
};
SScalarParam
out
=
{.
data
=
fi
->
data
,
.
num
=
1
,
.
type
=
type
};
if
(
vectorConvertImpl
(
&
in
,
&
out
))
{
qError
(
"convert value to type[%d] failed"
,
type
);
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
...
...
@@ -1851,18 +1851,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
}
varDataSetLen
(
newValData
,
len
);
varDataCopy
(
fi
->
data
,
newValData
);
}
else
if
(
type
==
TSDB_DATA_TYPE_JSON
&&
(
unit
->
compare
.
optr
==
TSDB_RELATION_MATCH
||
unit
->
compare
.
optr
==
TSDB_RELATION_NMATCH
)){
char
newValData
[
TSDB_REGEX_STRING_DEFAULT_LEN
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
len
=
taosUcs4ToMbs
(((
tVariant
*
)(
fi
->
desc
))
->
pz
,
((
tVariant
*
)(
fi
->
desc
))
->
nLen
,
newValData
);
if
(
len
<
0
){
qError
(
"filterInitValFieldData taosUcs4ToMbs error 2"
);
return
TSDB_CODE_FAILED
;
}
memcpy
(((
tVariant
*
)(
fi
->
desc
))
->
pz
,
newValData
,
len
);
((
tVariant
*
)(
fi
->
desc
))
->
nLen
=
len
;
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1872,8 +1861,6 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
bool
filterDoCompare
(
__compar_fn_t
func
,
uint8_t
optr
,
void
*
left
,
void
*
right
)
{
int32_t
ret
=
func
(
left
,
right
);
if
(
ret
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
switch
(
optr
)
{
case
TSDB_RELATION_EQUAL
:
{
return
ret
==
0
;
...
...
@@ -1899,9 +1886,6 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case
TSDB_RELATION_MATCH
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_CONTAINS
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_NMATCH
:
{
return
ret
==
0
;
}
...
...
@@ -1968,25 +1952,25 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *c
}
int32_t
filterCompareRangeCtx
(
SFilterRangeCtx
*
ctx1
,
SFilterRangeCtx
*
ctx2
,
bool
*
equal
)
{
CHK_JMP
(
ctx1
->
status
!=
ctx2
->
status
);
CHK_JMP
(
ctx1
->
isnull
!=
ctx2
->
isnull
);
CHK_JMP
(
ctx1
->
notnull
!=
ctx2
->
notnull
);
CHK_JMP
(
ctx1
->
isrange
!=
ctx2
->
isrange
);
FLT_
CHK_JMP
(
ctx1
->
status
!=
ctx2
->
status
);
FLT_
CHK_JMP
(
ctx1
->
isnull
!=
ctx2
->
isnull
);
FLT_
CHK_JMP
(
ctx1
->
notnull
!=
ctx2
->
notnull
);
FLT_
CHK_JMP
(
ctx1
->
isrange
!=
ctx2
->
isrange
);
SFilterRangeNode
*
r1
=
ctx1
->
rs
;
SFilterRangeNode
*
r2
=
ctx2
->
rs
;
while
(
r1
&&
r2
)
{
CHK_JMP
(
r1
->
ra
.
sflag
!=
r2
->
ra
.
sflag
);
CHK_JMP
(
r1
->
ra
.
eflag
!=
r2
->
ra
.
eflag
);
CHK_JMP
(
r1
->
ra
.
s
!=
r2
->
ra
.
s
);
CHK_JMP
(
r1
->
ra
.
e
!=
r2
->
ra
.
e
);
FLT_
CHK_JMP
(
r1
->
ra
.
sflag
!=
r2
->
ra
.
sflag
);
FLT_
CHK_JMP
(
r1
->
ra
.
eflag
!=
r2
->
ra
.
eflag
);
FLT_
CHK_JMP
(
r1
->
ra
.
s
!=
r2
->
ra
.
s
);
FLT_
CHK_JMP
(
r1
->
ra
.
e
!=
r2
->
ra
.
e
);
r1
=
r1
->
next
;
r2
=
r2
->
next
;
}
CHK_JMP
(
r1
!=
r2
);
FLT_
CHK_JMP
(
r1
!=
r2
);
*
equal
=
true
;
...
...
@@ -2009,11 +1993,11 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI
uint8_t
optr
=
FILTER_UNIT_OPTR
(
u
);
filterAddRangeOptr
(
ctx
,
optr
,
TSDB_RELATION_AND
,
empty
,
NULL
);
CHK_JMP
(
*
empty
);
FLT_
CHK_JMP
(
*
empty
);
if
(
!
FILTER_NO_MERGE_OPTR
(
optr
))
{
filterAddUnitRange
(
info
,
u
,
ctx
,
TSDB_RELATION_AND
);
CHK_JMP
(
MR_EMPTY_RES
(
ctx
));
FLT_
CHK_JMP
(
MR_EMPTY_RES
(
ctx
));
}
if
(
FILTER_UNIT_OPTR
(
u
)
==
TSDB_RELATION_EQUAL
&&
!
FILTER_NO_MERGE_DATA_TYPE
(
FILTER_UNIT_DATA_TYPE
(
u
))){
gRes
->
colInfo
[
colIdx
].
optr
=
TSDB_RELATION_EQUAL
;
...
...
@@ -2214,7 +2198,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
filterMergeTwoGroupsImpl
(
info
,
&
ctx
,
TSDB_RELATION_OR
,
idx1
,
*
gRes1
,
*
gRes2
,
NULL
,
all
);
CHK_JMP
(
*
all
);
FLT_
CHK_JMP
(
*
all
);
if
(
numEqual
)
{
if
((
*
gRes1
)
->
colNum
==
1
)
{
...
...
@@ -2234,7 +2218,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
++
equal2
;
}
CHK_JMP
(
equal1
!=
merNum
&&
equal2
!=
merNum
);
FLT_
CHK_JMP
(
equal1
!=
merNum
&&
equal2
!=
merNum
);
colCtx
.
colIdx
=
idx1
;
colCtx
.
ctx
=
ctx
;
ctx
=
NULL
;
...
...
@@ -2246,7 +2230,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter
++
equal1
;
}
CHK_JMP
(
equal1
!=
merNum
);
FLT_
CHK_JMP
(
equal1
!=
merNum
);
colCtx
.
colIdx
=
idx1
;
colCtx
.
ctx
=
ctx
;
ctx
=
NULL
;
...
...
@@ -2327,7 +2311,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
assert
(
m
<
n
);
filterMergeTwoGroups
(
info
,
&
gRes
[
m
],
&
gRes
[
n
],
&
all
);
CHK_JMP
(
all
);
FLT_
CHK_JMP
(
all
);
if
(
gRes
[
n
]
==
NULL
)
{
if
(
n
<
((
*
gResNum
)
-
1
))
{
...
...
@@ -2348,7 +2332,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
assert
(
m
<
n
);
filterMergeTwoGroups
(
info
,
&
gRes
[
m
],
&
gRes
[
n
],
&
all
);
CHK_JMP
(
all
);
FLT_
CHK_JMP
(
all
);
if
(
gRes
[
n
]
==
NULL
)
{
if
(
n
<
((
*
gResNum
)
-
1
))
{
...
...
@@ -2503,7 +2487,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
idxs
[
colNum
++
]
=
i
;
}
CHK_JMP
(
colNum
<=
0
);
FLT_
CHK_JMP
(
colNum
<=
0
);
info
->
colRangeNum
=
colNum
;
info
->
colRange
=
calloc
(
colNum
,
POINTER_BYTES
);
...
...
@@ -2543,7 +2527,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_
--
info
->
colRangeNum
;
--
m
;
CHK_JMP
(
info
->
colRangeNum
<=
0
);
FLT_
CHK_JMP
(
info
->
colRangeNum
<=
0
);
}
++
n
;
...
...
@@ -2672,7 +2656,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
if
(
cunit
->
optr
==
TSDB_RELATION_ISNULL
||
cunit
->
optr
==
TSDB_RELATION_NOTNULL
||
cunit
->
optr
==
TSDB_RELATION_IN
||
cunit
->
optr
==
TSDB_RELATION_LIKE
||
cunit
->
optr
==
TSDB_RELATION_MATCH
||
cunit
->
optr
==
TSDB_RELATION_NOT_EQUAL
||
cunit
->
optr
==
TSDB_RELATION_CONTAINS
)
{
||
cunit
->
optr
==
TSDB_RELATION_NOT_EQUAL
)
{
continue
;
}
...
...
@@ -2973,7 +2957,7 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
return
all
;
}
bool
filterExecuteImplRange
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
S
DataStatis
*
statis
,
int16_t
numOfCols
)
{
bool
filterExecuteImplRange
(
void
*
pinfo
,
int32_t
numOfRows
,
int8_t
**
p
,
S
ColumnDataAgg
*
statis
,
int16_t
numOfCols
)
{
SFilterInfo
*
info
=
(
SFilterInfo
*
)
pinfo
;
bool
all
=
true
;
uint16_t
dataSize
=
info
->
cunits
[
0
].
dataSize
;
...
...
@@ -3175,13 +3159,13 @@ int32_t filterPreprocess(SFilterInfo *info) {
filterMergeGroups
(
info
,
gRes
,
&
gResNum
);
if
(
FILTER_GET_FLAG
(
info
->
status
,
FI_STATUS_ALL
))
{
q
Info
(
"Final - FilterInfo: [ALL]"
);
flt
Info
(
"Final - FilterInfo: [ALL]"
);
goto
_return
;
}
if
(
FILTER_GET_FLAG
(
info
->
status
,
FI_STATUS_EMPTY
))
{
q
Info
(
"Final - FilterInfo: [EMPTY]"
);
flt
Info
(
"Final - FilterInfo: [EMPTY]"
);
goto
_return
;
}
...
...
@@ -3210,9 +3194,6 @@ _return:
int32_t
fltSetColFieldDataImpl
(
SFilterInfo
*
info
,
void
*
param
,
filer_get_col_from_id
fp
,
bool
fromColId
)
{
CHK_LRET
(
info
==
NULL
,
TSDB_CODE_QRY_APP_ERROR
,
"info NULL"
);
CHK_LRET
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
<=
0
,
TSDB_CODE_QRY_APP_ERROR
,
"no column fileds"
);
if
(
FILTER_ALL_RES
(
info
)
||
FILTER_EMPTY_RES
(
info
))
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3392,7 +3373,7 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
uint8_t
raOptr
=
FILTER_UNIT_OPTR
(
unit
);
filterAddRangeOptr
(
cur
,
raOptr
,
TSDB_RELATION_AND
,
&
empty
,
NULL
);
CHK_JMP
(
empty
);
FLT_
CHK_JMP
(
empty
);
if
(
FILTER_NO_MERGE_OPTR
(
raOptr
))
{
continue
;
...
...
@@ -3431,7 +3412,7 @@ int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win) {
FLT_ERR_JRET
(
TSDB_CODE_QRY_INVALID_TIME_CONDITION
);
}
CHK_JMP
(
num
<
1
);
FLT_
CHK_JMP
(
num
<
1
);
SFilterRange
tra
;
filterGetRangeRes
(
prev
,
&
tra
);
...
...
@@ -3526,7 +3507,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
SListCell
*
cell
=
node
->
pParameterList
->
pHead
;
for
(
int32_t
i
=
0
;
i
<
node
->
pParameterList
->
length
;
++
i
)
{
if
(
NULL
==
cell
||
NULL
==
cell
->
pNode
)
{
scl
Error
(
"invalid cell, cell:%p, pNode:%p"
,
cell
,
cell
->
pNode
);
flt
Error
(
"invalid cell, cell:%p, pNode:%p"
,
cell
,
cell
->
pNode
);
stat
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
...
...
@@ -3562,8 +3543,8 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
}
if
(
NULL
==
node
->
pRight
)
{
if
(
sc
l
GetOperatorParamNum
(
node
->
opType
)
>
1
)
{
sclError
(
"invalid operator, pRight:%d
, type:%d"
,
node
->
pRight
,
nodeType
(
node
));
if
(
sc
alar
GetOperatorParamNum
(
node
->
opType
)
>
1
)
{
fltError
(
"invalid operator, pRight:%p
, type:%d"
,
node
->
pRight
,
nodeType
(
node
));
stat
->
code
=
TSDB_CODE_QRY_APP_ERROR
;
return
DEAL_RES_ERROR
;
}
...
...
@@ -3614,7 +3595,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
scl
Error
(
"invalid node type for filter, type:%d"
,
nodeType
(
*
pNode
));
flt
Error
(
"invalid node type for filter, type:%d"
,
nodeType
(
*
pNode
));
stat
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
7c1e4d31
...
...
@@ -6,7 +6,7 @@
#include "sclvector.h"
#include "sclInt.h"
int32_t
sc
l
GetOperatorParamNum
(
EOperatorType
type
)
{
int32_t
sc
alar
GetOperatorParamNum
(
EOperatorType
type
)
{
if
(
OP_TYPE_IS_NULL
==
type
||
OP_TYPE_IS_NOT_NULL
==
type
)
{
return
1
;
}
...
...
@@ -153,7 +153,7 @@ _return:
int32_t
sclInitOperatorParams
(
SScalarParam
**
pParams
,
SOperatorNode
*
node
,
SScalarCtx
*
ctx
,
int32_t
*
rowNum
)
{
int32_t
code
=
0
;
int32_t
paramNum
=
sc
l
GetOperatorParamNum
(
node
->
opType
);
int32_t
paramNum
=
sc
alar
GetOperatorParamNum
(
node
->
opType
);
if
(
NULL
==
node
->
pLeft
||
(
paramNum
==
2
&&
NULL
==
node
->
pRight
))
{
sclError
(
"invalid operation node, left:%p, right:%p"
,
node
->
pLeft
,
node
->
pRight
);
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
...
...
@@ -299,7 +299,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
node
->
opType
);
int32_t
paramNum
=
sc
l
GetOperatorParamNum
(
node
->
opType
);
int32_t
paramNum
=
sc
alar
GetOperatorParamNum
(
node
->
opType
);
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
...
...
source/util/src/compare.c
浏览文件 @
7c1e4d31
...
...
@@ -23,6 +23,8 @@
#include "thash.h"
#include "types.h"
#include "ulog.h"
#include "tdef.h"
#include "taos.h"
int32_t
setChkInBytes1
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
NULL
!=
taosHashGet
((
SHashObj
*
)
pRight
,
pLeft
,
1
)
?
1
:
0
;
...
...
@@ -418,3 +420,157 @@ int32_t taosArrayCompareString(const void* a, const void* b) {
return
compareLenPrefixedStr
(
x
,
y
);
}
int32_t
compareStrPatternMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
assert
(
varDataLen
(
pRight
)
<=
TSDB_MAX_FIELD_LEN
);
char
*
pattern
=
calloc
(
varDataLen
(
pRight
)
+
1
,
sizeof
(
char
));
memcpy
(
pattern
,
varDataVal
(
pRight
),
varDataLen
(
pRight
));
size_t
sz
=
varDataLen
(
pLeft
);
char
*
buf
=
malloc
(
sz
+
1
);
memcpy
(
buf
,
varDataVal
(
pLeft
),
sz
);
buf
[
sz
]
=
0
;
int32_t
ret
=
patternMatch
(
pattern
,
buf
,
sz
,
&
pInfo
);
free
(
buf
);
free
(
pattern
);
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
}
int32_t
compareStrPatternNotMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
compareStrPatternMatch
(
pLeft
,
pRight
)
?
0
:
1
;
}
int32_t
compareWStrPatternMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SPatternCompareInfo
pInfo
=
{
'%'
,
'_'
};
assert
(
varDataLen
(
pRight
)
<=
TSDB_MAX_FIELD_LEN
*
TSDB_NCHAR_SIZE
);
wchar_t
*
pattern
=
calloc
(
varDataLen
(
pRight
)
+
1
,
sizeof
(
wchar_t
));
memcpy
(
pattern
,
varDataVal
(
pRight
),
varDataLen
(
pRight
));
int32_t
ret
=
WCSPatternMatch
(
pattern
,
varDataVal
(
pLeft
),
varDataLen
(
pLeft
)
/
TSDB_NCHAR_SIZE
,
&
pInfo
);
free
(
pattern
);
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
}
int32_t
compareWStrPatternNotMatch
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
compareWStrPatternMatch
(
pLeft
,
pRight
)
?
0
:
1
;
}
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
optr
)
{
__compar_fn_t
comparFn
=
NULL
;
if
(
optr
==
TSDB_RELATION_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
setChkInBytes1
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
setChkInBytes2
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
setChkInBytes4
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
setChkInBytes8
;
default:
assert
(
0
);
}
}
if
(
optr
==
TSDB_RELATION_NOT_IN
&&
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
))
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
setChkNotInBytes1
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
setChkNotInBytes2
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_FLOAT
:
return
setChkNotInBytes4
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
setChkNotInBytes8
;
default:
assert
(
0
);
}
}
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
comparFn
=
compareInt8Val
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
comparFn
=
compareInt16Val
;
break
;
case
TSDB_DATA_TYPE_INT
:
comparFn
=
compareInt32Val
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
comparFn
=
compareInt64Val
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
comparFn
=
compareFloatVal
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
comparFn
=
compareDoubleVal
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
{
if
(
optr
==
TSDB_RELATION_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
/* normal relational comparFn */
comparFn
=
compareLenPrefixedStr
;
}
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
optr
==
TSDB_RELATION_MATCH
)
{
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
comparFn
=
compareWStrPatternMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_LIKE
)
{
comparFn
=
compareWStrPatternNotMatch
;
}
else
if
(
optr
==
TSDB_RELATION_IN
)
{
comparFn
=
compareChkInString
;
}
else
if
(
optr
==
TSDB_RELATION_NOT_IN
)
{
comparFn
=
compareChkNotInString
;
}
else
{
comparFn
=
compareLenPrefixedWStr
;
}
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
comparFn
=
compareUint8Val
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
comparFn
=
compareUint16Val
;
break
;
case
TSDB_DATA_TYPE_UINT
:
comparFn
=
compareUint32Val
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
comparFn
=
compareUint64Val
;
break
;
default:
comparFn
=
compareInt32Val
;
break
;
}
return
comparFn
;
}
source/util/src/thashutil.c
浏览文件 @
7c1e4d31
...
...
@@ -164,20 +164,20 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type) {
return
fn
;
}
//
int32_t taosFloatEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) {
//
return getComparFunc(TSDB_DATA_TYPE_FLOAT, -1)(a, b);
//
}
//
//
int32_t taosDoubleEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) {
//
return getComparFunc(TSDB_DATA_TYPE_DOUBLE, -1)(a, b);
//
}
int32_t
taosFloatEqual
(
const
void
*
a
,
const
void
*
b
,
size_t
UNUSED_PARAM
(
sz
))
{
return
getComparFunc
(
TSDB_DATA_TYPE_FLOAT
,
-
1
)(
a
,
b
);
}
int32_t
taosDoubleEqual
(
const
void
*
a
,
const
void
*
b
,
size_t
UNUSED_PARAM
(
sz
))
{
return
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
-
1
)(
a
,
b
);
}
_equal_fn_t
taosGetDefaultEqualFunction
(
int32_t
type
)
{
_equal_fn_t
fn
=
NULL
;
//
switch (type) {
//
case TSDB_DATA_TYPE_FLOAT: fn = taosFloatEqual; break;
//
case TSDB_DATA_TYPE_DOUBLE: fn = taosDoubleEqual; break;
//
default: fn = memcmp; break;
//
}
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
fn
=
taosFloatEqual
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
fn
=
taosDoubleEqual
;
break
;
default:
fn
=
memcmp
;
break
;
}
return
fn
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录