Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3a2d7235
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看板
提交
3a2d7235
编写于
2月 10, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818]Fix bug and refactor code.
上级
233079ec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
30 deletion
+41
-30
include/util/tpagedfile.h
include/util/tpagedfile.h
+11
-4
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+12
-12
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+5
-5
source/util/src/tpagedfile.c
source/util/src/tpagedfile.c
+12
-8
未找到文件。
include/util/tpagedfile.h
浏览文件 @
3a2d7235
...
...
@@ -71,28 +71,28 @@ SIDList getDataBufPagesIdList(SDiskbasedBuf* pResultBuf, int32_t groupId);
* @param id
* @return
*/
SFilePage
*
get
Res
BufPage
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
id
);
SFilePage
*
getBufPage
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
id
);
/**
* release the referenced buf pages
* @param pResultBuf
* @param page
*/
void
release
Res
BufPage
(
SDiskbasedBuf
*
pResultBuf
,
void
*
page
);
void
releaseBufPage
(
SDiskbasedBuf
*
pResultBuf
,
void
*
page
);
/**
*
* @param pResultBuf
* @param pi
*/
void
release
Res
BufPageInfo
(
SDiskbasedBuf
*
pResultBuf
,
struct
SPageInfo
*
pi
);
void
releaseBufPageInfo
(
SDiskbasedBuf
*
pResultBuf
,
struct
SPageInfo
*
pi
);
/**
* get the total buffer size in the format of disk file
* @param pResultBuf
* @return
*/
size_t
get
Res
BufSize
(
const
SDiskbasedBuf
*
pResultBuf
);
size_t
get
Total
BufSize
(
const
SDiskbasedBuf
*
pResultBuf
);
/**
* get the number of groups in the result buffer
...
...
@@ -135,6 +135,13 @@ int32_t getBufPageSize(const SDiskbasedBuf* pResultBuf);
*/
bool
isAllDataInMemBuf
(
const
SDiskbasedBuf
*
pResultBuf
);
/**
* Set the buffer page is dirty, and needs to be flushed to disk when swap out.
* @param pPageInfo
* @param dirty
*/
void
setBufPageDirty
(
SPageInfo
*
pPageInfo
,
bool
dirty
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/executor/src/executil.c
浏览文件 @
3a2d7235
...
...
@@ -143,7 +143,7 @@ void clearResultRow(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16_
// the result does not put into the SDiskbasedBuf, ignore it.
if
(
pResultRow
->
pageId
>=
0
)
{
SFilePage
*
page
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pResultRow
->
pageId
);
SFilePage
*
page
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResultRow
->
pageId
);
int16_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQueryAttr
->
numOfOutput
;
++
i
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
3a2d7235
...
...
@@ -245,8 +245,8 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
SRowCompSupporter
*
supporter
=
(
SRowCompSupporter
*
)
userData
;
STaskRuntimeEnv
*
pRuntimeEnv
=
supporter
->
pRuntimeEnv
;
SFilePage
*
page1
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow1
->
pageId
);
SFilePage
*
page2
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow2
->
pageId
);
SFilePage
*
page1
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow1
->
pageId
);
SFilePage
*
page2
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow2
->
pageId
);
int16_t
offset
=
supporter
->
dataOffset
;
char
*
in1
=
getPosInResultPage
(
pRuntimeEnv
->
pQueryAttr
,
page1
,
pRow1
->
offset
,
offset
);
...
...
@@ -708,12 +708,12 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedBuf *pRes
pData
=
getNewDataBuf
(
pResultBuf
,
tid
,
&
pageId
);
}
else
{
SPageInfo
*
pi
=
getLastPageInfo
(
list
);
pData
=
get
Res
BufPage
(
pResultBuf
,
getPageId
(
pi
));
pData
=
getBufPage
(
pResultBuf
,
getPageId
(
pi
));
pageId
=
getPageId
(
pi
);
if
(
pData
->
num
+
size
>
getBufPageSize
(
pResultBuf
))
{
// release current page first, and prepare the next one
release
Res
BufPageInfo
(
pResultBuf
,
pi
);
releaseBufPageInfo
(
pResultBuf
,
pi
);
pData
=
getNewDataBuf
(
pResultBuf
,
tid
,
&
pageId
);
if
(
pData
!=
NULL
)
{
assert
(
pData
->
num
==
0
);
// number of elements must be 0 for new allocated buffer
...
...
@@ -3651,7 +3651,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
void
setResultRowOutputBufInitCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
SFilePage
*
bufPage
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
SFilePage
*
bufPage
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
...
...
@@ -3724,7 +3724,7 @@ void setExecutionContext(STaskRuntimeEnv* pRuntimeEnv, SOptrBasicInfo* pInfo, in
void
setResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfCols
,
int32_t
*
rowCellInfoOffset
)
{
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
SFilePage
*
page
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
SFilePage
*
page
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
int16_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
...
...
@@ -3967,7 +3967,7 @@ static int32_t doCopyToSDataBlock(STaskRuntimeEnv* pRuntimeEnv, SGroupResInfo* p
pGroupResInfo
->
index
+=
1
;
SFilePage
*
page
=
get
Res
BufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow
->
pageId
);
SFilePage
*
page
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow
->
pageId
);
int32_t
offset
=
0
;
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
numOfCols
;
++
j
)
{
...
...
@@ -5634,13 +5634,13 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa
}
else
{
SPageInfo
*
pPgInfo
=
*
(
SPageInfo
**
)
taosArrayGet
(
pSource
->
pageIdList
,
pSource
->
pageIndex
);
SFilePage
*
pPage
=
get
Res
BufPage
(
pInfo
->
pSortInternalBuf
,
getPageId
(
pPgInfo
));
SFilePage
*
pPage
=
getBufPage
(
pInfo
->
pSortInternalBuf
,
getPageId
(
pPgInfo
));
int32_t
code
=
blockDataFromBuf
(
pSource
->
pBlock
,
pPage
->
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
release
Res
BufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
releaseBufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
}
}
...
...
@@ -5729,7 +5729,7 @@ void addToDiskbasedBuf(SOrderOperatorInfo* pInfo, jmp_buf env) {
assert
(
size
<=
getBufPageSize
(
pInfo
->
pSortInternalBuf
));
blockDataToBuf
(
pPage
->
data
,
p
);
release
Res
BufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
releaseBufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
blockDataDestroy
(
p
);
start
=
stop
+
1
;
...
...
@@ -5751,13 +5751,13 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, const SOrderOperatorI
SExternalMemSource
*
pSource
=
cmpParam
->
pSources
[
i
];
SPageInfo
*
pPgInfo
=
*
(
SPageInfo
**
)
taosArrayGet
(
pSource
->
pageIdList
,
pSource
->
pageIndex
);
SFilePage
*
pPage
=
get
Res
BufPage
(
pInfo
->
pSortInternalBuf
,
getPageId
(
pPgInfo
));
SFilePage
*
pPage
=
getBufPage
(
pInfo
->
pSortInternalBuf
,
getPageId
(
pPgInfo
));
int32_t
code
=
blockDataFromBuf
(
cmpParam
->
pSources
[
i
]
->
pBlock
,
pPage
->
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
release
Res
BufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
releaseBufPage
(
pInfo
->
pSortInternalBuf
,
pPage
);
}
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
3a2d7235
...
...
@@ -37,7 +37,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
for
(
int32_t
i
=
0
;
i
<
list
->
size
;
++
i
)
{
struct
SPageInfo
*
pgInfo
=
*
(
struct
SPageInfo
**
)
taosArrayGet
(
list
,
i
);
SFilePage
*
pg
=
get
Res
BufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
memcpy
(
buffer
->
data
+
offset
,
pg
->
data
,
(
size_t
)(
pg
->
num
*
pMemBucket
->
bytes
));
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
...
...
@@ -99,7 +99,7 @@ double findOnlyResult(tMemBucket *pMemBucket) {
assert
(
list
->
size
==
1
);
struct
SPageInfo
*
pgInfo
=
(
struct
SPageInfo
*
)
taosArrayGetP
(
list
,
0
);
SFilePage
*
pPage
=
get
Res
BufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
assert
(
pPage
->
num
==
1
);
double
v
=
0
;
...
...
@@ -343,7 +343,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
assert
(
pSlot
->
info
.
data
->
num
>=
pBucket
->
elemPerPage
&&
pSlot
->
info
.
size
>
0
);
// keep the pointer in memory
release
Res
BufPage
(
pBucket
->
pBuffer
,
pSlot
->
info
.
data
);
releaseBufPage
(
pBucket
->
pBuffer
,
pSlot
->
info
.
data
);
pSlot
->
info
.
data
=
NULL
;
}
...
...
@@ -471,10 +471,10 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
for
(
int32_t
f
=
0
;
f
<
list
->
size
;
++
f
)
{
SPageInfo
*
pgInfo
=
*
(
SPageInfo
**
)
taosArrayGet
(
list
,
f
);
SFilePage
*
pg
=
get
Res
BufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
getPageId
(
pgInfo
));
tMemBucketPut
(
pMemBucket
,
pg
->
data
,
(
int32_t
)
pg
->
num
);
release
Res
BufPageInfo
(
pMemBucket
->
pBuffer
,
pgInfo
);
releaseBufPageInfo
(
pMemBucket
->
pBuffer
,
pgInfo
);
}
return
getPercentileImpl
(
pMemBucket
,
count
-
num
,
fraction
);
...
...
source/util/src/tpagedfile.c
浏览文件 @
3a2d7235
...
...
@@ -305,7 +305,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pResultBuf) {
return
pn
;
}
static
char
*
ev
i
cOneDataPage
(
SDiskbasedBuf
*
pResultBuf
)
{
static
char
*
ev
a
cOneDataPage
(
SDiskbasedBuf
*
pResultBuf
)
{
char
*
bufPage
=
NULL
;
SListNode
*
pn
=
getEldestUnrefedPage
(
pResultBuf
);
...
...
@@ -355,7 +355,7 @@ SFilePage* getNewDataBuf(SDiskbasedBuf* pResultBuf, int32_t groupId, int32_t* pa
char
*
availablePage
=
NULL
;
if
(
NO_IN_MEM_AVAILABLE_PAGES
(
pResultBuf
))
{
availablePage
=
ev
i
cOneDataPage
(
pResultBuf
);
availablePage
=
ev
a
cOneDataPage
(
pResultBuf
);
// Failed to allocate a new buffer page, and there is an error occurs.
if
(
availablePage
==
NULL
)
{
...
...
@@ -391,7 +391,7 @@ SFilePage* getNewDataBuf(SDiskbasedBuf* pResultBuf, int32_t groupId, int32_t* pa
return
(
void
*
)(
GET_DATA_PAYLOAD
(
pi
));
}
SFilePage
*
get
Res
BufPage
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
id
)
{
SFilePage
*
getBufPage
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
id
)
{
assert
(
pResultBuf
!=
NULL
&&
id
>=
0
);
pResultBuf
->
statis
.
getPages
+=
1
;
...
...
@@ -418,7 +418,7 @@ SFilePage* getResBufPage(SDiskbasedBuf* pResultBuf, int32_t id) {
char
*
availablePage
=
NULL
;
if
(
NO_IN_MEM_AVAILABLE_PAGES
(
pResultBuf
))
{
availablePage
=
ev
i
cOneDataPage
(
pResultBuf
);
availablePage
=
ev
a
cOneDataPage
(
pResultBuf
);
if
(
availablePage
==
NULL
)
{
return
NULL
;
}
...
...
@@ -440,15 +440,15 @@ SFilePage* getResBufPage(SDiskbasedBuf* pResultBuf, int32_t id) {
}
}
void
release
Res
BufPage
(
SDiskbasedBuf
*
pResultBuf
,
void
*
page
)
{
void
releaseBufPage
(
SDiskbasedBuf
*
pResultBuf
,
void
*
page
)
{
assert
(
pResultBuf
!=
NULL
&&
page
!=
NULL
);
char
*
p
=
(
char
*
)
page
-
POINTER_BYTES
;
SPageInfo
*
ppi
=
((
SPageInfo
**
)
p
)[
0
];
release
Res
BufPageInfo
(
pResultBuf
,
ppi
);
releaseBufPageInfo
(
pResultBuf
,
ppi
);
}
void
release
Res
BufPageInfo
(
SDiskbasedBuf
*
pResultBuf
,
SPageInfo
*
pi
)
{
void
releaseBufPageInfo
(
SDiskbasedBuf
*
pResultBuf
,
SPageInfo
*
pi
)
{
assert
(
pi
->
pData
!=
NULL
&&
pi
->
used
);
pi
->
used
=
false
;
...
...
@@ -457,7 +457,7 @@ void releaseResBufPageInfo(SDiskbasedBuf* pResultBuf, SPageInfo* pi) {
size_t
getNumOfResultBufGroupId
(
const
SDiskbasedBuf
*
pResultBuf
)
{
return
taosHashGetSize
(
pResultBuf
->
groupSet
);
}
size_t
get
Res
BufSize
(
const
SDiskbasedBuf
*
pResultBuf
)
{
return
(
size_t
)
pResultBuf
->
totalBufSize
;
}
size_t
get
Total
BufSize
(
const
SDiskbasedBuf
*
pResultBuf
)
{
return
(
size_t
)
pResultBuf
->
totalBufSize
;
}
SIDList
getDataBufPagesIdList
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
groupId
)
{
assert
(
pResultBuf
!=
NULL
);
...
...
@@ -529,3 +529,7 @@ int32_t getBufPageSize(const SDiskbasedBuf* pResultBuf) {
bool
isAllDataInMemBuf
(
const
SDiskbasedBuf
*
pResultBuf
)
{
return
pResultBuf
->
fileSize
==
0
;
}
void
setBufPageDirty
(
SPageInfo
*
pPageInfo
,
bool
dirty
)
{
pPageInfo
->
dirty
=
dirty
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录