Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17ead5ed
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看板
提交
17ead5ed
编写于
2月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] refactor.
上级
eb017b8d
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
139 addition
and
101 deletion
+139
-101
include/util/tpagedbuf.h
include/util/tpagedbuf.h
+3
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+15
-5
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+8
-4
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+55
-31
source/libs/executor/test/executorUtilTests.cpp
source/libs/executor/test/executorUtilTests.cpp
+45
-45
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+2
-2
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+3
-3
source/util/test/pageBufferTest.cpp
source/util/test/pageBufferTest.cpp
+7
-7
未找到文件。
include/util/tpagedbuf.h
浏览文件 @
17ead5ed
...
...
@@ -55,7 +55,7 @@ typedef struct SDiskbasedBufStatis {
* @param handle
* @return
*/
int32_t
createDiskbasedBuf
fer
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
uint64_t
qId
,
const
char
*
dir
);
int32_t
createDiskbasedBuf
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
uint64_t
qId
,
const
char
*
dir
);
/**
*
...
...
@@ -108,13 +108,13 @@ size_t getTotalBufSize(const SDiskbasedBuf* pBuf);
* @param pBuf
* @return
*/
size_t
getNumOf
Result
BufGroupId
(
const
SDiskbasedBuf
*
pBuf
);
size_t
getNumOfBufGroupId
(
const
SDiskbasedBuf
*
pBuf
);
/**
* destroy result buffer
* @param pBuf
*/
void
destroy
Result
Buf
(
SDiskbasedBuf
*
pBuf
);
void
destroy
Diskbased
Buf
(
SDiskbasedBuf
*
pBuf
);
/**
*
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
17ead5ed
...
...
@@ -627,7 +627,7 @@ SOperatorInfo* createFilterOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
pdownstream
,
int32_t
numOfDownstream
,
SSchema
*
pSchema
,
int32_t
numOfOutput
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
void
*
param
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
// SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
// SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
17ead5ed
...
...
@@ -2215,7 +2215,7 @@ static void teardownQueryRuntimeEnv(STaskRuntimeEnv *pRuntimeEnv) {
destroyScalarFuncSupport
(
pRuntimeEnv
->
scalarSup
,
pQueryAttr
->
numOfOutput
);
// destroyUdfInfo(pRuntimeEnv->pUdfInfo);
destroy
Result
Buf
(
pRuntimeEnv
->
pResultBuf
);
destroy
Diskbased
Buf
(
pRuntimeEnv
->
pResultBuf
);
doFreeQueryHandle
(
pRuntimeEnv
);
destroyTsComp
(
pRuntimeEnv
,
pQueryAttr
);
...
...
@@ -4629,7 +4629,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
getIntermediateBufInfo
(
pRuntimeEnv
,
&
ps
,
&
pQueryAttr
->
intermediateResultRowSize
);
int32_t
TENMB
=
1024
*
1024
*
10
;
int32_t
code
=
createDiskbasedBuf
fer
(
&
pRuntimeEnv
->
pResultBuf
,
ps
,
TENMB
,
pQInfo
->
qId
,
tsTempDir
);
int32_t
code
=
createDiskbasedBuf
(
&
pRuntimeEnv
->
pResultBuf
,
ps
,
TENMB
,
pQInfo
->
qId
,
tsTempDir
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -5600,6 +5600,10 @@ SArray* getResultGroupCheckColumns(STaskAttr* pQuery) {
}
static
void
destroySortedMergeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SSortedMergeOperatorInfo
*
pInfo
=
(
SSortedMergeOperatorInfo
*
)
param
;
taosArrayDestroy
(
pInfo
->
orderInfo
);
destroySortHandle
(
pInfo
->
pSortHandle
);
blockDataDestroy
(
pInfo
->
pDataBlock
);
}
static
void
destroySlimitOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
...
@@ -5655,7 +5659,10 @@ static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataB
}
SSDataBlock
*
loadNextDataBlock
(
void
*
param
)
{
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
bool
newgroup
=
false
;
return
pOperator
->
exec
(
pOperator
,
&
newgroup
);
}
static
SSDataBlock
*
doSortedMerge
(
void
*
param
,
bool
*
newgroup
)
{
...
...
@@ -5672,14 +5679,17 @@ static SSDataBlock* doSortedMerge(void* param, bool* newgroup) {
SSchema
*
p
=
blockDataExtractSchema
(
pInfo
->
pDataBlock
,
NULL
);
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
createSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_
SINGLESOURC
E
,
pInfo
->
bufPageSize
,
pInfo
->
pSortHandle
=
createSortHandle
(
pInfo
->
orderInfo
,
pInfo
->
nullFirst
,
SORT_
MULTIWAY_MERG
E
,
pInfo
->
bufPageSize
,
numOfBufPage
,
p
,
pInfo
->
pDataBlock
->
info
.
numOfCols
,
"GET_TASKID(pTaskInfo)"
);
tfree
(
p
);
setFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfDownstream
;
++
i
)
{
sortAddSource
(
pInfo
->
pSortHandle
,
pOperator
->
pDownstream
[
i
]);
SOperatorSource
*
ps
=
calloc
(
1
,
sizeof
(
SOperatorSource
));
ps
->
param
=
pOperator
->
pDownstream
[
i
];
sortAddSource
(
pInfo
->
pSortHandle
,
ps
);
}
int32_t
code
=
sortOpen
(
pInfo
->
pSortHandle
);
...
...
@@ -5714,7 +5724,7 @@ static SArray* createBlockOrder(SArray* pExprInfo, SArray* pOrderVal) {
return
pOrderInfo
;
}
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
void
*
param
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortedMergeOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSortedMergeOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
source/libs/executor/src/tsort.c
浏览文件 @
17ead5ed
...
...
@@ -39,7 +39,7 @@ typedef struct SSortHandle {
bool
nullFirst
;
bool
hasVarCol
;
SArray
*
pSources
;
SArray
*
pSources
;
// TODO refactor, remove it
SArray
*
pOrderedSource
;
_sort_fetch_block_fn_t
fetchfp
;
...
...
@@ -119,6 +119,7 @@ void destroySortHandle(SSortHandle* pSortHandle) {
tMergeTreeDestroy
(
pSortHandle
->
pMergeTree
);
}
destroyDiskbasedBuf
(
pSortHandle
->
pBuf
);
tfree
(
pSortHandle
->
idStr
);
tfree
(
pSortHandle
);
}
...
...
@@ -171,7 +172,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
int32_t
start
=
0
;
if
(
pHandle
->
pBuf
==
NULL
)
{
int32_t
code
=
createDiskbasedBuf
fer
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
0
,
"/tmp"
);
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
0
,
"/tmp"
);
setPrintStatis
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -235,7 +236,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
}
else
{
// multi-pass internal merge sort is required
if
(
pHandle
->
pBuf
==
NULL
)
{
code
=
createDiskbasedBuf
fer
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
0
,
"/tmp"
);
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
0
,
"/tmp"
);
setPrintStatis
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -614,7 +615,10 @@ int32_t sortOpen(SSortHandle* pHandle) {
}
int32_t
numOfSources
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
if
(
pHandle
->
pBuf
!=
NULL
)
{
ASSERT
(
numOfSources
<=
getNumOfInMemBufPages
(
pHandle
->
pBuf
));
}
code
=
sortComparInit
(
&
pHandle
->
cmpParam
,
pHandle
->
pOrderedSource
,
0
,
numOfSources
-
1
,
pHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
17ead5ed
...
...
@@ -35,10 +35,17 @@
namespace
{
enum
{
data_rand
=
0x1
,
data_asc
=
0x2
,
data_desc
=
0x3
,
};
typedef
struct
SDummyInputInfo
{
int32_t
max
;
int32_t
current
;
int32_t
startVal
;
int32_t
type
;
SSDataBlock
*
pBlock
;
}
SDummyInputInfo
;
...
...
@@ -83,10 +90,18 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
char
buf
[
128
]
=
{
0
};
char
b1
[
128
]
=
{
0
};
int32_t
v
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
int32_t
v
=
(
--
pInfo
->
startVal
);
if
(
pInfo
->
type
==
data_desc
)
{
v
=
(
--
pInfo
->
startVal
);
}
else
if
(
pInfo
->
type
==
data_asc
)
{
v
=
++
pInfo
->
startVal
;
}
else
if
(
pInfo
->
type
==
data_rand
)
{
v
=
random
();
}
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
// sprintf(buf, "this is %d row", i);
...
...
@@ -103,7 +118,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
return
pBlock
;
}
SOperatorInfo
*
createDummyOperator
(
int32_t
numOfBlocks
)
{
SOperatorInfo
*
createDummyOperator
(
int32_t
numOfBlocks
,
int32_t
type
)
{
SOperatorInfo
*
pOperator
=
static_cast
<
SOperatorInfo
*>
(
calloc
(
1
,
sizeof
(
SOperatorInfo
)));
pOperator
->
name
=
"dummyInputOpertor4Test"
;
pOperator
->
exec
=
getDummyBlock
;
...
...
@@ -111,6 +126,7 @@ SOperatorInfo* createDummyOperator(int32_t numOfBlocks) {
SDummyInputInfo
*
pInfo
=
(
SDummyInputInfo
*
)
calloc
(
1
,
sizeof
(
SDummyInputInfo
));
pInfo
->
max
=
numOfBlocks
;
pInfo
->
startVal
=
1500000
;
pInfo
->
type
=
type
;
pOperator
->
info
=
pInfo
;
return
pOperator
;
...
...
@@ -121,6 +137,7 @@ int main(int argc, char** argv) {
return
RUN_ALL_TESTS
();
}
#if 0
TEST(testCase, build_executor_tree_Test) {
const char* msg = "{\n"
"\t\"Id\":\t{\n"
...
...
@@ -216,34 +233,34 @@ TEST(testCase, build_executor_tree_Test) {
// int32_t code = qCreateExecTask(&handle, 2, 1, NULL, (void**) &pTaskInfo, &sinkHandle);
}
//
TEST(testCase, inMem_sort_Test) {
//
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
//
SOrder o = {.order = TSDB_ORDER_ASC};
//
o.col.info.colId = 1;
//
o.col.info.type = TSDB_DATA_TYPE_INT;
//
taosArrayPush(pOrderVal, &o);
//
//
SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
//
SExprInfo *exp = static_cast<SExprInfo*>(calloc(1, sizeof(SExprInfo)));
//
exp->base.resSchema = createSchema(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1, "res");
//
taosArrayPush(pExprInfo, &exp);
//
//
SExprInfo *exp1 = static_cast<SExprInfo*>(calloc(1, sizeof(SExprInfo)));
//
exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BINARY, 40, 2, "res1");
//
taosArrayPush(pExprInfo, &exp1);
//
// SOperatorInfo* pOperator = createOrderOperatorInfo(createDummyOperator(5), pExprInfo, pOrderVal
);
//
//
bool newgroup = false;
//
SSDataBlock* pRes = pOperator->exec(pOperator, &newgroup);
//
//
SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
//
SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
//
for(int32_t i = 0; i < pRes->info.rows; ++i) {
//
char* p = colDataGet(pCol2, i);
//
printf("%d: %d, %s\n", i, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
//
}
//
}
TEST(testCase, inMem_sort_Test) {
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
SOrder o = {.order = TSDB_ORDER_ASC};
o.col.info.colId = 1;
o.col.info.type = TSDB_DATA_TYPE_INT;
taosArrayPush(pOrderVal, &o);
SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
SExprInfo *exp = static_cast<SExprInfo*>(calloc(1, sizeof(SExprInfo)));
exp->base.resSchema = createSchema(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1, "res");
taosArrayPush(pExprInfo, &exp);
SExprInfo *exp1 = static_cast<SExprInfo*>(calloc(1, sizeof(SExprInfo)));
exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BINARY, 40, 2, "res1");
taosArrayPush(pExprInfo, &exp1);
SOperatorInfo* pOperator = createOrderOperatorInfo(createDummyOperator(5), pExprInfo, pOrderVal, NULL
);
bool newgroup = false;
SSDataBlock* pRes = pOperator->exec(pOperator, &newgroup);
SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
for(int32_t i = 0; i < pRes->info.rows; ++i) {
char* p = colDataGet(pCol2, i);
printf("%d: %d, %s\n", i, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
}
}
typedef struct su {
int32_t v;
...
...
@@ -339,6 +356,7 @@ TEST(testCase, external_sort_Test) {
taosArrayDestroy(pExprInfo);
taosArrayDestroy(pOrderVal);
}
#endif
TEST
(
testCase
,
sorted_merge_Test
)
{
srand
(
time
(
NULL
));
...
...
@@ -359,7 +377,13 @@ TEST(testCase, sorted_merge_Test) {
exp1
->
base
.
resSchema
=
createSchema
(
TSDB_DATA_TYPE_BINARY
,
40
,
2
,
"res1"
);
// taosArrayPush(pExprInfo, &exp1);
SOperatorInfo
*
pOperator
=
createOrderOperatorInfo
(
createDummyOperator
(
1500
),
pExprInfo
,
pOrderVal
,
NULL
);
int32_t
numOfSources
=
10
;
SOperatorInfo
**
plist
=
(
SOperatorInfo
**
)
calloc
(
numOfSources
,
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
numOfSources
;
++
i
)
{
plist
[
i
]
=
createDummyOperator
(
1
,
data_asc
);
}
SOperatorInfo
*
pOperator
=
createSortedMergeOperatorInfo
(
plist
,
numOfSources
,
pExprInfo
,
pOrderVal
,
NULL
);
bool
newgroup
=
false
;
SSDataBlock
*
pRes
=
NULL
;
...
...
source/libs/executor/test/executorUtilTests.cpp
浏览文件 @
17ead5ed
...
...
@@ -219,50 +219,50 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
// destroySortHandle(phandle);
//}
TEST
(
testCase
,
ordered_merge_sort_Test
)
{
SArray
*
pOrderVal
=
taosArrayInit
(
4
,
sizeof
(
SOrder
));
SOrder
o
=
{.
order
=
TSDB_ORDER_ASC
};
o
.
col
.
info
.
colId
=
1
;
o
.
col
.
info
.
type
=
TSDB_DATA_TYPE_INT
;
taosArrayPush
(
pOrderVal
,
&
o
);
int32_t
numOfRows
=
1000
;
SBlockOrderInfo
oi
=
{
0
};
oi
.
order
=
TSDB_ORDER_ASC
;
oi
.
colIndex
=
0
;
SArray
*
orderInfo
=
taosArrayInit
(
1
,
sizeof
(
SBlockOrderInfo
));
taosArrayPush
(
orderInfo
,
&
oi
);
SSchema
s
=
{.
type
=
TSDB_DATA_TYPE_INT
,
.
colId
=
1
,
.
bytes
=
4
};
SSortHandle
*
phandle
=
createSortHandle
(
orderInfo
,
false
,
SORT_MULTIWAY_MERGE
,
1024
,
5
,
&
s
,
1
,
"test_abc"
);
setFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
);
setComparFn
(
phandle
,
docomp
);
for
(
int32_t
i
=
0
;
i
<
10
;
++
i
)
{
SOperatorSource
*
p
=
static_cast
<
SOperatorSource
*>
(
calloc
(
1
,
sizeof
(
SOperatorSource
)));
_info
*
c
=
static_cast
<
_info
*>
(
calloc
(
1
,
sizeof
(
_info
)));
c
->
count
=
1
;
c
->
pageRows
=
1000
;
c
->
startVal
=
0
;
p
->
param
=
c
;
sortAddSource
(
phandle
,
p
);
}
int32_t
code
=
sortOpen
(
phandle
);
int32_t
row
=
1
;
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
sortNextTuple
(
phandle
);
if
(
pTupleHandle
==
NULL
)
{
break
;
}
void
*
v
=
sortGetValue
(
pTupleHandle
,
0
);
printf
(
"%d: %d
\n
"
,
row
++
,
*
(
int32_t
*
)
v
);
}
destroySortHandle
(
phandle
);
}
//
TEST(testCase, ordered_merge_sort_Test) {
//
SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
//
SOrder o = {.order = TSDB_ORDER_ASC};
//
o.col.info.colId = 1;
//
o.col.info.type = TSDB_DATA_TYPE_INT;
//
taosArrayPush(pOrderVal, &o);
//
//
int32_t numOfRows = 1000;
//
SBlockOrderInfo oi = {0};
//
oi.order = TSDB_ORDER_ASC;
//
oi.colIndex = 0;
//
SArray* orderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
//
taosArrayPush(orderInfo, &oi);
//
//
SSchema s = {.type = TSDB_DATA_TYPE_INT, .colId = 1, .bytes = 4};
//
SSortHandle* phandle = createSortHandle(orderInfo, false, SORT_MULTIWAY_MERGE, 1024, 5, &s, 1,"test_abc");
//
setFetchRawDataFp(phandle, getSingleColDummyBlock);
//
setComparFn(phandle, docomp);
//
//
for(int32_t i = 0; i < 10; ++i) {
//
SOperatorSource* p = static_cast<SOperatorSource*>(calloc(1, sizeof(SOperatorSource)));
//
_info* c = static_cast<_info*>(calloc(1, sizeof(_info)));
//
c->count = 1;
//
c->pageRows = 1000;
//
c->startVal = 0;
//
//
p->param = c;
//
sortAddSource(phandle, p);
//
}
//
//
int32_t code = sortOpen(phandle);
//
int32_t row = 1;
//
//
while(1) {
//
STupleHandle* pTupleHandle = sortNextTuple(phandle);
//
if (pTupleHandle == NULL) {
//
break;
//
}
//
//
void* v = sortGetValue(pTupleHandle, 0);
//
printf("%d: %d\n", row++, *(int32_t*) v);
//
//
}
//
destroySortHandle(phandle);
//
}
#pragma GCC diagnostic pop
source/libs/function/src/tpercentile.c
浏览文件 @
17ead5ed
...
...
@@ -254,7 +254,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
resetSlotInfo
(
pBucket
);
int32_t
ret
=
createDiskbasedBuf
fer
(
&
pBucket
->
pBuffer
,
pBucket
->
bufPageSize
,
pBucket
->
bufPageSize
*
512
,
1
,
tsTempDir
);
int32_t
ret
=
createDiskbasedBuf
(
&
pBucket
->
pBuffer
,
pBucket
->
bufPageSize
,
pBucket
->
bufPageSize
*
512
,
1
,
tsTempDir
);
if
(
ret
!=
0
)
{
tMemBucketDestroy
(
pBucket
);
return
NULL
;
...
...
@@ -269,7 +269,7 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
return
;
}
destroy
Result
Buf
(
pBucket
->
pBuffer
);
destroy
Diskbased
Buf
(
pBucket
->
pBuffer
);
tfree
(
pBucket
->
pSlots
);
tfree
(
pBucket
);
}
...
...
source/util/src/tpagedbuf.c
浏览文件 @
17ead5ed
...
...
@@ -53,7 +53,7 @@ typedef struct SDiskbasedBuf {
static
void
printStatisData
(
const
SDiskbasedBuf
*
pBuf
);
int32_t
createDiskbasedBuf
fer
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
uint64_t
qId
,
const
char
*
dir
)
{
int32_t
createDiskbasedBuf
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
uint64_t
qId
,
const
char
*
dir
)
{
*
pBuf
=
calloc
(
1
,
sizeof
(
SDiskbasedBuf
));
SDiskbasedBuf
*
pResBuf
=
*
pBuf
;
...
...
@@ -473,7 +473,7 @@ void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) {
pBuf
->
statis
.
releasePages
+=
1
;
}
size_t
getNumOf
Result
BufGroupId
(
const
SDiskbasedBuf
*
pBuf
)
{
return
taosHashGetSize
(
pBuf
->
groupSet
);
}
size_t
getNumOfBufGroupId
(
const
SDiskbasedBuf
*
pBuf
)
{
return
taosHashGetSize
(
pBuf
->
groupSet
);
}
size_t
getTotalBufSize
(
const
SDiskbasedBuf
*
pBuf
)
{
return
(
size_t
)
pBuf
->
totalBufSize
;
}
...
...
@@ -488,7 +488,7 @@ SIDList getDataBufPagesIdList(SDiskbasedBuf* pBuf, int32_t groupId) {
}
}
void
destroy
Result
Buf
(
SDiskbasedBuf
*
pBuf
)
{
void
destroy
Diskbased
Buf
(
SDiskbasedBuf
*
pBuf
)
{
if
(
pBuf
==
NULL
)
{
return
;
}
...
...
source/util/test/pageBufferTest.cpp
浏览文件 @
17ead5ed
...
...
@@ -13,7 +13,7 @@ namespace {
// simple test
void
simpleTest
()
{
SDiskbasedBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedBuf
fer
(
&
pResultBuf
,
1024
,
4096
,
1
,
"/tmp/"
);
int32_t
ret
=
createDiskbasedBuf
(
&
pResultBuf
,
1024
,
4096
,
1
,
"/tmp/"
);
int32_t
pageId
=
0
;
int32_t
groupId
=
0
;
...
...
@@ -25,7 +25,7 @@ void simpleTest() {
SIDList
list
=
getDataBufPagesIdList
(
pResultBuf
,
groupId
);
ASSERT_EQ
(
taosArrayGetSize
(
list
),
1
);
ASSERT_EQ
(
getNumOf
Result
BufGroupId
(
pResultBuf
),
1
);
ASSERT_EQ
(
getNumOfBufGroupId
(
pResultBuf
),
1
);
releaseBufPage
(
pResultBuf
,
pBufPage
);
...
...
@@ -50,12 +50,12 @@ void simpleTest() {
SFilePage
*
t4
=
getBufPage
(
pResultBuf
,
pageId
);
ASSERT_TRUE
(
t4
==
pBufPage5
);
destroy
Result
Buf
(
pResultBuf
);
destroy
Diskbased
Buf
(
pResultBuf
);
}
void
writeDownTest
()
{
SDiskbasedBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedBuf
fer
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
,
"/tmp/"
);
int32_t
ret
=
createDiskbasedBuf
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
,
"/tmp/"
);
int32_t
pageId
=
0
;
int32_t
writePageId
=
0
;
...
...
@@ -97,12 +97,12 @@ void writeDownTest() {
SArray
*
pa
=
getDataBufPagesIdList
(
pResultBuf
,
groupId
);
ASSERT_EQ
(
taosArrayGetSize
(
pa
),
5
);
destroy
Result
Buf
(
pResultBuf
);
destroy
Diskbased
Buf
(
pResultBuf
);
}
void
recyclePageTest
()
{
SDiskbasedBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedBuf
fer
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
,
"/tmp/"
);
int32_t
ret
=
createDiskbasedBuf
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
,
"/tmp/"
);
int32_t
pageId
=
0
;
int32_t
writePageId
=
0
;
...
...
@@ -150,7 +150,7 @@ void recyclePageTest() {
SArray
*
pa
=
getDataBufPagesIdList
(
pResultBuf
,
groupId
);
ASSERT_EQ
(
taosArrayGetSize
(
pa
),
6
);
destroy
Result
Buf
(
pResultBuf
);
destroy
Diskbased
Buf
(
pResultBuf
);
}
}
// namespace
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录