Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
33dbf051
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
33dbf051
编写于
4月 17, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-98] fix bugs for group by + tag filter query
上级
0d2b5ca6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
81 addition
and
84 deletion
+81
-84
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+2
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+10
-11
src/query/inc/qast.h
src/query/inc/qast.h
+0
-1
src/query/src/qast.c
src/query/src/qast.c
+4
-4
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+0
-2
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+13
-14
src/util/inc/tcompare.h
src/util/inc/tcompare.h
+1
-19
src/util/src/tcompare.c
src/util/src/tcompare.c
+47
-28
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+2
-2
未找到文件。
src/client/src/tscAsync.c
浏览文件 @
33dbf051
...
@@ -47,7 +47,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
...
@@ -47,7 +47,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
pSql
->
signature
=
pSql
;
pSql
->
signature
=
pSql
;
pSql
->
param
=
param
;
pSql
->
param
=
param
;
pSql
->
pTscObj
=
pObj
;
pSql
->
pTscObj
=
pObj
;
pSql
->
maxRetry
=
TSDB_REPLICA_MAX_NUM
;
pSql
->
maxRetry
=
1
;
pSql
->
fp
=
fp
;
pSql
->
fp
=
fp
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
...
...
src/client/src/tscServer.c
浏览文件 @
33dbf051
...
@@ -825,7 +825,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -825,7 +825,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
=
doSerializeTableInfo
(
pSql
,
htons
(
pQueryMsg
->
head
.
vgId
),
pMsg
);
pMsg
=
doSerializeTableInfo
(
pSql
,
htons
(
pQueryMsg
->
head
.
vgId
),
pMsg
);
SSqlGroupbyExpr
*
pGroupbyExpr
=
&
pQueryInfo
->
groupbyExpr
;
SSqlGroupbyExpr
*
pGroupbyExpr
=
&
pQueryInfo
->
groupbyExpr
;
if
(
pGroupbyExpr
->
numOfGroupCols
!=
0
)
{
if
(
pGroupbyExpr
->
numOfGroupCols
>
0
)
{
pQueryMsg
->
orderByIdx
=
htons
(
pGroupbyExpr
->
orderIndex
);
pQueryMsg
->
orderByIdx
=
htons
(
pGroupbyExpr
->
orderIndex
);
pQueryMsg
->
orderType
=
htons
(
pGroupbyExpr
->
orderType
);
pQueryMsg
->
orderType
=
htons
(
pGroupbyExpr
->
orderType
);
...
...
src/client/src/tscSql.c
浏览文件 @
33dbf051
...
@@ -774,8 +774,9 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
...
@@ -774,8 +774,9 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
if
(
pRes
==
NULL
||
pRes
->
qhandle
==
0
)
{
if
(
pRes
==
NULL
||
pRes
->
qhandle
==
0
)
{
/* Query rsp is not received from vnode, so the qhandle is NULL */
/* Query rsp is not received from vnode, so the qhandle is NULL */
tscTrace
(
"%p qhandle is null, abort free, fp:%p"
,
pSql
,
pSql
->
fp
);
tscTrace
(
"%p qhandle is null, abort free, fp:%p"
,
pSql
,
pSql
->
fp
);
STscObj
*
pTscObj
=
pSql
->
pTscObj
;
if
(
tscShouldFreeAsyncSqlObj
(
pSql
)
)
{
if
(
pTscObj
->
pSql
!=
pSql
)
{
tscTrace
(
"%p SqlObj is freed by app"
,
pSql
);
tscTrace
(
"%p SqlObj is freed by app"
,
pSql
);
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
}
else
{
}
else
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
33dbf051
...
@@ -1207,7 +1207,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -1207,7 +1207,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
// all subqueries are failed
// all subqueries are failed
tscError
(
"%p retrieve from %d vnode(s) completed,code:%d.FAILED."
,
pPObj
,
pState
->
numOfTotal
,
pState
->
code
);
tscError
(
"%p retrieve from %d vnode(s) completed,code:%d.FAILED."
,
pPObj
,
pState
->
numOfTotal
,
pState
->
code
);
pPObj
->
res
.
code
=
-
(
pState
->
code
)
;
pPObj
->
res
.
code
=
pState
->
code
;
// release allocated resource
// release allocated resource
tscLocalReducerEnvDestroy
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
trsupport
->
pFinalColModel
,
tscLocalReducerEnvDestroy
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
trsupport
->
pFinalColModel
,
...
@@ -1336,12 +1336,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
...
@@ -1336,12 +1336,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
// STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
// SVnodeSidList *vnodeInfo = tscGetVnodeSidList(pTableMetaInfo->pMetricMeta, idx);
// SVnodeSidList *vnodeInfo = 0;
// SVnodeDesc * pSvd = &vnodeInfo->vpeerDesc[vnodeInfo->index];
if
(
numOfRows
>
0
)
{
if
(
numOfRows
>
0
)
{
assert
(
pRes
->
numOfRows
==
numOfRows
);
assert
(
pRes
->
numOfRows
==
numOfRows
);
int64_t
num
=
atomic_add_fetch_64
(
&
pState
->
numOfRetrievedRows
,
numOfRows
);
int64_t
num
=
atomic_add_fetch_64
(
&
pState
->
numOfRetrievedRows
,
numOfRows
);
...
@@ -1384,11 +1378,11 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
...
@@ -1384,11 +1378,11 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
}
}
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
}
else
{
// all data has been retrieved to client
}
else
{
// all data has been retrieved to client
tscAllDataRetrievedFromDnode
(
trsupport
,
pSql
);
tscAllDataRetrievedFromDnode
(
trsupport
,
pSql
);
}
}
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
}
}
static
SSqlObj
*
tscCreateSqlObjForSubquery
(
SSqlObj
*
pSql
,
SRetrieveSupport
*
trsupport
,
SSqlObj
*
prevSqlObj
)
{
static
SSqlObj
*
tscCreateSqlObjForSubquery
(
SSqlObj
*
pSql
,
SRetrieveSupport
*
trsupport
,
SSqlObj
*
prevSqlObj
)
{
...
@@ -1479,10 +1473,15 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
...
@@ -1479,10 +1473,15 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
tscHandleSubqueryError
(
param
,
tres
,
pState
->
code
);
tscHandleSubqueryError
(
param
,
tres
,
pState
->
code
);
}
else
{
// success, proceed to retrieve data from dnode
}
else
{
// success, proceed to retrieve data from dnode
tscTrace
(
"%p sub:%p query complete, ip:%u, vgId:%d, orderOfSub:%d,retrieve data"
,
trsupport
->
pParentSqlObj
,
pSql
,
tscTrace
(
"%p sub:%p query complete, ip:%u, vgId:%d, orderOfSub:%d,
retrieve data"
,
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
->
ipAddr
[
0
].
ip
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
pVgroup
->
ipAddr
[
0
].
ip
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
if
(
pSql
->
res
.
qhandle
==
0
)
{
// qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
tscRetrieveFromDnodeCallBack
(
param
,
pSql
,
0
);
}
else
{
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
}
}
}
}
}
...
...
src/query/inc/qast.h
浏览文件 @
33dbf051
...
@@ -47,7 +47,6 @@ typedef void (*__do_filter_suppl_fn_t)(void *, void *);
...
@@ -47,7 +47,6 @@ typedef void (*__do_filter_suppl_fn_t)(void *, void *);
*
*
*/
*/
typedef
struct
tQueryInfo
{
typedef
struct
tQueryInfo
{
int32_t
offset
;
// offset value in tags
int32_t
colIndex
;
// index of column in schema
int32_t
colIndex
;
// index of column in schema
uint8_t
optr
;
// expression operator
uint8_t
optr
;
// expression operator
SSchema
sch
;
// schema of tags
SSchema
sch
;
// schema of tags
...
...
src/query/src/qast.c
浏览文件 @
33dbf051
...
@@ -544,7 +544,7 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
...
@@ -544,7 +544,7 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
&
pCond
->
end
->
v
.
i64Key
,
type
,
TSDB_ORDER_DESC
);
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)
&
pCond
->
end
->
v
.
i64Key
,
type
,
TSDB_ORDER_DESC
);
}
}
__compar_fn_t
func
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
type
);
__compar_fn_t
func
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
type
,
0
);
if
(
pCond
->
start
!=
NULL
)
{
if
(
pCond
->
start
!=
NULL
)
{
int32_t
optr
=
pCond
->
start
->
optr
;
int32_t
optr
=
pCond
->
start
->
optr
;
...
@@ -569,7 +569,7 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
...
@@ -569,7 +569,7 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
if
(
comp
)
{
if
(
comp
)
{
ret
=
func
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
&
pCond
->
start
->
v
.
i64Key
);
ret
=
func
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
&
pCond
->
start
->
v
.
i64Key
);
assert
(
ret
<
=
0
);
assert
(
ret
>
=
0
);
}
}
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_GREATER
)
{
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_GREATER
)
{
...
@@ -595,8 +595,8 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
...
@@ -595,8 +595,8 @@ static void tQueryOnSkipList(SSkipList* pSkipList, SQueryCond* pCond, int32_t ty
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
if
(
comp
)
{
if
(
comp
)
{
ret
=
func
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
&
pCond
->
start
->
v
.
i64Key
);
ret
=
func
(
SL_GET_NODE_KEY
(
pSkipList
,
pNode
),
&
pCond
->
end
->
v
.
i64Key
);
assert
(
ret
>
=
0
);
assert
(
ret
<
=
0
);
}
}
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_LESS
)
{
if
(
ret
==
0
&&
optr
==
TSDB_RELATION_LESS
)
{
...
...
src/query/src/queryExecutor.c
浏览文件 @
33dbf051
...
@@ -5432,8 +5432,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
...
@@ -5432,8 +5432,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pQueryMsg
->
orderByIdx
=
htons
(
pQueryMsg
->
orderByIdx
);
pQueryMsg
->
orderByIdx
=
htons
(
pQueryMsg
->
orderByIdx
);
pQueryMsg
->
orderType
=
htons
(
pQueryMsg
->
orderType
);
pQueryMsg
->
orderType
=
htons
(
pQueryMsg
->
orderType
);
pMsg
+=
sizeof
(
SColIndex
)
*
pQueryMsg
->
numOfGroupCols
;
}
}
pQueryMsg
->
interpoType
=
htons
(
pQueryMsg
->
interpoType
);
pQueryMsg
->
interpoType
=
htons
(
pQueryMsg
->
interpoType
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
33dbf051
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "talgo.h"
#include "talgo.h"
#include "tlog.h"
#include "tlog.h"
#include "tutil.h"
#include "tutil.h"
#include "tcompare.h"
#include "../../../query/inc/qast.h"
#include "../../../query/inc/qast.h"
#include "../../../query/inc/qextbuffer.h"
#include "../../../query/inc/qextbuffer.h"
...
@@ -1170,7 +1171,7 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) {
...
@@ -1170,7 +1171,7 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) {
size_t
size
=
taosArrayGetSize
(
pTableList
);
size_t
size
=
taosArrayGetSize
(
pTableList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
STable
*
pTable
=
taosArrayGetP
(
pTableList
,
i
);
STable
*
pTable
=
taosArrayGetP
(
pTableList
,
i
);
taosArrayPush
(
pRes
,
&
pTable
->
tableId
);
taosArrayPush
(
pRes
,
&
pTable
);
}
}
}
}
...
@@ -1184,24 +1185,20 @@ static void destroyHelper(void* param) {
...
@@ -1184,24 +1185,20 @@ static void destroyHelper(void* param) {
free
(
param
);
free
(
param
);
}
}
static
void
getTagColumnInfo
(
SExprTreeSupporter
*
pSupporter
,
SSchema
*
pSchema
,
int32_t
*
index
,
int32_t
*
offset
)
{
static
void
getTagColumnInfo
(
SExprTreeSupporter
*
pSupporter
,
SSchema
*
pSchema
,
int32_t
*
index
)
{
*
index
=
0
;
*
index
=
0
;
*
offset
=
0
;
// filter on table name(TBNAME)
// filter on table name(TBNAME)
if
(
strcasecmp
(
pSchema
->
name
,
TSQL_TBNAME_L
)
==
0
)
{
if
(
strcasecmp
(
pSchema
->
name
,
TSQL_TBNAME_L
)
==
0
)
{
*
index
=
TSDB_TBNAME_COLUMN_INDEX
;
*
index
=
TSDB_TBNAME_COLUMN_INDEX
;
*
offset
=
TSDB_TBNAME_COLUMN_INDEX
;
return
;
return
;
}
}
while
((
*
index
)
<
pSupporter
->
numOfTags
)
{
while
((
*
index
)
<
pSupporter
->
numOfTags
)
{
if
(
pSupporter
->
pTagSchema
[
*
index
].
bytes
==
pSchema
->
bytes
&&
if
(
pSupporter
->
pTagSchema
[
*
index
].
bytes
==
pSchema
->
bytes
&&
pSupporter
->
pTagSchema
[
*
index
].
type
==
pSchema
->
type
&&
pSupporter
->
pTagSchema
[
*
index
].
type
==
pSchema
->
type
&&
pSupporter
->
pTagSchema
[
*
index
].
colId
==
pSchema
->
colId
)
{
pSupporter
->
pTagSchema
[
*
index
].
colId
==
pSchema
->
colId
)
{
break
;
break
;
}
else
{
(
*
offset
)
+=
pSupporter
->
pTagSchema
[(
*
index
)
++
].
bytes
;
}
}
}
}
}
}
...
@@ -1222,15 +1219,14 @@ void filterPrepare(void* expr, void* param) {
...
@@ -1222,15 +1219,14 @@ void filterPrepare(void* expr, void* param) {
tVariant
*
pCond
=
pExpr
->
_node
.
pRight
->
pVal
;
tVariant
*
pCond
=
pExpr
->
_node
.
pRight
->
pVal
;
SSchema
*
pSchema
=
pExpr
->
_node
.
pLeft
->
pSchema
;
SSchema
*
pSchema
=
pExpr
->
_node
.
pLeft
->
pSchema
;
getTagColumnInfo
(
pSupporter
,
pSchema
,
&
i
,
&
offset
);
getTagColumnInfo
(
pSupporter
,
pSchema
,
&
i
);
assert
((
i
>=
0
&&
i
<
TSDB_MAX_TAGS
)
||
(
i
==
TSDB_TBNAME_COLUMN_INDEX
));
assert
((
i
>=
0
&&
i
<
TSDB_MAX_TAGS
)
||
(
i
==
TSDB_TBNAME_COLUMN_INDEX
));
assert
((
offset
>=
0
&&
offset
<
TSDB_MAX_TAGS_LEN
)
||
(
offset
==
TSDB_TBNAME_COLUMN_INDEX
));
assert
((
offset
>=
0
&&
offset
<
TSDB_MAX_TAGS_LEN
)
||
(
offset
==
TSDB_TBNAME_COLUMN_INDEX
));
pInfo
->
sch
=
*
pSchema
;
pInfo
->
sch
=
*
pSchema
;
pInfo
->
colIndex
=
i
;
pInfo
->
colIndex
=
i
;
pInfo
->
optr
=
pExpr
->
_node
.
optr
;
pInfo
->
optr
=
pExpr
->
_node
.
optr
;
pInfo
->
offset
=
offset
;
pInfo
->
compare
=
getComparFunc
(
pSchema
->
type
,
pCond
->
nType
,
pInfo
->
optr
);
// pInfo->compare = getFilterComparator(pSchema->type, pCond->nType, pInfo->optr);
tVariantAssign
(
&
pInfo
->
q
,
pCond
);
tVariantAssign
(
&
pInfo
->
q
,
pCond
);
tVariantTypeSetType
(
&
pInfo
->
q
,
pInfo
->
sch
.
type
);
tVariantTypeSetType
(
&
pInfo
->
q
,
pInfo
->
sch
.
type
);
...
@@ -1329,6 +1325,8 @@ void createTableGroupImpl(SArray* pGroups, STable** pTables, size_t numOfTables,
...
@@ -1329,6 +1325,8 @@ void createTableGroupImpl(SArray* pGroups, STable** pTables, size_t numOfTables,
taosArrayPush
(
g
,
&
p1
);
taosArrayPush
(
g
,
&
p1
);
}
}
}
}
taosArrayPush
(
pGroups
,
&
g
);
}
}
SArray
*
createTableGroup
(
SArray
*
pTableList
,
STSchema
*
pTagSchema
,
SColIndex
*
pCols
,
int32_t
numOfOrderCols
)
{
SArray
*
createTableGroup
(
SArray
*
pTableList
,
STSchema
*
pTagSchema
,
SColIndex
*
pCols
,
int32_t
numOfOrderCols
)
{
...
@@ -1380,7 +1378,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
...
@@ -1380,7 +1378,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
bool
tSkipListNodeFilterCallback
(
const
void
*
pNode
,
void
*
param
)
{
bool
tSkipListNodeFilterCallback
(
const
void
*
pNode
,
void
*
param
)
{
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
STable
*
pTable
=
(
STable
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
pNode
));
STable
*
pTable
=
*
(
STable
*
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
pNode
));
char
*
val
=
dataRowTuple
(
pTable
->
tagVal
);
// todo not only the first column
char
*
val
=
dataRowTuple
(
pTable
->
tagVal
);
// todo not only the first column
int8_t
type
=
pInfo
->
sch
.
type
;
int8_t
type
=
pInfo
->
sch
.
type
;
...
@@ -1437,7 +1435,8 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr)
...
@@ -1437,7 +1435,8 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr)
SExprTreeSupporter
s
=
{.
pTagSchema
=
schema
,
.
numOfTags
=
schemaNCols
(
pSTable
->
tagSchema
)};
SExprTreeSupporter
s
=
{.
pTagSchema
=
schema
,
.
numOfTags
=
schemaNCols
(
pSTable
->
tagSchema
)};
SBinaryFilterSupp
supp
=
{
SBinaryFilterSupp
supp
=
{
.
fp
=
(
__result_filter_fn_t
)
tSkipListNodeFilterCallback
,
.
setupInfoFn
=
filterPrepare
,
.
pExtInfo
=
&
s
};
.
fp
=
(
__result_filter_fn_t
)
tSkipListNodeFilterCallback
,
.
setupInfoFn
=
filterPrepare
,
.
pExtInfo
=
&
s
,
};
SArray
*
pTableList
=
taosArrayInit
(
8
,
POINTER_BYTES
);
SArray
*
pTableList
=
taosArrayInit
(
8
,
POINTER_BYTES
);
...
...
src/util/inc/tcompare.h
浏览文件 @
33dbf051
...
@@ -34,31 +34,13 @@ typedef struct SPatternCompareInfo {
...
@@ -34,31 +34,13 @@ typedef struct SPatternCompareInfo {
char
matchOne
;
// symbol for match one wildcard, default: '_'
char
matchOne
;
// symbol for match one wildcard, default: '_'
}
SPatternCompareInfo
;
}
SPatternCompareInfo
;
int32_t
compareInt32Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt64Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt16Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareInt8Val
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareIntDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareDoubleIntVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareStrVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareWStrVal
(
const
void
*
pLeft
,
const
void
*
pRight
);
int
patternMatch
(
const
char
*
zPattern
,
const
char
*
zString
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int
patternMatch
(
const
char
*
zPattern
,
const
char
*
zString
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int
WCSPatternMatch
(
const
wchar_t
*
zPattern
,
const
wchar_t
*
zString
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
int
WCSPatternMatch
(
const
wchar_t
*
zPattern
,
const
wchar_t
*
zString
,
size_t
size
,
const
SPatternCompareInfo
*
pInfo
);
__compar_fn_t
getKeyComparFunc
(
int32_t
keyType
);
__compar_fn_t
getKeyComparFunc
(
int32_t
keyType
);
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
filterDataType
);
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
filterDataType
,
int32_t
optr
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/util/src/tcompare.c
浏览文件 @
33dbf051
...
@@ -40,25 +40,23 @@ int32_t compareInt8Val(const void *pLeft, const void *pRight) {
...
@@ -40,25 +40,23 @@ int32_t compareInt8Val(const void *pLeft, const void *pRight) {
}
}
int32_t
compareIntDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareIntDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
// int64_t lhs = ((SSkipListKey *)pLeft)->i64Key;
int64_t
lhs
=
GET_INT64_VAL
(
pLeft
);
// double rhs = ((SSkipListKey *)pRight)->dKey;
double
rhs
=
GET_DOUBLE_VAL
(
pRight
);
// if (fabs(lhs - rhs) < FLT_EPSILON) {
if
(
fabs
(
lhs
-
rhs
)
<
FLT_EPSILON
)
{
// return 0;
return
0
;
// } else {
}
else
{
// return (lhs > rhs) ? 1 : -1;
return
(
lhs
>
rhs
)
?
1
:
-
1
;
// }
}
return
0
;
}
}
int32_t
compareDoubleIntVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareDoubleIntVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
// double lhs = ((SSkipListKey *)pLeft)->dKey;
double
lhs
=
GET_DOUBLE_VAL
(
pLeft
);
// int64_t rhs = ((SSkipListKey *)pRight)->i64Key;
int64_t
rhs
=
GET_INT64_VAL
(
pRight
);
// if (fabs(lhs - rhs) < FLT_EPSILON) {
if
(
fabs
(
lhs
-
rhs
)
<
FLT_EPSILON
)
{
// return 0;
return
0
;
// } else {
}
else
{
// return (lhs > rhs) ? 1 : -1;
return
(
lhs
>
rhs
)
?
1
:
-
1
;
// }
}
return
0
;
}
}
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
...
@@ -241,7 +239,8 @@ static UNUSED_FUNC int32_t compareWStrPatternComp(const void* pLeft, const void*
...
@@ -241,7 +239,8 @@ static UNUSED_FUNC int32_t compareWStrPatternComp(const void* pLeft, const void*
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
return
(
ret
==
TSDB_PATTERN_MATCH
)
?
0
:
1
;
}
}
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
filterDataType
)
{
// todo promote the type definition before the comparsion
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
filterDataType
,
int32_t
optr
)
{
__compar_fn_t
comparFn
=
NULL
;
__compar_fn_t
comparFn
=
NULL
;
switch
(
type
)
{
switch
(
type
)
{
...
@@ -250,10 +249,15 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType) {
...
@@ -250,10 +249,15 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType) {
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
// assert(type == filterDataType);
if
(
filterDataType
==
TSDB_DATA_TYPE_BIGINT
||
filterDataType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
filterDataType
==
TSDB_DATA_TYPE_BIGINT
||
filterDataType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
comparFn
=
compareInt64Val
;
comparFn
=
compareInt64Val
;
break
;
}
else
if
(
filterDataType
>=
TSDB_DATA_TYPE_FLOAT
&&
filterDataType
<=
TSDB_DATA_TYPE_DOUBLE
)
{
comparFn
=
compareIntDoubleVal
;
}
}
break
;
}
}
case
TSDB_DATA_TYPE_BOOL
:
{
case
TSDB_DATA_TYPE_BOOL
:
{
if
(
filterDataType
>=
TSDB_DATA_TYPE_BOOL
&&
filterDataType
<=
TSDB_DATA_TYPE_BIGINT
)
{
if
(
filterDataType
>=
TSDB_DATA_TYPE_BOOL
&&
filterDataType
<=
TSDB_DATA_TYPE_BIGINT
)
{
...
@@ -265,22 +269,37 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType) {
...
@@ -265,22 +269,37 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType) {
}
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDB_DATA_TYPE_DOUBLE
:
{
// if (filterDataType >= TSDB_DATA_TYPE_BOOL && filterDataType <= TSDB_DATA_TYPE_BIGINT) {
if
(
filterDataType
>=
TSDB_DATA_TYPE_BOOL
&&
filterDataType
<=
TSDB_DATA_TYPE_BIGINT
)
{
// comparFn = compareDoubleIntVal;
comparFn
=
compareDoubleIntVal
;
// } else if (filterDataType >= TSDB_DATA_TYPE_FLOAT && filterDataType <= TSDB_DATA_TYPE_DOUBLE) {
}
else
if
(
filterDataType
>=
TSDB_DATA_TYPE_FLOAT
&&
filterDataType
<=
TSDB_DATA_TYPE_DOUBLE
)
{
// comparFn = compareDoubleVal;
// }
if
(
filterDataType
==
TSDB_DATA_TYPE_DOUBLE
)
{
comparFn
=
compareDoubleVal
;
comparFn
=
compareDoubleVal
;
}
}
break
;
break
;
}
}
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
{
comparFn
=
compareStrVal
;
assert
(
filterDataType
==
TSDB_DATA_TYPE_BINARY
);
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareStrPatternComp
;
}
else
{
/* normal relational comparFn */
comparFn
=
compareStrVal
;
}
break
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
}
comparFn
=
compareWStrVal
;
case
TSDB_DATA_TYPE_NCHAR
:
{
assert
(
filterDataType
==
TSDB_DATA_TYPE_NCHAR
);
if
(
optr
==
TSDB_RELATION_LIKE
)
{
comparFn
=
compareWStrPatternComp
;
}
else
{
comparFn
=
compareWStrVal
;
}
break
;
break
;
}
default:
default:
comparFn
=
compareInt32Val
;
comparFn
=
compareInt32Val
;
break
;
break
;
...
...
src/util/src/tskiplist.c
浏览文件 @
33dbf051
...
@@ -308,7 +308,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey, int16_t keyType) {
...
@@ -308,7 +308,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey, int16_t keyType) {
pSkipList
->
state
.
queryCount
++
;
pSkipList
->
state
.
queryCount
++
;
#endif
#endif
__compar_fn_t
filterComparFn
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
keyType
);
__compar_fn_t
filterComparFn
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
keyType
,
0
);
int32_t
ret
=
-
1
;
int32_t
ret
=
-
1
;
for
(
int32_t
i
=
sLevel
;
i
>=
0
;
--
i
)
{
for
(
int32_t
i
=
sLevel
;
i
>=
0
;
--
i
)
{
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
i
);
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
i
);
...
@@ -372,7 +372,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char*
...
@@ -372,7 +372,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char*
SSkipListNode
*
forward
[
MAX_SKIP_LIST_LEVEL
]
=
{
0
};
SSkipListNode
*
forward
[
MAX_SKIP_LIST_LEVEL
]
=
{
0
};
int32_t
ret
=
-
1
;
int32_t
ret
=
-
1
;
__compar_fn_t
filterComparFn
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
type
);
__compar_fn_t
filterComparFn
=
getComparFunc
(
pSkipList
->
keyInfo
.
type
,
type
,
0
);
SSkipListNode
*
pNode
=
pSkipList
->
pHead
;
SSkipListNode
*
pNode
=
pSkipList
->
pHead
;
for
(
int32_t
i
=
pSkipList
->
level
-
1
;
i
>=
0
;
--
i
)
{
for
(
int32_t
i
=
pSkipList
->
level
-
1
;
i
>=
0
;
--
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录