Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3698016a
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3698016a
编写于
8月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
94069ec2
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
50 deletion
+38
-50
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
+37
-50
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
3698016a
...
...
@@ -603,6 +603,7 @@ struct SDataFWriter {
uint8_t
*
pBuf1
;
uint8_t
*
pBuf2
;
uint8_t
*
pBuf3
;
uint8_t
*
pBuf4
;
};
struct
STsdbReadSnap
{
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
3698016a
...
...
@@ -1596,6 +1596,7 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) {
tFree
((
*
ppWriter
)
->
pBuf1
);
tFree
((
*
ppWriter
)
->
pBuf2
);
tFree
((
*
ppWriter
)
->
pBuf3
);
tFree
((
*
ppWriter
)
->
pBuf4
);
taosMemoryFree
(
*
ppWriter
);
_exit:
*
ppWriter
=
NULL
;
...
...
@@ -1919,14 +1920,8 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
.
nRow
=
pBlockData
->
nRow
,
.
cmprAlg
=
cmprAlg
};
SArray
*
aBlockCol
=
taosArrayInit
(
taosArrayGetSize
(
pBlockData
->
aIdx
),
sizeof
(
SBlockCol
));
if
(
aBlockCol
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
// encode =================
// columns
// columns
AND SBlockCol
int32_t
nBuf1
=
0
;
for
(
int32_t
iColData
=
0
;
iColData
<
taosArrayGetSize
(
pBlockData
->
aIdx
);
iColData
++
)
{
SColData
*
pColData
=
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
);
...
...
@@ -1949,89 +1944,83 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
nBuf1
=
nBuf1
+
blockCol
.
szBitmap
+
blockCol
.
szOffset
+
blockCol
.
szValue
+
sizeof
(
TSCKSUM
);
}
if
(
taosArrayPush
(
aBlockCol
,
&
blockCol
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
code
=
tRealloc
(
&
pWriter
->
pBuf2
,
hdr
.
szBlkCol
+
tPutBlockCol
(
NULL
,
&
blockCol
));
if
(
code
)
goto
_err
;
hdr
.
szBlkCol
+=
tPutBlockCol
(
pWriter
->
pBuf2
+
hdr
.
szBlkCol
,
&
blockCol
)
;
}
hdr
.
szBlkCol
+=
tPutBlockCol
(
NULL
,
&
blockCol
);
int32_t
nBuf2
=
0
;
if
(
hdr
.
szBlkCol
>
0
)
{
nBuf2
=
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
);
code
=
tRealloc
(
&
pWriter
->
pBuf2
,
nBuf2
);
if
(
code
)
goto
_err
;
taosCalcChecksumAppend
(
0
,
pWriter
->
pBuf2
,
nBuf2
);
}
// uid
// uid + version + tskey
int32_t
nBuf3
=
0
;
if
(
pBlockData
->
uid
==
0
)
{
code
=
tsdbCmprData
((
uint8_t
*
)
pBlockData
->
aUid
,
sizeof
(
int64_t
)
*
pBlockData
->
nRow
,
TSDB_DATA_TYPE_BIGINT
,
cmprAlg
,
&
pWriter
->
pBuf
2
,
0
,
&
hdr
.
szUid
,
&
pWriter
->
pBuf3
);
&
pWriter
->
pBuf
3
,
nBuf3
,
&
hdr
.
szUid
,
&
pWriter
->
pBuf4
);
if
(
code
)
goto
_err
;
}
nBuf3
+=
hdr
.
szUid
;
// version
code
=
tsdbCmprData
((
uint8_t
*
)
pBlockData
->
aVersion
,
sizeof
(
int64_t
)
*
pBlockData
->
nRow
,
TSDB_DATA_TYPE_BIGINT
,
cmprAlg
,
&
pWriter
->
pBuf
2
,
hdr
.
szUid
,
&
hdr
.
szVer
,
&
pWriter
->
pBuf3
);
cmprAlg
,
&
pWriter
->
pBuf
3
,
nBuf3
,
&
hdr
.
szVer
,
&
pWriter
->
pBuf4
);
if
(
code
)
goto
_err
;
nBuf3
+=
hdr
.
szVer
;
// tskey
code
=
tsdbCmprData
((
uint8_t
*
)
pBlockData
->
aTSKEY
,
sizeof
(
TSKEY
)
*
pBlockData
->
nRow
,
TSDB_DATA_TYPE_TIMESTAMP
,
cmprAlg
,
&
pWriter
->
pBuf
2
,
hdr
.
szUid
+
hdr
.
szVer
,
&
hdr
.
szKey
,
&
pWriter
->
pBuf3
);
cmprAlg
,
&
pWriter
->
pBuf
3
,
nBuf3
,
&
hdr
.
szKey
,
&
pWriter
->
pBuf4
);
if
(
code
)
goto
_err
;
nBuf3
+=
hdr
.
szKey
;
// hdr
pBlkInfo
->
szKey
=
tPutDiskDataHdr
(
NULL
,
&
hdr
);
code
=
tRealloc
(
&
pWriter
->
pBuf3
,
pBlkInfo
->
szKey
);
nBuf3
+=
sizeof
(
TSCKSUM
);
code
=
tRealloc
(
&
pWriter
->
pBuf3
,
nBuf3
);
if
(
code
)
goto
_err
;
tPutDiskDataHdr
(
pWriter
->
pBuf3
,
&
hdr
);
TSCKSUM
cksm
=
taosCalcChecksum
(
0
,
pWriter
->
pBuf3
,
pBlkInfo
->
szKey
);
code
=
tRealloc
(
&
pWriter
->
pBuf2
,
hdr
.
szUid
+
hdr
.
szVer
+
hdr
.
szKey
+
sizeof
(
TSCKSUM
));
// hdr
int32_t
nBuf4
=
tPutDiskDataHdr
(
NULL
,
&
hdr
);
code
=
tRealloc
(
&
pWriter
->
pBuf4
,
nBuf4
);
if
(
code
)
goto
_err
;
taosCalcChecksumAppend
(
cksm
,
pWriter
->
pBuf2
,
hdr
.
szUid
+
hdr
.
szVer
+
hdr
.
szKey
+
sizeof
(
TSCKSUM
));
tPutDiskDataHdr
(
pWriter
->
pBuf4
,
&
hdr
);
taosCalcChecksumAppend
(
taosCalcChecksum
(
0
,
pWriter
->
pBuf4
,
nBuf4
),
pWriter
->
pBuf3
,
nBuf3
);
// write =================
TdFilePtr
pFD
=
toLast
?
pWriter
->
pLastFD
:
pWriter
->
pDataFD
;
// hdr
int64_t
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf3
,
pBlkInfo
->
szKey
);
pBlkInfo
->
szKey
=
nBuf4
+
nBuf3
;
pBlkInfo
->
szBlock
=
nBuf1
+
nBuf2
+
nBuf3
+
nBuf4
;
int64_t
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf4
,
nBuf4
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
// uid + version + tskey + (CKSM)
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf2
,
hdr
.
szUid
+
hdr
.
szVer
+
hdr
.
szKey
+
sizeof
(
TSCKSUM
));
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf3
,
nBuf3
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
pBlkInfo
->
szKey
=
pBlkInfo
->
szKey
+
hdr
.
szUid
+
hdr
.
szVer
+
hdr
.
szKey
+
sizeof
(
TSCKSUM
);
pBlkInfo
->
szBlock
+=
pBlkInfo
->
szKey
;
// aBlockCol
if
(
hdr
.
szBlkCol
>
0
)
{
code
=
tRealloc
(
&
pWriter
->
pBuf2
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
));
if
(
code
)
goto
_err
;
n
=
0
;
for
(
int32_t
iBlockCol
=
0
;
iBlockCol
<
taosArrayGetSize
(
aBlockCol
);
iBlockCol
++
)
{
n
+=
tPutBlockCol
(
pWriter
->
pBuf2
+
n
,
taosArrayGet
(
aBlockCol
,
iBlockCol
));
}
ASSERT
(
n
==
hdr
.
szBlkCol
);
taosCalcChecksumAppend
(
0
,
pWriter
->
pBuf2
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
));
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf2
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
));
if
(
nBuf2
)
{
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf2
,
nBuf2
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
}
// colmns
if
(
nBuf1
>
0
)
{
if
(
nBuf1
)
{
n
=
taosWriteFile
(
pFD
,
pWriter
->
pBuf1
,
nBuf1
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
pBlkInfo
->
szBlock
+=
nBuf1
;
}
// update info
...
...
@@ -2048,12 +2037,10 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
}
_exit:
taosArrayDestroy
(
aBlockCol
);
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb write block data failed since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
taosArrayDestroy
(
aBlockCol
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录