Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a5ce7d6
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6a5ce7d6
编写于
2月 02, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: opt tag filter perf.
上级
49dedc3c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
68 deletion
+110
-68
include/common/tcommon.h
include/common/tcommon.h
+6
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+8
-7
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+96
-61
未找到文件。
include/common/tcommon.h
浏览文件 @
6a5ce7d6
...
@@ -367,6 +367,12 @@ typedef struct SSortExecInfo {
...
@@ -367,6 +367,12 @@ typedef struct SSortExecInfo {
int32_t
readBytes
;
// read io bytes
int32_t
readBytes
;
// read io bytes
}
SSortExecInfo
;
}
SSortExecInfo
;
typedef
struct
SFilterTableInfo
{
char
*
name
;
uint64_t
uid
;
void
*
pTagVal
;
}
SFilterTableInfo
;
// stream special block column
// stream special block column
#define START_TS_COLUMN_INDEX 0
#define START_TS_COLUMN_INDEX 0
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
6a5ce7d6
...
@@ -1346,13 +1346,14 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, voi
...
@@ -1346,13 +1346,14 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, voi
return
ret
;
return
ret
;
}
}
int32_t
metaGetTableTagsByUids
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
uidList
,
SHashObj
*
tags
)
{
int32_t
metaGetTableTagsByUids
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
uidList
,
SHashObj
*
tags
)
{
const
int32_t
LIMIT
=
128
;
const
int32_t
LIMIT
=
128
;
int32_t
isLock
=
false
;
int32_t
isLock
=
false
;
int32_t
sz
=
uidList
?
taosArrayGetSize
(
uidList
)
:
0
;
int32_t
sz
=
uidList
?
taosArrayGetSize
(
uidList
)
:
0
;
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
tb_uid_t
*
id
=
taosArrayGet
(
uidList
,
i
);
SFilterTableInfo
*
p
=
taosArrayGet
(
uidList
,
i
);
if
(
i
%
LIMIT
==
0
)
{
if
(
i
%
LIMIT
==
0
)
{
if
(
isLock
)
metaULock
(
pMeta
);
if
(
isLock
)
metaULock
(
pMeta
);
...
@@ -1361,20 +1362,20 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHas
...
@@ -1361,20 +1362,20 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHas
isLock
=
true
;
isLock
=
true
;
}
}
if
(
taosHashGet
(
tags
,
id
,
sizeof
(
tb_uid_t
))
==
NULL
)
{
// if (taosHashGet(tags, &p->u
id, sizeof(tb_uid_t)) == NULL) {
void
*
val
=
NULL
;
void
*
val
=
NULL
;
int32_t
len
=
0
;
int32_t
len
=
0
;
if
(
metaGetTableTagByUid
(
pMeta
,
suid
,
*
id
,
&
val
,
&
len
,
false
)
==
0
)
{
if
(
metaGetTableTagByUid
(
pMeta
,
suid
,
p
->
uid
,
&
val
,
&
len
,
false
)
==
0
)
{
taosHashPut
(
tags
,
id
,
sizeof
(
tb_uid_t
),
val
,
len
);
p
->
pTagVal
=
taosMemoryMalloc
(
len
);
memcpy
(
p
->
pTagVal
,
val
,
len
);
tdbFree
(
val
);
tdbFree
(
val
);
}
else
{
}
else
{
metaError
(
"vgId:%d, failed to table tags, suid: %"
PRId64
", uid: %"
PRId64
""
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
metaError
(
"vgId:%d, failed to table tags, suid: %"
PRId64
", uid: %"
PRId64
""
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
*
id
);
p
->
u
id
);
}
}
}
}
}
//
}
if
(
isLock
)
metaULock
(
pMeta
);
if
(
isLock
)
metaULock
(
pMeta
);
return
0
;
return
0
;
}
}
...
...
source/libs/executor/src/executil.c
浏览文件 @
6a5ce7d6
...
@@ -44,8 +44,8 @@ typedef struct tagFilterAssist {
...
@@ -44,8 +44,8 @@ typedef struct tagFilterAssist {
}
tagFilterAssist
;
}
tagFilterAssist
;
static
int32_t
removeInvalidUid
(
SArray
*
uids
,
SHashObj
*
tags
);
static
int32_t
removeInvalidUid
(
SArray
*
uids
,
SHashObj
*
tags
);
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
list
,
SNode
*
pTagCond
,
SHashObj
*
tags
);
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
pRes
,
SNode
*
pTagCond
,
SHashObj
*
tags
);
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
pExistedUidList
,
SNode
*
pTagCond
);
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
SArray
*
pExistedUidList
,
SNode
*
pTagCond
);
static
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
static
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
);
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
);
...
@@ -416,23 +416,35 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -416,23 +416,35 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
nodesRewriteExprPostOrder
(
&
pTagCond
,
getColumn
,
(
void
*
)
&
ctx
);
nodesRewriteExprPostOrder
(
&
pTagCond
,
getColumn
,
(
void
*
)
&
ctx
);
pResBlock
=
createDataBlock
();
SDataType
type
=
{.
type
=
TSDB_DATA_TYPE_BOOL
,
.
bytes
=
sizeof
(
bool
)};
if
(
pResBlock
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
ctx
.
cInfoList
);
++
i
)
{
SColumnInfoData
colInfo
=
{
0
};
colInfo
.
info
=
*
(
SColumnInfo
*
)
taosArrayGet
(
ctx
.
cInfoList
,
i
);
blockDataAppendColInfo
(
pResBlock
,
&
colInfo
);
}
// int64_t stt = taosGetTimestampUs();
// int64_t stt = taosGetTimestampUs();
tags
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
// tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
SArray
*
pRes
=
taosArrayInit
(
10
,
sizeof
(
SFilterTableInfo
));
int32_t
filter
=
optimizeTbnameInCond
(
metaHandle
,
suid
,
pRes
,
pTagCond
,
tags
);
if
(
filter
==
0
)
{
// tbname in filter is activated, do nothing and return
int32_t
numOfRows
=
taosArrayGetSize
(
pRes
);
code
=
createResultData
(
&
type
,
numOfRows
,
&
output
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
qError
(
"failed to create result, reason:%s"
,
tstrerror
(
code
));
goto
end
;
}
bool
*
b
=
(
bool
*
)
output
.
columnData
->
pData
;
taosArrayEnsureCap
(
uidList
,
numOfRows
);
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
b
[
i
]
=
true
;
SFilterTableInfo
*
pInfo
=
taosArrayGet
(
pRes
,
i
);
taosArrayPush
(
uidList
,
&
pInfo
->
uid
);
}
int32_t
filter
=
optimizeTbnameInCond
(
metaHandle
,
suid
,
uidList
,
pTagCond
,
tags
);
terrno
=
0
;
if
(
filter
==
-
1
)
{
goto
end
;
}
else
{
// if (filter == -1) {
// here we retrieve all tags from the vnode table-meta store
// here we retrieve all tags from the vnode table-meta store
code
=
metaGetTableTags
(
metaHandle
,
suid
,
uidList
,
tags
);
code
=
metaGetTableTags
(
metaHandle
,
suid
,
uidList
,
tags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -443,10 +455,22 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -443,10 +455,22 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
}
}
if
(
suid
!=
0
)
{
if
(
suid
!=
0
)
{
removeInvalidUid
(
uidList
,
tags
);
// removeInvalidUid(uidList, tags);
}
pResBlock
=
createDataBlock
();
if
(
pResBlock
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
ctx
.
cInfoList
);
++
i
)
{
SColumnInfoData
colInfo
=
{
0
};
colInfo
.
info
=
*
(
SColumnInfo
*
)
taosArrayGet
(
ctx
.
cInfoList
,
i
);
blockDataAppendColInfo
(
pResBlock
,
&
colInfo
);
}
}
int32_t
size
=
taosArrayGetSize
(
uidList
);
int32_t
size
=
taosArrayGetSize
(
pRes
);
if
(
size
==
0
)
{
if
(
size
==
0
)
{
goto
end
;
goto
end
;
}
}
...
@@ -457,27 +481,32 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -457,27 +481,32 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
goto
end
;
goto
end
;
}
}
int32_t
numOfCols
=
taosArrayGetSize
(
pResBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
int64_t
*
uid
=
taosArrayGet
(
uidList
,
i
);
SFilterTableInfo
*
p1
=
taosArrayGet
(
pRes
,
i
);
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
pResBlock
->
pDataBlock
);
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
j
++
)
{
SColumnInfoData
*
pColInfo
=
(
SColumnInfoData
*
)
taosArrayGet
(
pResBlock
->
pDataBlock
,
j
);
SColumnInfoData
*
pColInfo
=
(
SColumnInfoData
*
)
taosArrayGet
(
pResBlock
->
pDataBlock
,
j
);
if
(
pColInfo
->
info
.
colId
==
-
1
)
{
// tbname
if
(
pColInfo
->
info
.
colId
==
-
1
)
{
// tbname
char
str
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
str
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
metaGetTableNameByUid
(
metaHandle
,
*
uid
,
str
);
STR_TO_VARSTR
(
str
,
p1
->
name
);
// metaGetTableNameByUid(metaHandle, *uid, str);
colDataAppend
(
pColInfo
,
i
,
str
,
false
);
colDataAppend
(
pColInfo
,
i
,
str
,
false
);
#if TAG_FILTER_DEBUG
#if TAG_FILTER_DEBUG
qDebug
(
"tagfilter uid:%ld, tbname:%s"
,
*
uid
,
str
+
2
);
qDebug
(
"tagfilter uid:%ld, tbname:%s"
,
*
uid
,
str
+
2
);
#endif
#endif
}
else
{
}
else
{
void
*
pTagsVal
=
taosHashGet
(
tags
,
uid
,
sizeof
(
uint64_t
));
//
void* pTagsVal = taosHashGet(tags, uid, sizeof(uint64_t));
if
(
pTagsVal
==
NULL
)
{
//
if (pTagsVal == NULL) {
continue
;
//
continue;
}
//
}
STagVal
tagVal
=
{
0
};
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pColInfo
->
info
.
colId
;
tagVal
.
cid
=
pColInfo
->
info
.
colId
;
const
char
*
p
=
metaGetTableTagVal
(
p
Tags
Val
,
pColInfo
->
info
.
type
,
&
tagVal
);
const
char
*
p
=
metaGetTableTagVal
(
p
1
->
pTag
Val
,
pColInfo
->
info
.
type
,
&
tagVal
);
if
(
p
==
NULL
||
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
((
STag
*
)
p
)
->
nTag
==
0
))
{
if
(
p
==
NULL
||
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
((
STag
*
)
p
)
->
nTag
==
0
))
{
colDataAppend
(
pColInfo
,
i
,
p
,
true
);
colDataAppend
(
pColInfo
,
i
,
p
,
true
);
...
@@ -485,14 +514,12 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -485,14 +514,12 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
colDataAppend
(
pColInfo
,
i
,
p
,
false
);
colDataAppend
(
pColInfo
,
i
,
p
,
false
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pColInfo
->
info
.
type
))
{
}
else
if
(
IS_VAR_DATA_TYPE
(
pColInfo
->
info
.
type
))
{
char
*
tmp
=
alloca
(
tagVal
.
nData
+
VARSTR_HEADER_SIZE
+
1
);
char
*
tmp
=
alloca
(
tagVal
.
nData
+
VARSTR_HEADER_SIZE
+
1
);
// char* tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1);
varDataSetLen
(
tmp
,
tagVal
.
nData
);
varDataSetLen
(
tmp
,
tagVal
.
nData
);
memcpy
(
tmp
+
VARSTR_HEADER_SIZE
,
tagVal
.
pData
,
tagVal
.
nData
);
memcpy
(
tmp
+
VARSTR_HEADER_SIZE
,
tagVal
.
pData
,
tagVal
.
nData
);
colDataAppend
(
pColInfo
,
i
,
tmp
,
false
);
colDataAppend
(
pColInfo
,
i
,
tmp
,
false
);
#if TAG_FILTER_DEBUG
#if TAG_FILTER_DEBUG
qDebug
(
"tagfilter varch:%s"
,
tmp
+
2
);
qDebug
(
"tagfilter varch:%s"
,
tmp
+
2
);
#endif
#endif
// taosMemoryFree(tmp);
}
else
{
}
else
{
colDataAppend
(
pColInfo
,
i
,
(
const
char
*
)
&
tagVal
.
i64
,
false
);
colDataAppend
(
pColInfo
,
i
,
(
const
char
*
)
&
tagVal
.
i64
,
false
);
#if TAG_FILTER_DEBUG
#if TAG_FILTER_DEBUG
...
@@ -515,14 +542,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
...
@@ -515,14 +542,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
pBlockList
=
taosArrayInit
(
2
,
POINTER_BYTES
);
pBlockList
=
taosArrayInit
(
2
,
POINTER_BYTES
);
taosArrayPush
(
pBlockList
,
&
pResBlock
);
taosArrayPush
(
pBlockList
,
&
pResBlock
);
SDataType
type
=
{.
type
=
TSDB_DATA_TYPE_BOOL
,
.
bytes
=
sizeof
(
bool
)};
code
=
createResultData
(
&
type
,
size
,
&
output
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
qError
(
"failed to create result, reason:%s"
,
tstrerror
(
code
));
goto
end
;
}
code
=
scalarCalculate
(
pTagCond
,
pBlockList
,
&
output
);
code
=
scalarCalculate
(
pTagCond
,
pBlockList
,
&
output
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to calculate scalar, reason:%s"
,
tstrerror
(
code
));
qError
(
"failed to calculate scalar, reason:%s"
,
tstrerror
(
code
));
...
@@ -847,13 +866,26 @@ static int tableUidCompare(const void* a, const void* b) {
...
@@ -847,13 +866,26 @@ static int tableUidCompare(const void* a, const void* b) {
return
u1
<
u2
?
-
1
:
1
;
return
u1
<
u2
?
-
1
:
1
;
}
}
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
list
,
SNode
*
cond
,
SHashObj
*
tags
)
{
static
int32_t
filterTableInfoCompare
(
const
void
*
a
,
const
void
*
b
)
{
SFilterTableInfo
*
p1
=
(
SFilterTableInfo
*
)
a
;
SFilterTableInfo
*
p2
=
(
SFilterTableInfo
*
)
b
;
if
(
p1
->
uid
==
p2
->
uid
)
{
return
0
;
}
return
p1
->
uid
<
p2
->
uid
?
-
1
:
1
;
}
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
pRes
,
SNode
*
cond
,
SHashObj
*
tags
)
{
int32_t
ret
=
-
1
;
int32_t
ret
=
-
1
;
if
(
nodeType
(
cond
)
==
QUERY_NODE_OPERATOR
)
{
if
(
nodeType
(
cond
)
==
QUERY_NODE_OPERATOR
)
{
ret
=
optimizeTbnameInCondImpl
(
metaHandle
,
suid
,
list
,
cond
);
ret
=
optimizeTbnameInCondImpl
(
metaHandle
,
pRes
,
cond
);
if
(
ret
!=
-
1
)
{
if
(
ret
==
0
)
{
metaGetTableTagsByUids
(
metaHandle
,
suid
,
list
,
tags
);
// metaGetTableTagsByUids(metaHandle, suid, pRes, tags);
removeInvalidUid
(
list
,
tags
);
// removeInvalidUid(pRes, tags);
}
else
{
// ret == -1
// do nothing
}
}
}
}
...
@@ -873,19 +905,19 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list
...
@@ -873,19 +905,19 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list
SListCell
*
cell
=
pList
->
pHead
;
SListCell
*
cell
=
pList
->
pHead
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
cell
==
NULL
)
break
;
if
(
cell
==
NULL
)
break
;
if
(
optimizeTbnameInCondImpl
(
metaHandle
,
suid
,
list
,
cell
->
pNode
)
==
0
)
{
if
(
optimizeTbnameInCondImpl
(
metaHandle
,
pRes
,
cell
->
pNode
)
==
0
)
{
hasTbnameCond
=
true
;
hasTbnameCond
=
true
;
break
;
break
;
}
}
cell
=
cell
->
pNext
;
cell
=
cell
->
pNext
;
}
}
taosArraySort
(
list
,
tableUid
Compare
);
taosArraySort
(
pRes
,
filterTableInfo
Compare
);
taosArrayRemoveDuplicate
(
list
,
tableUid
Compare
,
NULL
);
taosArrayRemoveDuplicate
(
pRes
,
filterTableInfo
Compare
,
NULL
);
if
(
hasTbnameCond
)
{
if
(
hasTbnameCond
)
{
ret
=
metaGetTableTagsByUids
(
metaHandle
,
suid
,
list
,
tags
);
ret
=
metaGetTableTagsByUids
(
metaHandle
,
suid
,
pRes
,
tags
);
removeInvalidUid
(
list
,
tags
);
removeInvalidUid
(
pRes
,
tags
);
}
}
return
ret
;
return
ret
;
...
@@ -900,12 +932,12 @@ static int32_t removeInvalidUid(SArray* uids, SHashObj* tags) {
...
@@ -900,12 +932,12 @@ static int32_t removeInvalidUid(SArray* uids, SHashObj* tags) {
return
0
;
return
0
;
}
}
SArray
*
validUid
=
taosArrayInit
(
size
,
sizeof
(
int64_t
));
SArray
*
validUid
=
taosArrayInit
(
size
,
sizeof
(
SFilterTableInfo
));
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
int64_t
*
uid
=
taosArrayGet
(
uids
,
i
);
SFilterTableInfo
*
p
=
taosArrayGet
(
uids
,
i
);
if
(
taosHashGet
(
tags
,
uid
,
sizeof
(
int64_t
))
!=
NULL
)
{
if
(
taosHashGet
(
tags
,
&
p
->
uid
,
sizeof
(
int64_t
))
!=
NULL
)
{
taosArrayPush
(
validUid
,
uid
);
taosArrayPush
(
validUid
,
p
);
}
}
}
}
...
@@ -915,7 +947,7 @@ static int32_t removeInvalidUid(SArray* uids, SHashObj* tags) {
...
@@ -915,7 +947,7 @@ static int32_t removeInvalidUid(SArray* uids, SHashObj* tags) {
}
}
// only return uid that does not contained in pExistedUidList
// only return uid that does not contained in pExistedUidList
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
pExistedUidList
,
SNode
*
pTagCond
)
{
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
SArray
*
pExistedUidList
,
SNode
*
pTagCond
)
{
if
(
nodeType
(
pTagCond
)
!=
QUERY_NODE_OPERATOR
)
{
if
(
nodeType
(
pTagCond
)
!=
QUERY_NODE_OPERATOR
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -938,12 +970,13 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
...
@@ -938,12 +970,13 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
SArray
*
pTbList
=
getTableNameList
(
pList
);
SArray
*
pTbList
=
getTableNameList
(
pList
);
int32_t
numOfTables
=
taosArrayGetSize
(
pTbList
);
int32_t
numOfTables
=
taosArrayGetSize
(
pTbList
);
SHashObj
*
uHash
=
NULL
;
SHashObj
*
uHash
=
NULL
;
size_t
numOfExisted
=
taosArrayGetSize
(
pExistedUidList
);
// len > 0 means there already have uids
size_t
numOfExisted
=
taosArrayGetSize
(
pExistedUidList
);
// len > 0 means there already have uids
if
(
numOfExisted
>
0
)
{
if
(
numOfExisted
>
0
)
{
uHash
=
taosHashInit
(
numOfExisted
/
0
.
7
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
uHash
=
taosHashInit
(
numOfExisted
/
0
.
7
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
for
(
int
i
=
0
;
i
<
numOfExisted
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numOfExisted
;
i
++
)
{
int64_t
*
uid
=
taosArrayGet
(
pExistedUidList
,
i
);
SFilterTableInfo
*
pTInfo
=
taosArrayGet
(
pExistedUidList
,
i
);
taosHashPut
(
uHash
,
uid
,
sizeof
(
int64_t
),
&
i
,
sizeof
(
i
));
taosHashPut
(
uHash
,
&
pTInfo
->
uid
,
sizeof
(
u
int64_t
),
&
i
,
sizeof
(
i
));
}
}
}
}
...
@@ -955,7 +988,8 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
...
@@ -955,7 +988,8 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
ETableType
tbType
=
TSDB_TABLE_MAX
;
ETableType
tbType
=
TSDB_TABLE_MAX
;
if
(
metaGetTableTypeByName
(
metaHandle
,
name
,
&
tbType
)
==
0
&&
tbType
==
TSDB_CHILD_TABLE
)
{
if
(
metaGetTableTypeByName
(
metaHandle
,
name
,
&
tbType
)
==
0
&&
tbType
==
TSDB_CHILD_TABLE
)
{
if
(
NULL
==
uHash
||
taosHashGet
(
uHash
,
&
uid
,
sizeof
(
uid
))
==
NULL
)
{
if
(
NULL
==
uHash
||
taosHashGet
(
uHash
,
&
uid
,
sizeof
(
uid
))
==
NULL
)
{
taosArrayPush
(
pExistedUidList
,
&
uid
);
SFilterTableInfo
s
=
{.
uid
=
uid
,
.
name
=
name
,
.
pTagVal
=
NULL
};
taosArrayPush
(
pExistedUidList
,
&
s
);
}
}
}
else
{
}
else
{
taosArrayDestroy
(
pTbList
);
taosArrayDestroy
(
pTbList
);
...
@@ -992,39 +1026,40 @@ static void genTagFilterDigest(const SNode* pTagCond, T_MD5_CTX* pContext) {
...
@@ -992,39 +1026,40 @@ static void genTagFilterDigest(const SNode* pTagCond, T_MD5_CTX* pContext) {
taosMemoryFree
(
payload
);
taosMemoryFree
(
payload
);
}
}
static
int32_t
doFilterByTagCond
(
STableListInfo
*
pListInfo
,
SArray
*
r
es
,
SNode
*
pTagCond
,
void
*
metaHandle
)
{
static
int32_t
doFilterByTagCond
(
STableListInfo
*
pListInfo
,
SArray
*
pR
es
,
SNode
*
pTagCond
,
void
*
metaHandle
)
{
if
(
pTagCond
==
NULL
)
{
if
(
pTagCond
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
terrno
=
TDB_CODE_SUCCESS
;
terrno
=
TDB_CODE_SUCCESS
;
SColumnInfoData
*
pColInfoData
=
getColInfoResult
(
metaHandle
,
pListInfo
->
suid
,
r
es
,
pTagCond
);
SColumnInfoData
*
pColInfoData
=
getColInfoResult
(
metaHandle
,
pListInfo
->
suid
,
pR
es
,
pTagCond
);
if
(
terrno
!=
TDB_CODE_SUCCESS
)
{
if
(
terrno
!=
TDB_CODE_SUCCESS
)
{
colDataDestroy
(
pColInfoData
);
colDataDestroy
(
pColInfoData
);
taosMemoryFreeClear
(
pColInfoData
);
taosMemoryFreeClear
(
pColInfoData
);
taosArrayDestroy
(
r
es
);
taosArrayDestroy
(
pR
es
);
qError
(
"failed to getColInfoResult, code: %s"
,
tstrerror
(
terrno
));
qError
(
"failed to getColInfoResult, code: %s"
,
tstrerror
(
terrno
));
return
terrno
;
return
terrno
;
}
}
int32_t
i
=
0
;
int32_t
i
=
0
;
int32_t
len
=
taosArrayGetSize
(
r
es
);
int32_t
len
=
taosArrayGetSize
(
pR
es
);
if
(
pColInfoData
!=
NULL
)
{
if
(
pColInfoData
!=
NULL
)
{
bool
*
pResult
=
(
bool
*
)
pColInfoData
->
pData
;
bool
*
pResult
=
(
bool
*
)
pColInfoData
->
pData
;
SArray
*
p
=
taosArrayInit
(
taosArrayGetSize
(
r
es
),
sizeof
(
uint64_t
));
SArray
*
p
=
taosArrayInit
(
taosArrayGetSize
(
pR
es
),
sizeof
(
uint64_t
));
while
(
i
<
len
&&
pColInfoData
)
{
while
(
i
<
len
&&
pColInfoData
)
{
int64_t
*
uid
=
taosArrayGet
(
r
es
,
i
);
int64_t
*
uid
=
taosArrayGet
(
pR
es
,
i
);
qDebug
(
"tagfilter get uid:%"
PRId64
", res:%d"
,
*
uid
,
pResult
[
i
]);
qDebug
(
"tagfilter get uid:%"
PRId64
", res:%d"
,
*
uid
,
pResult
[
i
]);
if
(
pResult
[
i
])
{
if
(
pResult
[
i
])
{
taosArrayPush
(
p
,
uid
);
taosArrayPush
(
p
,
uid
);
}
}
i
+=
1
;
i
+=
1
;
}
}
taosArraySwap
(
r
es
,
p
);
taosArraySwap
(
pR
es
,
p
);
taosArrayDestroy
(
p
);
taosArrayDestroy
(
p
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录