Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
888f8aa1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
未验证
提交
888f8aa1
编写于
2月 28, 2023
作者:
H
Haojun Liao
提交者:
GitHub
2月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20194 from taosdata/fix/join_bug
fix(query): set correct vgId and add some test case.
上级
e8a1c539
6348c03f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
168 addition
and
46 deletion
+168
-46
src/client/src/tscServer.c
src/client/src/tscServer.c
+20
-10
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+2
-0
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+39
-13
src/query/tests/CMakeLists.txt
src/query/tests/CMakeLists.txt
+7
-7
src/query/tests/apercentileTest.cpp
src/query/tests/apercentileTest.cpp
+6
-6
src/query/tests/histogramTest.cpp
src/query/tests/histogramTest.cpp
+1
-1
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+93
-9
未找到文件。
src/client/src/tscServer.c
浏览文件 @
888f8aa1
...
...
@@ -1252,18 +1252,28 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
tsBuf
.
tsOffset
=
htonl
((
int32_t
)(
pMsg
-
pCmd
->
payload
));
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
// note: here used the idx instead of actual vnode id.
int32_t
vgId
=
0
;
if
(
pTableMetaInfo
->
vgroupList
!=
NULL
)
{
int32_t
vnodeIndex
=
pTableMetaInfo
->
vgroupIndex
;
vgId
=
pTableMetaInfo
->
vgroupList
->
vgroups
[
vnodeIndex
].
vgId
;
bool
qType
=
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
);
if
(
qType
)
{
dumpFileBlockByGroupIndex
(
pQueryInfo
->
tsBuf
,
pTableMetaInfo
->
vgroupIndex
,
pMsg
,
&
pQueryMsg
->
tsBuf
.
tsLen
,
&
pQueryMsg
->
tsBuf
.
tsNumOfBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
}
else
{
vgId
=
query
.
vgId
;
}
// note: here used the idx instead of actual vnode id.
int32_t
vgId
=
0
;
if
(
pTableMetaInfo
->
pVgroupTables
!=
NULL
)
{
int32_t
vnodeIndex
=
pTableMetaInfo
->
vgroupIndex
;
SVgroupTableInfo
*
pTableInfo
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
vnodeIndex
);
vgId
=
pTableInfo
->
vgInfo
.
vgId
;
}
else
{
vgId
=
query
.
vgId
;
}
code
=
dumpFileBlockByGroupId
(
pQueryInfo
->
tsBuf
,
vgId
,
pMsg
,
&
pQueryMsg
->
tsBuf
.
tsLen
,
&
pQueryMsg
->
tsBuf
.
tsNumOfBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
code
=
dumpFileBlockByGroupId
(
pQueryInfo
->
tsBuf
,
vgId
,
pMsg
,
&
pQueryMsg
->
tsBuf
.
tsLen
,
&
pQueryMsg
->
tsBuf
.
tsNumOfBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
}
pMsg
+=
pQueryMsg
->
tsBuf
.
tsLen
;
...
...
src/query/inc/qTsbuf.h
浏览文件 @
888f8aa1
...
...
@@ -136,6 +136,8 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id);
int32_t
dumpFileBlockByGroupId
(
STSBuf
*
pTSBuf
,
int32_t
id
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
);
int32_t
dumpFileBlockByGroupIndex
(
STSBuf
*
pTSBuf
,
int32_t
groupIndex
,
void
*
pBuf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
);
STSElem
tsBufFindElemStartPosByTag
(
STSBuf
*
pTSBuf
,
tVariant
*
pTag
);
bool
tsBufIsValidElem
(
STSElem
*
pElem
);
...
...
src/query/src/qTsbuf.c
浏览文件 @
888f8aa1
...
...
@@ -593,22 +593,22 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex
}
STSCursor
*
pCur
=
&
pTSBuf
->
cur
;
if
(
pCur
->
vgroupIndex
==
groupIndex
&&
((
pCur
->
blockIndex
<=
blockIndex
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
(
pCur
->
blockIndex
>=
blockIndex
&&
pCur
->
order
==
TSDB_ORDER_DESC
)))
{
int32_t
i
=
0
;
bool
decomp
=
false
;
int32_t
step
=
abs
(
blockIndex
-
pCur
->
blockIndex
);
while
((
++
i
)
<=
step
)
{
if
(
readDataFromDisk
(
pTSBuf
,
pCur
->
order
,
decomp
)
==
NULL
)
{
return
;
}
}
}
else
{
//
if (pCur->vgroupIndex == groupIndex && ((pCur->blockIndex <= blockIndex && pCur->order == TSDB_ORDER_ASC) ||
//
(pCur->blockIndex >= blockIndex && pCur->order == TSDB_ORDER_DESC))) {
//
int32_t i = 0;
//
bool decomp = false;
//
int32_t step = abs(blockIndex - pCur->blockIndex);
//
//
while ((++i) <= step) {
//
if (readDataFromDisk(pTSBuf, pCur->order, decomp) == NULL) {
//
return;
//
}
//
}
//
} else {
if
(
tsBufFindBlock
(
pTSBuf
,
pBlockInfo
,
blockIndex
)
==
-
1
)
{
assert
(
false
);
}
}
//
}
STSBlock
*
pBlock
=
&
pTSBuf
->
block
;
...
...
@@ -1133,6 +1133,32 @@ int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t groupId, void* buf, int32
return
TSDB_CODE_SUCCESS
;
}
int32_t
dumpFileBlockByGroupIndex
(
STSBuf
*
pTSBuf
,
int32_t
groupIndex
,
void
*
pBuf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
)
{
assert
(
groupIndex
>=
0
&&
groupIndex
<
pTSBuf
->
numOfGroups
);
STSGroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
groupIndex
].
info
;
*
len
=
0
;
*
numOfBlocks
=
0
;
if
(
fseek
(
pTSBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
)
!=
0
)
{
int
code
=
TAOS_SYSTEM_ERROR
(
ferror
(
pTSBuf
->
f
));
// qError("%p: fseek failed: %s", pSql, tstrerror(code));
return
code
;
}
size_t
s
=
fread
(
pBuf
,
1
,
pBlockInfo
->
compLen
,
pTSBuf
->
f
);
if
(
s
!=
pBlockInfo
->
compLen
)
{
int
code
=
TAOS_SYSTEM_ERROR
(
ferror
(
pTSBuf
->
f
));
// tscError("%p: fread didn't return expected data: %s", pSql, tstrerror(code));
return
code
;
}
*
len
=
pBlockInfo
->
compLen
;
*
numOfBlocks
=
pBlockInfo
->
numOfBlocks
;
return
TSDB_CODE_SUCCESS
;
}
STSElem
tsBufFindElemStartPosByTag
(
STSBuf
*
pTSBuf
,
tVariant
*
pTag
)
{
STSElem
el
=
{.
id
=
-
1
};
...
...
src/query/tests/CMakeLists.txt
浏览文件 @
888f8aa1
...
...
@@ -30,11 +30,11 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR))
ENDIF
()
ENDIF
()
SET_SOURCE_FILES_PROPERTIES
(
./astTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./histogramTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./percentileTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./apercentileTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./resultBufferTest.cpp PROPERTIES COMPILE_FLAGS -w
)
#
SET_SOURCE_FILES_PROPERTIES(./astTest.cpp PROPERTIES COMPILE_FLAGS -w)
#
SET_SOURCE_FILES_PROPERTIES(./histogramTest.cpp PROPERTIES COMPILE_FLAGS -w)
#
SET_SOURCE_FILES_PROPERTIES(./percentileTest.cpp PROPERTIES COMPILE_FLAGS -w)
#
SET_SOURCE_FILES_PROPERTIES(./apercentileTest.cpp PROPERTIES COMPILE_FLAGS -w)
#
SET_SOURCE_FILES_PROPERTIES(./resultBufferTest.cpp PROPERTIES COMPILE_FLAGS -w)
SET_SOURCE_FILES_PROPERTIES
(
./tsBufTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./unitTest.cpp PROPERTIES COMPILE_FLAGS -w
)
SET_SOURCE_FILES_PROPERTIES
(
./rangeMergeTest.cpp PROPERTIES COMPILE_FLAGS -w
)
#
SET_SOURCE_FILES_PROPERTIES(./unitTest.cpp PROPERTIES COMPILE_FLAGS -w)
#
SET_SOURCE_FILES_PROPERTIES(./rangeMergeTest.cpp PROPERTIES COMPILE_FLAGS -w)
src/query/tests/apercentileTest.cpp
浏览文件 @
888f8aa1
...
...
@@ -291,13 +291,13 @@ void tdigestTest() {
for
(
int32_t
j
=
0
;
j
<
typeTimes
;
++
j
)
{
printf
(
"DMode:%d,Type:%d,randP:%d -"
,
dataMode
[
i
],
dataTypes
[
j
],
randPers
[
p
]);
for
(
int32_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
p
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
p
]);
}
printf
(
"
\n
"
);
printf
(
"HMode:%d,Type:%d,randP:%d -"
,
dataMode
[
i
],
dataTypes
[
j
],
randPers
[
p
]);
for
(
int32_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
p
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
p
]);
}
printf
(
"
\n
"
);
}
...
...
@@ -307,13 +307,13 @@ void tdigestTest() {
for
(
int32_t
j
=
0
;
j
<
typeTimes
;
++
j
)
{
printf
(
"DMode:%d,Type:%d,randL:%d -"
,
dataMode
[
i
],
dataTypes
[
j
],
randLimits
[
p
]);
for
(
int64_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
p
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
p
]);
}
printf
(
"
\n
"
);
printf
(
"HMode:%d,Type:%d,randL:%d -"
,
dataMode
[
i
],
dataTypes
[
j
],
randLimits
[
p
]);
for
(
int64_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
p
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
p
]);
}
printf
(
"
\n
"
);
}
...
...
@@ -322,13 +322,13 @@ void tdigestTest() {
for
(
int32_t
j
=
0
;
j
<
typeTimes
;
++
j
)
{
printf
(
"DMode:%d,Type:%d -"
,
dataMode
[
i
],
dataTypes
[
j
]);
for
(
int64_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
0
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
0
][
i
][
j
][
m
][
0
]);
}
printf
(
"
\n
"
);
printf
(
"HMode:%d,Type:%d -"
,
dataMode
[
i
],
dataTypes
[
j
]);
for
(
int64_t
m
=
0
;
m
<
numTimes
;
++
m
)
{
printf
(
" %d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
0
]);
printf
(
" %
l
d:%f"
,
totalNum
[
m
],
useTime
[
1
][
i
][
j
][
m
][
0
]);
}
printf
(
"
\n
"
);
}
...
...
src/query/tests/histogramTest.cpp
浏览文件 @
888f8aa1
...
...
@@ -35,7 +35,7 @@ void doHistogramAddTest() {
(
int64_t
)
systemTime
.
tv_sec
*
1000L
+
(
uint64_t
)
systemTime
.
tv_usec
/
1000
;
printf
(
"total elapsed time: %ld
\n
"
,
et
-
st
);
printf
(
"elements: %d, slot:%d
\n
"
,
pHisto
->
numOfElems
,
pHisto
->
numOfEntries
);
printf
(
"elements: %
l
d, slot:%d
\n
"
,
pHisto
->
numOfElems
,
pHisto
->
numOfEntries
);
tHistogramPrint
(
pHisto
);
printf
(
"%ld
\n
"
,
tHistogramSum
(
pHisto
,
1.5
));
...
...
src/query/tests/tsBufTest.cpp
浏览文件 @
888f8aa1
...
...
@@ -497,19 +497,103 @@ void mergeIdenticalVnodeBufferTest() {
tsBufDestroy
(
pTSBuf1
);
tsBufDestroy
(
pTSBuf2
);
}
void
mergeMultiBlockFromOneGroupTest
()
{
STSBuf
*
pTSBuf1
=
tsBufCreate
(
true
,
TSDB_ORDER_ASC
);
STSBuf
*
pTSBuf2
=
tsBufCreate
(
true
,
TSDB_ORDER_ASC
);
tVariant
t
=
{
0
};
t
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
int32_t
step
=
30
;
int32_t
num
=
1000
;
int32_t
numOfTags
=
2
;
// vnodeId:0
int64_t
start
=
10000
;
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
int64_t
*
list
=
createTsList
(
num
,
start
,
step
);
t
.
i64
=
i
;
tsBufAppend
(
pTSBuf1
,
12
,
&
t
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
free
(
list
);
start
+=
step
*
num
;
}
tsBufFlush
(
pTSBuf1
);
for
(
int32_t
i
=
numOfTags
;
i
<
numOfTags
*
2
;
++
i
)
{
int64_t
*
list
=
createTsList
(
num
,
start
,
step
);
t
.
i64
=
i
;
tsBufAppend
(
pTSBuf1
,
77
,
&
t
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
free
(
list
);
start
+=
step
*
num
;
}
tsBufFlush
(
pTSBuf1
);
start
=
10000
;
for
(
int32_t
i
=
911
;
i
<
912
;
++
i
)
{
int64_t
*
list
=
createTsList
(
num
,
start
,
step
);
t
.
i64
=
i
;
tsBufAppend
(
pTSBuf1
,
12
,
&
t
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
free
(
list
);
start
+=
step
*
num
;
}
tsBufFlush
(
pTSBuf1
);
char
*
p
=
(
char
*
)
malloc
(
1024768
);
int32_t
len
=
0
;
int32_t
numOfBlocks
=
0
;
dumpFileBlockByGroupId
(
pTSBuf1
,
12
,
p
,
&
len
,
&
numOfBlocks
);
STSBuf
*
pNew
=
tsBufCreateFromCompBlocks
(
p
,
numOfBlocks
,
len
,
1
,
12
);
printf
(
"%p
\n
"
,
pNew
);
tsBufDisplay
(
pNew
);
// tsBufMerge(pTSBuf1, pTSBuf2);
// EXPECT_EQ(pTSBuf1->numOfGroups, 2);
// EXPECT_EQ(pTSBuf1->numOfTotal, numOfTags * 2 * num);
//
// tsBufResetPos(pTSBuf1);
//
// int32_t count = 0;
// while (tsBufNextPos(pTSBuf1)) {
// STSElem elem = tsBufGetElem(pTSBuf1);
//
// if (count++ < numOfTags * num) {
// EXPECT_EQ(elem.id, 12);
// } else {
// EXPECT_EQ(elem.id, 77);
// }
//
// printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts);
// }
//
// tsBufDestroy(pTSBuf1);
// tsBufDestroy(pTSBuf2);
}
}
// namespace
//TODO add binary tag value test case
TEST
(
testCase
,
tsBufTest
)
{
simpleTest
();
largeTSTest
();
multiTagsTest
();
multiVnodeTagsTest
();
loadDataTest
();
invalidFileTest
();
//
simpleTest();
//
largeTSTest();
//
multiTagsTest();
//
multiVnodeTagsTest();
//
loadDataTest();
//
invalidFileTest();
// randomIncTsTest();
TSTraverse
();
mergeDiffVnodeBufferTest
();
mergeIdenticalVnodeBufferTest
();
// TSTraverse();
// mergeDiffVnodeBufferTest();
// mergeIdenticalVnodeBufferTest();
mergeMultiBlockFromOneGroupTest
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录