Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7671bfe1
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看板
提交
7671bfe1
编写于
8月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refact
上级
71691eb7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
49 deletion
+67
-49
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+32
-49
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+34
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
7671bfe1
...
...
@@ -188,6 +188,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
uint8_t
**
ppBuf
);
int32_t
tsdbDecmprColData
(
uint8_t
*
pIn
,
SBlockCol
*
pBlockCol
,
int8_t
cmprAlg
,
int32_t
nVal
,
SColData
*
pColData
,
uint8_t
**
ppBuf
);
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
);
// tsdbMemTable ==============================================================================================
// SMemTable
int32_t
tsdbMemTableCreate
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTable
);
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
7671bfe1
...
...
@@ -401,6 +401,7 @@ struct SDataFReader {
uint8_t
*
pBuf1
;
uint8_t
*
pBuf2
;
uint8_t
*
pBuf3
;
};
int32_t
tsdbDataFReaderOpen
(
SDataFReader
**
ppReader
,
STsdb
*
pTsdb
,
SDFileSet
*
pSet
)
{
...
...
@@ -485,6 +486,7 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
tFree
((
*
ppReader
)
->
pBuf1
);
tFree
((
*
ppReader
)
->
pBuf2
);
tFree
((
*
ppReader
)
->
pBuf3
);
taosMemoryFree
(
*
ppReader
);
_exit:
...
...
@@ -729,94 +731,75 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
int32_t
nColId
,
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
// TODO
tBlockDataReset
(
pBlockData
);
TdFilePtr
pFD
=
fromLast
?
pReader
->
pLastFD
:
pReader
->
pDataFD
;
// seek
int64_t
n
=
taosLSeekFile
(
pFD
,
pBlkInfo
->
offset
,
SEEK_SET
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
// read
code
=
tRealloc
(
&
pReader
->
pBuf1
,
pBlkInfo
->
szBlock
);
// uid + version + tskey
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
,
&
pReader
->
pBuf1
,
pBlkInfo
->
szKey
);
if
(
code
)
goto
_err
;
n
=
taosReadFile
(
pFD
,
pReader
->
pBuf1
,
pBlkInfo
->
szBlock
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
else
if
(
n
<
pBlkInfo
->
szBlock
)
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
}
uint8_t
*
p
=
pReader
->
pBuf1
;
// check & decode
SDiskDataHdr
hdr
;
if
(
!
taosCheckChecksumWhole
(
p
,
pBlkInfo
->
szKey
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
}
p
+=
tGetDiskDataHdr
(
p
,
&
hdr
);
uint8_t
*
p
=
pReader
->
pBuf1
+
tGetDiskDataHdr
(
pReader
->
pBuf1
,
&
hdr
);
ASSERT
(
hdr
.
delimiter
==
TSDB_FILE_DLMT
);
ASSERT
(
hdr
.
suid
||
hdr
.
uid
);
tBlockDataSetSchema
(
pBlockData
,
NULL
,
hdr
.
suid
,
hdr
.
uid
);
pBlockData
->
suid
=
hdr
.
suid
;
pBlockData
->
uid
=
hdr
.
uid
;
pBlockData
->
nRow
=
hdr
.
nRow
;
// uid
if
(
hdr
.
uid
==
0
)
{
ASSERT
(
hdr
.
szUid
);
code
=
tsdbDecmprData
(
p
,
hdr
.
szUid
,
TSDB_DATA_TYPE_BIGINT
,
hdr
.
cmprAlg
,
(
uint8_t
**
)
&
pBlockData
->
aUid
,
sizeof
(
int64_t
)
*
hdr
.
nRow
,
&
pReader
->
pBuf2
);
if
(
code
)
goto
_err
;
}
else
{
ASSERT
(
hdr
.
szUid
==
0
);
ASSERT
(
!
hdr
.
szUid
);
}
p
+=
hdr
.
szUid
;
// version
code
=
tsdbDecmprData
(
p
,
hdr
.
szVer
,
TSDB_DATA_TYPE_BIGINT
,
hdr
.
cmprAlg
,
(
uint8_t
**
)
&
pBlockData
->
aVersion
,
sizeof
(
int64_t
)
*
hdr
.
nRow
,
&
pReader
->
pBuf2
);
if
(
code
)
goto
_err
;
p
+=
hdr
.
szVer
;
code
=
tsdbDecmprData
(
p
,
hdr
.
szKey
,
TSDB_DATA_TYPE_BIGINT
,
hdr
.
cmprAlg
,
(
uint8_t
**
)
&
pBlockData
->
aTSKEY
,
// TSKEY
code
=
tsdbDecmprData
(
p
,
hdr
.
szKey
,
TSDB_DATA_TYPE_TIMESTAMP
,
hdr
.
cmprAlg
,
(
uint8_t
**
)
&
pBlockData
->
aTSKEY
,
sizeof
(
TSKEY
)
*
hdr
.
nRow
,
&
pReader
->
pBuf2
);
if
(
code
)
goto
_err
;
p
+=
hdr
.
szKey
;
p
+=
sizeof
(
TSCKSUM
);
// SBlockCol
ASSERT
(
p
-
pReader
->
pBuf1
==
sizeof
(
TSCKSUM
));
// read and decode columns
if
(
hdr
.
szBlkCol
>
0
)
{
if
(
!
taosCheckChecksumWhole
(
p
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
)))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
}
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
+
pBlkInfo
->
szKey
,
&
pReader
->
pBuf1
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
));
if
(
code
)
goto
_err
;
int32_t
iColData
=
0
;
uint8_t
*
pt
=
p
+
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
);
n
=
0
;
int32_t
n
=
0
;
while
(
n
<
hdr
.
szBlkCol
)
{
SBlockCol
blockCol
;
n
+=
tGetBlockCol
(
p
+
n
,
&
blockCol
);
n
+=
tGetBlockCol
(
p
Reader
->
pBuf1
+
n
,
&
blockCol
);
ASSERT
(
blockCol
.
flag
&&
blockCol
.
flag
!=
HAS_NONE
);
SColData
*
pColData
;
code
=
tBlockDataAddColData
(
pBlockData
,
iColData
,
&
pColData
);
if
(
code
)
goto
_err
;
iColData
++
;
// TODO: merge with the column IDs
tColDataInit
(
pColData
,
blockCol
.
cid
,
blockCol
.
type
,
blockCol
.
smaOn
);
SColData
*
pColData
=
NULL
;
// (todo)
if
(
blockCol
.
flag
==
HAS_NULL
)
{
for
(
int32_t
iRow
=
0
;
iRow
<
pBlockData
->
nRow
;
iRow
++
)
{
code
=
tColDataAppendValue
(
pColData
,
&
COL_VAL_NULL
(
blockCol
.
cid
,
blockCol
.
type
));
if
(
code
)
goto
_err
;
}
// TODO: make a hdr.nRow COL_VAL_NULL();
}
else
{
code
=
tsdbDecmprColData
(
pt
+
blockCol
.
offset
,
&
blockCol
,
hdr
.
cmprAlg
,
hdr
.
nRow
,
pColData
,
&
pReader
->
pBuf2
);
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
+
pBlkInfo
->
szKey
+
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
)
+
blockCol
.
offset
,
&
pReader
->
pBuf2
,
blockCol
.
szBitmap
+
blockCol
.
szOffset
+
blockCol
.
szValue
+
sizeof
(
TSCKSUM
));
code
=
tsdbDecmprColData
(
pReader
->
pBuf2
,
&
blockCol
,
hdr
.
cmprAlg
,
hdr
.
nRow
,
pColData
,
&
pReader
->
pBuf3
);
if
(
code
)
goto
_err
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
7671bfe1
...
...
@@ -1865,6 +1865,40 @@ int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, in
}
p
+=
pBlockCol
->
szValue
;
_exit:
return
code
;
}
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
)
{
int32_t
code
=
0
;
// alloc
code
=
tRealloc
(
ppOut
,
size
);
if
(
code
)
goto
_exit
;
// seek
int64_t
n
=
taosLSeekFile
(
pFD
,
offset
,
SEEK_SET
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
// read
n
=
taosReadFile
(
pFD
,
*
ppOut
,
size
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
else
if
(
n
<
size
)
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_exit
;
}
// check
if
(
!
taosCheckChecksumWhole
(
*
ppOut
,
size
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_exit
;
}
_exit:
return
code
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录