Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c5d33d31
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c5d33d31
编写于
2月 09, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] fix bug in paged file.
上级
8b4b14f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
15 deletion
+30
-15
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+5
-1
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+1
-1
source/util/src/tpagedfile.c
source/util/src/tpagedfile.c
+24
-13
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
c5d33d31
...
...
@@ -5718,6 +5718,10 @@ void addToDiskbasedBuf(SOrderOperatorInfo* pInfo, jmp_buf env) {
int32_t
pageId
=
-
1
;
SFilePage
*
pPage
=
getNewDataBuf
(
pInfo
->
pSortInternalBuf
,
pInfo
->
sourceId
,
&
pageId
);
if
(
pPage
==
NULL
)
{
assert
(
0
);
longjmp
(
env
,
terrno
);
}
int32_t
size
=
blockDataGetSize
(
p
)
+
sizeof
(
int32_t
)
+
p
->
info
.
numOfCols
*
sizeof
(
int32_t
);
assert
(
size
<=
getBufPageSize
(
pInfo
->
pSortInternalBuf
));
...
...
@@ -5884,7 +5888,7 @@ SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprI
return
NULL
;
}
pInfo
->
sortBufSize
=
1024
*
1024
*
5
;
// 1MB
pInfo
->
sortBufSize
=
1024
*
1024
*
5
0
;
// 1MB
pInfo
->
capacity
=
64
*
1024
;
pInfo
->
pDataBlock
=
createOutputBuf_rv
(
pExprInfo
,
pInfo
->
capacity
);
pInfo
->
pSources
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
c5d33d31
...
...
@@ -262,7 +262,7 @@ TEST(testCase, external_sort_Test) {
exp1
->
base
.
resSchema
=
createSchema
(
TSDB_DATA_TYPE_BINARY
,
40
,
2
,
"res1"
);
taosArrayPush
(
pExprInfo
,
&
exp1
);
SOperatorInfo
*
pOperator
=
createOrderOperatorInfo
(
createDummyOperator
(
50000
),
pExprInfo
,
pOrderVal
);
SOperatorInfo
*
pOperator
=
createOrderOperatorInfo
(
createDummyOperator
(
50000
0
),
pExprInfo
,
pOrderVal
);
bool
newgroup
=
false
;
SSDataBlock
*
pRes
=
NULL
;
...
...
source/util/src/tpagedfile.c
浏览文件 @
c5d33d31
...
...
@@ -13,8 +13,8 @@ typedef struct SFreeListItem {
}
SFreeListItem
;
typedef
struct
SPageDiskInfo
{
int32
_t
offset
;
int32_t
length
;
uint64
_t
offset
;
int32_t
length
;
}
SPageDiskInfo
;
typedef
struct
SPageInfo
{
...
...
@@ -36,7 +36,7 @@ typedef struct SDiskbasedBufStatis {
typedef
struct
SDiskbasedBuf
{
int32_t
numOfPages
;
int64_t
totalBufSize
;
int64_t
fileSize
;
// disk file size
uint64_t
fileSize
;
// disk file size
FILE
*
file
;
int32_t
allocateId
;
// allocated page id
char
*
path
;
// file path
...
...
@@ -49,7 +49,7 @@ typedef struct SDiskbasedBuf {
void
*
assistBuf
;
// assistant buffer for compress/decompress data
SArray
*
pFree
;
// free area in file
bool
comp
;
// compressed before flushed to disk
int32_t
nextPos
;
// next page flush position
uint64_t
nextPos
;
// next page flush position
uint64_t
qId
;
// for debug purpose
SDiskbasedBufStatis
statis
;
...
...
@@ -130,7 +130,7 @@ static char* doDecompressData(void* data, int32_t srcSize, int32_t *dst, SDiskba
return
data
;
}
static
int32
_t
allocatePositionInFile
(
SDiskbasedBuf
*
pResultBuf
,
size_t
size
)
{
static
uint64
_t
allocatePositionInFile
(
SDiskbasedBuf
*
pResultBuf
,
size_t
size
)
{
if
(
pResultBuf
->
pFree
==
NULL
)
{
return
pResultBuf
->
nextPos
;
}
else
{
...
...
@@ -165,10 +165,16 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pResultBuf, SPageInfo* pg) {
pResultBuf
->
nextPos
+=
size
;
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
assert
(
ret
==
0
);
if
(
ret
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
ret
=
(
int32_t
)
fwrite
(
t
,
1
,
size
,
pResultBuf
->
file
);
assert
(
ret
==
size
);
if
(
ret
!=
size
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
if
(
pResultBuf
->
fileSize
<
pg
->
info
.
offset
+
pg
->
info
.
length
)
{
pResultBuf
->
fileSize
=
pg
->
info
.
offset
+
pg
->
info
.
length
;
...
...
@@ -186,13 +192,15 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pResultBuf, SPageInfo* pg) {
//3. write to disk.
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
if
(
ret
!=
0
)
{
// todo handle the error case
if
(
ret
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
ret
=
(
int32_t
)
fwrite
(
t
,
size
,
1
,
pResultBuf
->
file
);
if
(
ret
!=
size
)
{
// todo handle the error case
if
(
ret
!=
size
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
if
(
pResultBuf
->
fileSize
<
pg
->
info
.
offset
+
pg
->
info
.
length
)
{
...
...
@@ -207,7 +215,6 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pResultBuf, SPageInfo* pg) {
pg
->
info
.
length
=
size
;
pResultBuf
->
statis
.
flushBytes
+=
pg
->
info
.
length
;
return
ret
;
}
...
...
@@ -346,6 +353,11 @@ SFilePage* getNewDataBuf(SDiskbasedBuf* pResultBuf, int32_t groupId, int32_t* pa
availablePage
=
evicOneDataPage
(
pResultBuf
);
}
// Failed to allocate a new buffer page, and there is an error occurs.
if
(
availablePage
==
NULL
&&
terrno
!=
0
)
{
return
NULL
;
}
// register new id in this group
*
pageId
=
(
++
pResultBuf
->
allocateId
);
...
...
@@ -354,7 +366,6 @@ SFilePage* getNewDataBuf(SDiskbasedBuf* pResultBuf, int32_t groupId, int32_t* pa
// add to LRU list
assert
(
listNEles
(
pResultBuf
->
lruList
)
<
pResultBuf
->
inMemPages
&&
pResultBuf
->
inMemPages
>
0
);
lruListPushFront
(
pResultBuf
->
lruList
,
pi
);
// add to hash map
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录