Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c522a4f0
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看板
提交
c522a4f0
编写于
3月 23, 2022
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-1318]<fix>: used merge sort to sort vgId and updated test cases
上级
ecfb830c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
110 addition
and
17 deletion
+110
-17
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+94
-1
tests/develop-test/2-query/function_unique.py
tests/develop-test/2-query/function_unique.py
+16
-16
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
c522a4f0
...
...
@@ -936,6 +936,96 @@ static void setTidTagType(SJoinSupporter* p, uint8_t type) {
}
}
static
int32_t
tidTagsMerge
(
SArray
*
arr
,
int32_t
start
,
int32_t
mid
,
int32_t
end
,
const
int32_t
tagSize
)
{
char
*
pTmp
,
*
pRes
=
NULL
;
char
*
result
=
NULL
;
STidTags
*
pi
,
*
pj
,
*
p
;
int32_t
k
=
0
;
int32_t
i
=
start
;
int32_t
j
=
mid
+
1
;
if
(
end
-
start
>
0
)
{
result
=
calloc
(
1
,
(
end
-
start
+
1
)
*
tagSize
);
if
(
result
==
NULL
)
{
tscError
(
"failed to allocate memory for tidTagsMerge"
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
pRes
=
result
;
while
(
i
<=
mid
&&
j
<=
end
)
{
pi
=
taosArrayGet
(
arr
,
i
);
pj
=
taosArrayGet
(
arr
,
j
);
if
(
pi
->
vgId
<=
pj
->
vgId
)
{
p
=
taosArrayGet
(
arr
,
i
++
);
memcpy
(
pRes
,
p
,
tagSize
);
}
else
{
p
=
taosArrayGet
(
arr
,
j
++
);
memcpy
(
pRes
,
p
,
tagSize
);
}
k
++
;
pRes
+=
tagSize
;
}
if
(
i
==
mid
+
1
)
{
while
(
j
<=
end
)
{
p
=
taosArrayGet
(
arr
,
j
++
);
memcpy
(
pRes
,
p
,
tagSize
);
k
++
;
pRes
+=
tagSize
;
}
}
if
(
j
==
end
+
1
)
{
while
(
i
<=
mid
)
{
p
=
taosArrayGet
(
arr
,
i
++
);
memcpy
(
pRes
,
p
,
tagSize
);
k
++
;
pRes
+=
tagSize
;
}
}
for
(
i
=
start
,
j
=
0
,
pTmp
=
result
;
j
<
k
;
i
++
,
j
++
,
pTmp
+=
tagSize
)
{
p
=
(
STidTags
*
)
taosArrayGet
(
arr
,
i
);
memcpy
(
p
,
pTmp
,
tagSize
);
}
if
(
result
)
{
tfree
(
result
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tidTagsMergeSort
(
SArray
*
arr
,
int32_t
start
,
int32_t
end
,
const
int32_t
tagSize
)
{
int32_t
ret
;
int32_t
mid
;
if
(
start
>=
end
)
{
return
TSDB_CODE_SUCCESS
;
}
mid
=
(
start
+
end
)
/
2
;
ret
=
tidTagsMergeSort
(
arr
,
start
,
mid
,
tagSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
ret
=
tidTagsMergeSort
(
arr
,
mid
+
1
,
end
,
tagSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
return
tidTagsMerge
(
arr
,
start
,
mid
,
end
,
tagSize
);
}
static
int32_t
getIntersectionOfTableTuple
(
SQueryInfo
*
pQueryInfo
,
SSqlObj
*
pParentSql
,
SArray
*
resList
)
{
int16_t
joinNum
=
pParentSql
->
subState
.
numOfSub
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
...
@@ -1125,7 +1215,10 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
// sort according to the tag value
size_t
num
=
taosArrayGetSize
(
ctxlist
[
i
].
res
);
qsort
((
ctxlist
[
i
].
res
)
->
pData
,
num
,
size
,
tidTagsCompar
);
int32_t
ret
=
tidTagsMergeSort
(
ctxlist
[
i
].
res
,
0
,
num
-
1
,
size
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
taosArrayPush
(
resList
,
&
ctxlist
[
i
].
res
);
...
...
tests/develop-test/2-query/function_unique.py
浏览文件 @
c522a4f0
...
...
@@ -83,8 +83,8 @@ class TDTestCase:
tdSql
.
checkData
(
3
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
1
,
1
9
)
tdSql
.
checkData
(
3
,
1
,
9
)
tdSql
.
checkData
(
2
,
1
,
9
)
tdSql
.
checkData
(
3
,
1
,
1
9
)
tdSql
.
query
(
'select ts,unique(voltage),ts,groupid,location,tbname from unique'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -106,19 +106,19 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
2
,
1
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
2
,
2
,
1
9
)
tdSql
.
checkData
(
2
,
2
,
9
)
tdSql
.
checkData
(
2
,
3
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
2
,
4
,
2
)
tdSql
.
checkData
(
2
,
5
,
"Beijing.
haidian
"
)
tdSql
.
checkData
(
2
,
6
,
"d00
2
"
)
tdSql
.
checkData
(
2
,
4
,
3
)
tdSql
.
checkData
(
2
,
5
,
"Beijing.
Tongzhou
"
)
tdSql
.
checkData
(
2
,
6
,
"d00
3
"
)
tdSql
.
checkData
(
3
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
3
,
1
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
3
,
2
,
9
)
tdSql
.
checkData
(
3
,
2
,
1
9
)
tdSql
.
checkData
(
3
,
3
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
3
,
4
,
3
)
tdSql
.
checkData
(
3
,
5
,
"Beijing.
Tongzhou
"
)
tdSql
.
checkData
(
3
,
6
,
"d00
3
"
)
tdSql
.
checkData
(
3
,
4
,
2
)
tdSql
.
checkData
(
3
,
5
,
"Beijing.
haidian
"
)
tdSql
.
checkData
(
3
,
6
,
"d00
2
"
)
tdSql
.
execute
(
'insert into D004 values("2021-10-15 00:00:01", 10, 2) ("2021-12-24 00:21:31", 5, 2) ("2021-12-25 01:31:31", 9, 4)'
)
...
...
@@ -151,9 +151,9 @@ class TDTestCase:
tdSql
.
query
(
'select ts,unique(voltage) from unique group by ts'
)
tdSql
.
checkRows
(
9
)
tdSql
.
checkData
(
1
,
2
,
1
)
tdSql
.
checkData
(
4
,
2
,
1
)
tdSql
.
checkData
(
4
,
2
,
2
)
tdSql
.
checkData
(
8
,
2
,
1
)
tdSql
.
checkData
(
6
,
2
,
9
)
tdSql
.
checkData
(
6
,
2
,
1
9
)
tdSql
.
checkData
(
7
,
2
,
9
)
#group by tag,column
tdSql
.
query
(
'select ts,unique(voltage) from unique group by location,num'
)
...
...
@@ -165,13 +165,13 @@ class TDTestCase:
tdSql
.
query
(
'select unique(voltage) from unique order by ts desc'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
0
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
0
,
1
,
1
9
)
tdSql
.
checkData
(
5
,
0
,
"2021-10-15 00:00:01"
)
tdSql
.
checkData
(
5
,
1
,
10
)
tdSql
.
query
(
'select unique(voltage) from unique order by ts'
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkData
(
5
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
5
,
1
,
9
)
tdSql
.
checkData
(
5
,
1
,
1
9
)
tdSql
.
checkData
(
0
,
0
,
"2021-10-15 00:00:01"
)
tdSql
.
checkData
(
0
,
1
,
10
)
#order by column [desc]
...
...
@@ -216,7 +216,7 @@ class TDTestCase:
tdSql
.
checkData
(
6
,
0
,
"2021-12-25 01:31:31"
)
tdSql
.
checkData
(
6
,
1
,
9
)
tdSql
.
checkData
(
0
,
0
,
"2021-12-24 01:31:31"
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
0
,
1
,
1
9
)
# error
tdSql
.
error
(
"select unique(ts) from unique"
)
...
...
@@ -246,7 +246,7 @@ class TDTestCase:
tdSql
.
query
(
'select unique(voltage) from unique where voltage > 2 limit 2 offset 1'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
5
)
tdSql
.
checkData
(
1
,
1
,
1
9
)
tdSql
.
checkData
(
1
,
1
,
9
)
#having
tdSql
.
query
(
'select unique(voltage) from unique group by num having unique(voltage)>5'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录