Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0c5a8dc3
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看板
提交
0c5a8dc3
编写于
2月 22, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] refactor.
上级
b95e95dc
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
57 addition
and
57 deletion
+57
-57
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+10
-10
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+13
-13
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+12
-12
source/libs/executor/test/executorUtilTests.cpp
source/libs/executor/test/executorUtilTests.cpp
+22
-22
未找到文件。
source/libs/executor/inc/tsort.h
浏览文件 @
0c5a8dc3
...
...
@@ -63,33 +63,33 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
* @param type
* @return
*/
SSortHandle
*
c
reateSortHandle
(
SArray
*
pOrderInfo
,
bool
nullFirst
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
const
char
*
idstr
);
SSortHandle
*
tsortC
reateSortHandle
(
SArray
*
pOrderInfo
,
bool
nullFirst
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
const
char
*
idstr
);
/**
*
* @param pSortHandle
*/
void
d
estroySortHandle
(
SSortHandle
*
pSortHandle
);
void
tsortD
estroySortHandle
(
SSortHandle
*
pSortHandle
);
/**
*
* @param pHandle
* @return
*/
int32_t
sortOpen
(
SSortHandle
*
pHandle
);
int32_t
t
sortOpen
(
SSortHandle
*
pHandle
);
/**
*
* @param pHandle
* @return
*/
int32_t
sortClose
(
SSortHandle
*
pHandle
);
int32_t
t
sortClose
(
SSortHandle
*
pHandle
);
/**
*
* @return
*/
int32_t
s
etFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fp
);
int32_t
tsortS
etFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fp
);
/**
*
...
...
@@ -97,7 +97,7 @@ int32_t setFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fp);
* @param fp
* @return
*/
int32_t
setComparFn
(
SSortHandle
*
pHandle
,
_sort_merge_compar_fn_t
fp
);
int32_t
tsortSetComparFp
(
SSortHandle
*
pHandle
,
_sort_merge_compar_fn_t
fp
);
/**
*
...
...
@@ -105,14 +105,14 @@ int32_t setComparFn(SSortHandle* pHandle, _sort_merge_compar_fn_t fp);
* @param pSource
* @return success or failed
*/
int32_t
sortAddSource
(
SSortHandle
*
pSortHandle
,
void
*
pSource
);
int32_t
t
sortAddSource
(
SSortHandle
*
pSortHandle
,
void
*
pSource
);
/**
*
* @param pHandle
* @return
*/
STupleHandle
*
sortNextTuple
(
SSortHandle
*
pHandle
);
STupleHandle
*
t
sortNextTuple
(
SSortHandle
*
pHandle
);
/**
*
...
...
@@ -120,7 +120,7 @@ STupleHandle* sortNextTuple(SSortHandle* pHandle);
* @param colIndex
* @return
*/
bool
sortIsValueNul
l
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
);
bool
tsortIsNullVa
l
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
);
/**
*
...
...
@@ -128,7 +128,7 @@ bool sortIsValueNull(STupleHandle* pVHandle, int32_t colIndex);
* @param colIndex
* @return
*/
void
*
sortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
);
void
*
t
sortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
);
#ifdef __cplusplus
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
0c5a8dc3
...
...
@@ -5586,7 +5586,7 @@ static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
groupInfo
);
if
(
pInfo
->
pSortHandle
!=
NULL
)
{
d
estroySortHandle
(
pInfo
->
pSortHandle
);
tsortD
estroySortHandle
(
pInfo
->
pSortHandle
);
}
blockDataDestroy
(
pInfo
->
binfo
.
pRes
);
...
...
@@ -5617,11 +5617,11 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, STupleHandle* pTupleHan
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
bool
isNull
=
sortIsValueNul
l
(
pTupleHandle
,
i
);
bool
isNull
=
tsortIsNullVa
l
(
pTupleHandle
,
i
);
if
(
isNull
)
{
colDataAppend
(
pColInfo
,
pBlock
->
info
.
rows
,
NULL
,
true
);
}
else
{
char
*
pData
=
sortGetValue
(
pTupleHandle
,
i
);
char
*
pData
=
t
sortGetValue
(
pTupleHandle
,
i
);
colDataAppend
(
pColInfo
,
pBlock
->
info
.
rows
,
pData
,
false
);
}
}
...
...
@@ -5633,7 +5633,7 @@ static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataB
blockDataClearup
(
pDataBlock
,
hasVarCol
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
sortNextTuple
(
pHandle
);
STupleHandle
*
pTupleHandle
=
t
sortNextTuple
(
pHandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
...
...
@@ -5788,7 +5788,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) {
blockDataClearup
(
pDataBlock
,
pInfo
->
hasVarCol
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
sortNextTuple
(
pHandle
);
STupleHandle
*
pTupleHandle
=
t
sortNextTuple
(
pHandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
...
...
@@ -5835,19 +5835,19 @@ static SSDataBlock* doSortedMerge(void* param, bool* newgroup) {
SSchema
*
p
=
blockDataExtractSchema
(
pInfo
->
binfo
.
pRes
,
NULL
);
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
c
reateSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
pInfo
->
pSortHandle
=
tsortC
reateSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
p
,
pInfo
->
binfo
.
pRes
->
info
.
numOfCols
,
"GET_TASKID(pTaskInfo)"
);
tfree
(
p
);
s
etFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
tsortS
etFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfDownstream
;
++
i
)
{
SGenericSource
*
ps
=
calloc
(
1
,
sizeof
(
SGenericSource
));
ps
->
param
=
pOperator
->
pDownstream
[
i
];
sortAddSource
(
pInfo
->
pSortHandle
,
ps
);
t
sortAddSource
(
pInfo
->
pSortHandle
,
ps
);
}
int32_t
code
=
sortOpen
(
pInfo
->
pSortHandle
);
int32_t
code
=
t
sortOpen
(
pInfo
->
pSortHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
terrno
);
}
...
...
@@ -6006,18 +6006,18 @@ static SSDataBlock* doSort(void* param, bool* newgroup) {
SSchema
*
p
=
blockDataExtractSchema
(
pInfo
->
pDataBlock
,
NULL
);
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
c
reateSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_SINGLESOURCE_SORT
,
pInfo
->
bufPageSize
,
pInfo
->
pSortHandle
=
tsortC
reateSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_SINGLESOURCE_SORT
,
pInfo
->
bufPageSize
,
numOfBufPage
,
p
,
pInfo
->
pDataBlock
->
info
.
numOfCols
,
"GET_TASKID(pTaskInfo)"
);
tfree
(
p
);
s
etFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
tsortS
etFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
SGenericSource
*
ps
=
calloc
(
1
,
sizeof
(
SGenericSource
));
ps
->
param
=
pOperator
;
sortAddSource
(
pInfo
->
pSortHandle
,
ps
);
t
sortAddSource
(
pInfo
->
pSortHandle
,
ps
);
// TODO set error code;
int32_t
code
=
sortOpen
(
pInfo
->
pSortHandle
);
int32_t
code
=
t
sortOpen
(
pInfo
->
pSortHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
terrno
);
}
...
...
source/libs/executor/src/tsort.c
浏览文件 @
0c5a8dc3
...
...
@@ -87,7 +87,7 @@ static SSDataBlock* createDataBlock_rv(SSchema* pSchema, int32_t numOfCols) {
* @param type
* @return
*/
SSortHandle
*
c
reateSortHandle
(
SArray
*
pOrderInfo
,
bool
nullFirst
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
const
char
*
idstr
)
{
SSortHandle
*
tsortC
reateSortHandle
(
SArray
*
pOrderInfo
,
bool
nullFirst
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
const
char
*
idstr
)
{
SSortHandle
*
pSortHandle
=
calloc
(
1
,
sizeof
(
SSortHandle
));
pSortHandle
->
type
=
type
;
...
...
@@ -99,7 +99,7 @@ SSortHandle* createSortHandle(SArray* pOrderInfo, bool nullFirst, int32_t type,
pSortHandle
->
cmpParam
.
orderInfo
=
pOrderInfo
;
pSortHandle
->
pDataBlock
=
createDataBlock_rv
(
pSchema
,
numOfCols
);
setComparFn
(
pSortHandle
,
msortComparFn
);
tsortSetComparFp
(
pSortHandle
,
msortComparFn
);
if
(
idstr
!=
NULL
)
{
pSortHandle
->
idStr
=
strdup
(
idstr
);
...
...
@@ -108,8 +108,8 @@ SSortHandle* createSortHandle(SArray* pOrderInfo, bool nullFirst, int32_t type,
return
pSortHandle
;
}
void
d
estroySortHandle
(
SSortHandle
*
pSortHandle
)
{
sortClose
(
pSortHandle
);
void
tsortD
estroySortHandle
(
SSortHandle
*
pSortHandle
)
{
t
sortClose
(
pSortHandle
);
if
(
pSortHandle
->
pMergeTree
!=
NULL
)
{
tMergeTreeDestroy
(
pSortHandle
->
pMergeTree
);
}
...
...
@@ -119,7 +119,7 @@ void destroySortHandle(SSortHandle* pSortHandle) {
tfree
(
pSortHandle
);
}
int32_t
sortAddSource
(
SSortHandle
*
pSortHandle
,
void
*
pSource
)
{
int32_t
t
sortAddSource
(
SSortHandle
*
pSortHandle
,
void
*
pSource
)
{
taosArrayPush
(
pSortHandle
->
pOrderedSource
,
&
pSource
);
}
...
...
@@ -573,7 +573,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
sortOpen
(
SSortHandle
*
pHandle
)
{
int32_t
t
sortOpen
(
SSortHandle
*
pHandle
)
{
if
(
pHandle
->
opened
)
{
return
0
;
}
...
...
@@ -611,19 +611,19 @@ int32_t sortOpen(SSortHandle* pHandle) {
}
}
int32_t
sortClose
(
SSortHandle
*
pHandle
)
{
int32_t
t
sortClose
(
SSortHandle
*
pHandle
)
{
// do nothing
}
int32_t
s
etFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fp
)
{
int32_t
tsortS
etFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fp
)
{
pHandle
->
fetchfp
=
fp
;
}
int32_t
setComparFn
(
SSortHandle
*
pHandle
,
_sort_merge_compar_fn_t
fp
)
{
int32_t
tsortSetComparFp
(
SSortHandle
*
pHandle
,
_sort_merge_compar_fn_t
fp
)
{
pHandle
->
comparFn
=
fp
;
}
STupleHandle
*
sortNextTuple
(
SSortHandle
*
pHandle
)
{
STupleHandle
*
t
sortNextTuple
(
SSortHandle
*
pHandle
)
{
if
(
pHandle
->
cmpParam
.
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
return
NULL
;
}
...
...
@@ -669,11 +669,11 @@ STupleHandle* sortNextTuple(SSortHandle* pHandle) {
return
&
pHandle
->
tupleHandle
;
}
bool
sortIsValueNul
l
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
)
{
bool
tsortIsNullVa
l
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
)
{
return
false
;
}
void
*
sortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
)
{
void
*
t
sortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
)
{
SColumnInfoData
*
pColInfo
=
TARRAY_GET_ELEM
(
pVHandle
->
pBlock
->
pDataBlock
,
colIndex
);
return
colDataGetData
(
pColInfo
,
pVHandle
->
rowIndex
);
}
source/libs/executor/test/executorUtilTests.cpp
浏览文件 @
0c5a8dc3
...
...
@@ -164,24 +164,24 @@ TEST(testCase, inMem_sort_Test) {
taosArrayPush(orderInfo, &oi);
SSchema s = {.type = TSDB_DATA_TYPE_INT, .colId = 1, .bytes = 4, };
SSortHandle* phandle =
c
reateSortHandle(orderInfo, false, SORT_SINGLESOURCE_SORT, 1024, 5, &s, 1, "test_abc");
s
etFetchRawDataFp(phandle, getSingleColDummyBlock);
sortAddSource(phandle, &numOfRows);
SSortHandle* phandle =
tsortC
reateSortHandle(orderInfo, false, SORT_SINGLESOURCE_SORT, 1024, 5, &s, 1, "test_abc");
tsortS
etFetchRawDataFp(phandle, getSingleColDummyBlock);
t
sortAddSource(phandle, &numOfRows);
int32_t code = sortOpen(phandle);
int32_t code =
t
sortOpen(phandle);
int32_t row = 1;
while(1) {
STupleHandle* pTupleHandle = sortNextTuple(phandle);
STupleHandle* pTupleHandle =
t
sortNextTuple(phandle);
if (pTupleHandle == NULL) {
break;
}
void* v = sortGetValue(pTupleHandle, 0);
void* v =
t
sortGetValue(pTupleHandle, 0);
printf("%d: %d\n", row++, *(int32_t*) v);
}
d
estroySortHandle(phandle);
tsortD
estroySortHandle(phandle);
}
TEST(testCase, external_mem_sort_Test) {
...
...
@@ -198,8 +198,8 @@ TEST(testCase, external_mem_sort_Test) {
taosArrayPush(orderInfo, &oi);
SSchema s = {.type = TSDB_DATA_TYPE_INT, .colId = 1, .bytes = 4, };
SSortHandle* phandle =
c
reateSortHandle(orderInfo, false, SORT_SINGLESOURCE_SORT, 1024, 5, &s, 1, "test_abc");
s
etFetchRawDataFp(phandle, getSingleColDummyBlock);
SSortHandle* phandle =
tsortC
reateSortHandle(orderInfo, false, SORT_SINGLESOURCE_SORT, 1024, 5, &s, 1, "test_abc");
tsortS
etFetchRawDataFp(phandle, getSingleColDummyBlock);
_info* pInfo = (_info*) calloc(1, sizeof(_info));
pInfo->startVal = 100000;
...
...
@@ -209,22 +209,22 @@ TEST(testCase, external_mem_sort_Test) {
SGenericSource* ps = static_cast<SGenericSource*>(calloc(1, sizeof(SGenericSource)));
ps->param = pInfo;
sortAddSource(phandle, ps);
t
sortAddSource(phandle, ps);
int32_t code = sortOpen(phandle);
int32_t code =
t
sortOpen(phandle);
int32_t row = 1;
while(1) {
STupleHandle* pTupleHandle = sortNextTuple(phandle);
STupleHandle* pTupleHandle =
t
sortNextTuple(phandle);
if (pTupleHandle == NULL) {
break;
}
void* v = sortGetValue(pTupleHandle, 0);
void* v =
t
sortGetValue(pTupleHandle, 0);
printf("%d: %d\n", row++, *(int32_t*) v);
}
d
estroySortHandle(phandle);
tsortD
estroySortHandle(phandle);
}
TEST(testCase, ordered_merge_sort_Test) {
...
...
@@ -242,9 +242,9 @@ TEST(testCase, ordered_merge_sort_Test) {
taosArrayPush(orderInfo, &oi);
SSchema s = {.type = TSDB_DATA_TYPE_INT, .colId = 1, .bytes = 4};
SSortHandle* phandle =
c
reateSortHandle(orderInfo, false, SORT_MULTISOURCE_MERGE, 1024, 5, &s, 1,"test_abc");
s
etFetchRawDataFp(phandle, getSingleColDummyBlock);
setComparFn
(phandle, docomp);
SSortHandle* phandle =
tsortC
reateSortHandle(orderInfo, false, SORT_MULTISOURCE_MERGE, 1024, 5, &s, 1,"test_abc");
tsortS
etFetchRawDataFp(phandle, getSingleColDummyBlock);
tsortSetComparFp
(phandle, docomp);
for(int32_t i = 0; i < 10; ++i) {
SGenericSource* p = static_cast<SGenericSource*>(calloc(1, sizeof(SGenericSource)));
...
...
@@ -254,23 +254,23 @@ TEST(testCase, ordered_merge_sort_Test) {
c->startVal = 0;
p->param = c;
sortAddSource(phandle, p);
t
sortAddSource(phandle, p);
}
int32_t code = sortOpen(phandle);
int32_t code =
t
sortOpen(phandle);
int32_t row = 1;
while(1) {
STupleHandle* pTupleHandle = sortNextTuple(phandle);
STupleHandle* pTupleHandle =
t
sortNextTuple(phandle);
if (pTupleHandle == NULL) {
break;
}
void* v = sortGetValue(pTupleHandle, 0);
void* v =
t
sortGetValue(pTupleHandle, 0);
printf("%d: %d\n", row++, *(int32_t*) v);
}
d
estroySortHandle(phandle);
tsortD
estroySortHandle(phandle);
}
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录