Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dfe82efc
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看板
提交
dfe82efc
编写于
9月 04, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
8ec79c9d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
34 deletion
+30
-34
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+30
-34
未找到文件。
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
dfe82efc
...
...
@@ -18,9 +18,12 @@
#define TSDB_DEFAULT_PAGE_SIZE 4096
// =============== PAGE-WISE FILE ===============
#define PAGE_CONTENT_SIZE(SIZE) ((SIZE) - sizeof(TSCKSUM))
#define PAGE_OFFSET(PGNO, SIZE) (((PGNO)-1) * (SIZE))
#define OFFSET_PGNO(OFFSET, SIZE) ((OFFSET) / (SIZE) + 1)
#define PAGE_CONTENT_SIZE(PAGE) ((PAGE) - sizeof(TSCKSUM))
#define LOGIC_TO_FILE_OFFSET(OFFSET, PAGE) \
((OFFSET) / PAGE_CONTENT_SIZE(PAGE) * (PAGE) + (OFFSET) % PAGE_CONTENT_SIZE(PAGE))
#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE)*PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE))
#define PAGE_OFFSET(PGNO, PAGE) (((PGNO)-1) * (PAGE))
#define OFFSET_PGNO(OFFSET, PAGE) ((OFFSET) / (PAGE) + 1)
static
int32_t
tsdbOpenFile
(
const
char
*
path
,
int32_t
szPage
,
int32_t
flag
,
STsdbFD
**
ppFD
)
{
int32_t
code
=
0
;
...
...
@@ -140,16 +143,17 @@ _exit:
return
code
;
}
static
int32_t
tsdbReadFile
(
STsdbFD
*
pFD
,
int64_t
offset
,
uint8_t
*
pBuf
,
int64_t
count
)
{
static
int32_t
tsdbReadFile
(
STsdbFD
*
pFD
,
int64_t
offset
,
uint8_t
*
pBuf
,
int64_t
size
)
{
int32_t
code
=
0
;
int64_t
n
;
int64_t
pgno
=
OFFSET_PGNO
(
offset
,
pFD
->
szPage
);
int64_t
fOffset
=
LOGIC_TO_FILE_OFFSET
(
offset
,
pFD
->
szPage
);
int64_t
pgno
=
OFFSET_PGNO
(
fOffset
,
pFD
->
szPage
);
int32_t
szPgCont
=
PAGE_CONTENT_SIZE
(
pFD
->
szPage
);
ASSERT
(
pgno
);
if
(
pFD
->
pgno
==
pgno
)
{
int64_t
bOff
=
o
ffset
%
pFD
->
szPage
;
int64_t
nRead
=
TMIN
(
szPgCont
-
bOff
,
count
);
int64_t
bOff
=
fO
ffset
%
pFD
->
szPage
;
int64_t
nRead
=
TMIN
(
szPgCont
-
bOff
,
size
);
ASSERT
(
bOff
<
szPgCont
);
...
...
@@ -158,11 +162,11 @@ static int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t
pgno
++
;
}
while
(
n
<
count
)
{
while
(
n
<
size
)
{
code
=
tsdbReadFilePage
(
pFD
,
pgno
);
if
(
code
)
goto
_exit
;
int64_t
nRead
=
TMIN
(
szPgCont
,
count
-
n
);
int64_t
nRead
=
TMIN
(
szPgCont
,
size
-
n
);
memcpy
(
pBuf
+
n
,
pFD
->
pBuf
,
nRead
);
n
+=
nRead
;
...
...
@@ -794,9 +798,10 @@ _err:
}
int32_t
tsdbReadBlockIdx
(
SDataFReader
*
pReader
,
SArray
*
aBlockIdx
)
{
int32_t
code
=
0
;
int64_t
offset
=
pReader
->
pSet
->
pHeadF
->
offset
;
int64_t
size
=
pReader
->
pSet
->
pHeadF
->
size
-
offset
;
// todo
int32_t
code
=
0
;
SHeadFile
*
pHeadFile
=
pReader
->
pSet
->
pHeadF
;
int64_t
offset
=
pHeadFile
->
offset
;
int64_t
size
=
pHeadFile
->
size
-
offset
;
taosArrayClear
(
aBlockIdx
);
if
(
size
==
0
)
return
code
;
...
...
@@ -810,10 +815,7 @@ int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
if
(
code
)
goto
_err
;
// decode
uint32_t
delimiter
;
int64_t
n
=
tGetU32
(
pReader
->
aBuf
[
0
],
&
delimiter
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
int64_t
n
=
0
;
while
(
n
<
size
)
{
SBlockIdx
blockIdx
;
n
+=
tGetBlockIdx
(
pReader
->
aBuf
[
0
]
+
n
,
&
blockIdx
);
...
...
@@ -833,9 +835,10 @@ _err:
}
int32_t
tsdbReadSstBlk
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SArray
*
aSstBlk
)
{
int32_t
code
=
0
;
int64_t
offset
=
pReader
->
pSet
->
aSstF
[
iSst
]
->
offset
;
int64_t
size
=
pReader
->
pSet
->
aSstF
[
iSst
]
->
size
-
offset
;
// todo
int32_t
code
=
0
;
SSstFile
*
pSstFile
=
pReader
->
pSet
->
aSstF
[
iSst
];
int64_t
offset
=
pSstFile
->
offset
;
int64_t
size
=
pSstFile
->
size
-
offset
;
taosArrayClear
(
aSstBlk
);
if
(
size
==
0
)
return
code
;
...
...
@@ -849,10 +852,7 @@ int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) {
if
(
code
)
goto
_err
;
// decode
uint32_t
delimiter
;
int64_t
n
=
tGetU32
(
pReader
->
aBuf
[
0
],
&
delimiter
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
int64_t
n
=
0
;
while
(
n
<
size
)
{
SSstBlk
sstBlk
;
n
+=
tGetSstBlk
(
pReader
->
aBuf
[
0
]
+
n
,
&
sstBlk
);
...
...
@@ -885,16 +885,12 @@ int32_t tsdbReadBlock(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mBl
if
(
code
)
goto
_err
;
// decode
uint32_t
delimiter
;
int64_t
n
=
tGetU32
(
pReader
->
aBuf
[
0
],
&
delimiter
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
int64_t
tn
=
tGetMapData
(
pReader
->
aBuf
[
0
]
+
n
,
mBlock
);
if
(
tn
<
0
)
{
int64_t
n
=
tGetMapData
(
pReader
->
aBuf
[
0
],
mBlock
);
if
(
n
<
0
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
ASSERT
(
n
+
tn
==
size
);
ASSERT
(
n
==
size
);
return
code
;
...
...
@@ -912,12 +908,11 @@ int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pDataBlk, SArray *aCol
taosArrayClear
(
aColumnDataAgg
);
// alloc
int32_t
size
=
pSmaInfo
->
size
;
code
=
tRealloc
(
&
pReader
->
aBuf
[
0
],
size
);
code
=
tRealloc
(
&
pReader
->
aBuf
[
0
],
pSmaInfo
->
size
);
if
(
code
)
goto
_err
;
// read
code
=
tsdbReadFile
(
pReader
->
pSmaFD
,
pSmaInfo
->
offset
,
pReader
->
aBuf
[
0
],
size
);
code
=
tsdbReadFile
(
pReader
->
pSmaFD
,
pSmaInfo
->
offset
,
pReader
->
aBuf
[
0
],
pSmaInfo
->
size
);
if
(
code
)
goto
_err
;
// decode
...
...
@@ -1117,7 +1112,8 @@ int32_t tsdbReadSstBlockEx(SDataFReader *pReader, int32_t iSst, SSstBlk *pSstBlk
int32_t
code
=
0
;
// read
tsdbReadFile
(
pReader
->
aSstFD
[
iSst
],
pSstBlk
->
bInfo
.
offset
,
pReader
->
aBuf
[
0
],
pSstBlk
->
bInfo
.
szBlock
);
code
=
tsdbReadFile
(
pReader
->
aSstFD
[
iSst
],
pSstBlk
->
bInfo
.
offset
,
pReader
->
aBuf
[
0
],
pSstBlk
->
bInfo
.
szBlock
);
if
(
code
)
goto
_exit
;
// decmpr
code
=
tDecmprBlockData
(
pReader
->
aBuf
[
0
],
pSstBlk
->
bInfo
.
szBlock
,
pBlockData
,
&
pReader
->
aBuf
[
1
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录