Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d1c7e3a5
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
d1c7e3a5
编写于
8月 04, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more last refact
上级
f84f8837
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
72 deletion
+90
-72
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+17
-12
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+16
-9
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+55
-49
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
d1c7e3a5
...
...
@@ -134,14 +134,15 @@ int32_t tGetColData(uint8_t *p, SColData *pColData);
#define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1)
#define tBlockDataFirstKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataFirstRow(PBLOCKDATA))
#define tBlockDataLastKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataLastRow(PBLOCKDATA))
int32_t
tBlockDataInit
(
SBlockData
*
pBlockData
);
void
tBlockDataReset
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
);
int32_t
tBlockDataInit
(
SBlockData
*
pBlockData
);
void
tBlockDataClear
(
SBlockData
*
pBlockData
,
int8_t
deepClear
);
void
tBlockDataReset
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
,
int64_t
suid
,
int64_t
uid
);
int32_t
tBlockDataAddColData
(
SBlockData
*
pBlockData
,
int32_t
iColData
,
SColData
**
ppColData
);
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
);
int32_t
tBlockDataCorrectSchema
(
SBlockData
*
pBlockData
,
SBlockData
*
pBlockDataFrom
);
void
tBlockDataClearData
(
SBlockData
*
pBlockData
);
void
tBlockDataClear
(
SBlockData
*
pBlockData
,
int8_t
deepClear
);
int32_t
tBlockDataAddColData
(
SBlockData
*
pBlockData
,
int32_t
iColData
,
SColData
**
ppColData
);
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tBlockDataMerge
(
SBlockData
*
pBlockData1
,
SBlockData
*
pBlockData2
,
SBlockData
*
pBlockData
);
int32_t
tBlockDataCopy
(
SBlockData
*
pBlockDataSrc
,
SBlockData
*
pBlockDataDest
);
SColData
*
tBlockDataGetColDataByIdx
(
SBlockData
*
pBlockData
,
int32_t
idx
);
...
...
@@ -468,13 +469,17 @@ struct SColData {
uint8_t
*
pData
;
};
// (SBlockData){.suid = 0, .uid = 0}: block data not initialized
// (SBlockData){.suid = suid, .uid = uid}: block data for ONE child table int .data file
// (SBlockData){.suid = suid, .uid = 0}: block data for N child tables int .last file
// (SBlockData){.suid = 0, .uid = uid}: block data for 1 normal table int .last/.data file
struct
SBlockData
{
int64_t
suid
;
// 0 means normal table data block
int64_t
uid
;
// 0 means block data in .last file, others
in .data file
int32_t
nRow
;
int64_t
*
aUid
;
int64_t
*
aVersion
;
TSKEY
*
aTSKEY
;
int64_t
suid
;
// 0 means normal table block data, otherwise child table block data
int64_t
uid
;
// 0 means block data in .last file, otherwise
in .data file
int32_t
nRow
;
// number of rows
int64_t
*
aUid
;
// uids of each row, only exist in block data in .last file (uid == 0)
int64_t
*
aVersion
;
// versions of each row
TSKEY
*
aTSKEY
;
// timestamp of each row
SArray
*
aIdx
;
// SArray<int32_t>
SArray
*
aColData
;
// SArray<SColData>
};
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
d1c7e3a5
...
...
@@ -296,22 +296,28 @@ static int32_t tsdbCommitterNextLastRow(SCommitter *pCommitter) {
ASSERT
(
pCommitter
->
dReader
.
pReader
);
ASSERT
(
pCommitter
->
dReader
.
pRowInfo
);
SBlockData
*
pBlockDatal
=
&
pCommitter
->
dReader
.
bDatal
;
pCommitter
->
dReader
.
iRow
++
;
if
(
pCommitter
->
dReader
.
iRow
<
pCommitter
->
dReader
.
bDatal
.
nRow
)
{
pCommitter
->
dReader
.
pRowInfo
->
uid
=
pCommitter
->
dReader
.
bData
.
aUid
[
pCommitter
->
dReader
.
iRow
];
pCommitter
->
dReader
.
pRowInfo
->
row
=
tsdbRowFromBlockData
(
&
pCommitter
->
dReader
.
bDatal
,
pCommitter
->
dReader
.
iRow
);
if
(
pCommitter
->
dReader
.
iRow
<
pBlockDatal
->
nRow
)
{
if
(
pBlockDatal
->
uid
==
0
)
{
pCommitter
->
dReader
.
pRowInfo
->
uid
=
pBlockDatal
->
aUid
[
pCommitter
->
dReader
.
iRow
];
}
pCommitter
->
dReader
.
pRowInfo
->
row
=
tsdbRowFromBlockData
(
pBlockDatal
,
pCommitter
->
dReader
.
iRow
);
}
else
{
pCommitter
->
dReader
.
iBlockL
++
;
if
(
pCommitter
->
dReader
.
iBlockL
<
taosArrayGetSize
(
pCommitter
->
dReader
.
aBlockL
))
{
pCommitter
->
dReader
.
pBlockL
=
(
SBlockL
*
)
taosArrayGet
(
pCommitter
->
dReader
.
aBlockL
,
pCommitter
->
dReader
.
iBlockL
);
code
=
tsdbReadLastBlock
(
pCommitter
->
dReader
.
pReader
,
pCommitter
->
dReader
.
pBlockL
,
&
pCommitter
->
dReader
.
bDatal
,
NULL
,
NULL
);
code
=
tsdbReadLastBlock
(
pCommitter
->
dReader
.
pReader
,
pCommitter
->
dReader
.
pBlockL
,
pBlockDatal
,
NULL
,
NULL
);
if
(
code
)
goto
_exit
;
pCommitter
->
dReader
.
iRow
=
0
;
pCommitter
->
dReader
.
pRowInfo
->
suid
=
pCommitter
->
dReader
.
pBlockL
->
suid
;
pCommitter
->
dReader
.
pRowInfo
->
uid
=
pCommitter
->
dReader
.
bData
.
aUid
[
pCommitter
->
dReader
.
iRow
];
pCommitter
->
dReader
.
pRowInfo
->
row
=
tsdbRowFromBlockData
(
&
pCommitter
->
dReader
.
bDatal
,
pCommitter
->
dReader
.
iRow
);
pCommitter
->
dReader
.
pRowInfo
->
suid
=
pBlockDatal
->
suid
;
if
(
pBlockDatal
->
uid
)
{
pCommitter
->
dReader
.
pRowInfo
->
uid
=
pBlockDatal
->
uid
;
}
else
{
pCommitter
->
dReader
.
pRowInfo
->
uid
=
pBlockDatal
->
aUid
[
0
];
}
pCommitter
->
dReader
.
pRowInfo
->
row
=
tsdbRowFromBlockData
(
pBlockDatal
,
pCommitter
->
dReader
.
iRow
);
}
else
{
pCommitter
->
dReader
.
pRowInfo
=
NULL
;
}
...
...
@@ -354,15 +360,16 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
}
else
{
pCommitter
->
dReader
.
pBlockIdx
=
NULL
;
}
tBlockDataReset
(
&
pCommitter
->
dReader
.
bData
);
// last
code
=
tsdbReadBlockL
(
pCommitter
->
dReader
.
pReader
,
pCommitter
->
dReader
.
aBlockL
,
NULL
);
if
(
code
)
goto
_err
;
pCommitter
->
dReader
.
iBlockL
=
-
1
;
pCommitter
->
dReader
.
bDatal
.
nRow
=
0
;
pCommitter
->
dReader
.
iRow
=
-
1
;
pCommitter
->
dReader
.
pRowInfo
=
&
pCommitter
->
dReader
.
rowInfo
;
tBlockDataReset
(
&
pCommitter
->
dReader
.
bDatal
);
code
=
tsdbCommitterNextLastRow
(
pCommitter
);
if
(
code
)
goto
_err
;
}
else
{
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
d1c7e3a5
...
...
@@ -591,8 +591,8 @@ int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx, uint8_t **ppB
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
_exit:
tFree
(
pBuf
);
_exit:
return
code
;
_err:
...
...
@@ -658,8 +658,8 @@ int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL, uint8_t **ppBuf)
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
_exit:
tFree
(
pBuf
);
_exit:
return
code
;
_err:
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
d1c7e3a5
...
...
@@ -1121,6 +1121,8 @@ static FORCE_INLINE int32_t tColDataCmprFn(const void *p1, const void *p2) {
int32_t
tBlockDataInit
(
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
pBlockData
->
suid
=
0
;
pBlockData
->
uid
=
0
;
pBlockData
->
nRow
=
0
;
pBlockData
->
aUid
=
NULL
;
pBlockData
->
aVersion
=
NULL
;
...
...
@@ -1141,36 +1143,45 @@ _exit:
return
code
;
}
void
tBlockDataReset
(
SBlockData
*
pBlockData
)
{
pBlockData
->
nRow
=
0
;
taosArrayClear
(
pBlockData
->
aIdx
);
}
void
tBlockDataClear
(
SBlockData
*
pBlockData
,
int8_t
deepClear
)
{
tFree
((
uint8_t
*
)
pBlockData
->
aUid
);
tFree
((
uint8_t
*
)
pBlockData
->
aVersion
);
tFree
((
uint8_t
*
)
pBlockData
->
aTSKEY
);
taosArrayDestroy
(
pBlockData
->
aIdx
);
taosArrayDestroyEx
(
pBlockData
->
aColData
,
deepClear
?
tColDataClear
:
NULL
);
pBlockData
->
aColData
=
NULL
;
pBlockData
->
aIdx
=
NULL
;
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
aUid
=
NULL
;
pBlockData
->
aVersion
=
NULL
;
pBlockData
->
aTSKEY
=
NULL
;
pBlockData
->
aIdx
=
NULL
;
pBlockData
->
aColData
=
NULL
;
}
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
SColData
*
pColData
;
STColumn
*
pTColumn
;
void
tBlockDataReset
(
SBlockData
*
pBlockData
)
{
pBlockData
->
suid
=
0
;
pBlockData
->
uid
=
0
;
pBlockData
->
nRow
=
0
;
taosArrayClear
(
pBlockData
->
aIdx
);
}
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
,
int64_t
suid
,
int64_t
uid
)
{
int32_t
code
=
0
;
ASSERT
(
suid
||
uid
);
tBlockDataReset
(
pBlockData
);
for
(
int32_t
iColumn
=
1
;
iColumn
<
pTSchema
->
numOfCols
;
iColumn
++
)
{
pTColumn
=
&
pTSchema
->
columns
[
iColumn
]
;
pBlockData
->
suid
=
suid
;
pBlockData
->
uid
=
uid
;
code
=
tBlockDataAddColData
(
pBlockData
,
iColumn
-
1
,
&
pColData
);
if
(
code
)
goto
_exit
;
if
(
pTSchema
)
{
for
(
int32_t
iColumn
=
1
;
iColumn
<
pTSchema
->
numOfCols
;
iColumn
++
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
SColData
*
pColData
;
code
=
tBlockDataAddColData
(
pBlockData
,
iColumn
-
1
,
&
pColData
);
if
(
code
)
goto
_exit
;
tColDataInit
(
pColData
,
pTColumn
->
colId
,
pTColumn
->
type
,
(
pTColumn
->
flags
&
COL_SMA_ON
)
!=
0
);
tColDataInit
(
pColData
,
pTColumn
->
colId
,
pTColumn
->
type
,
(
pTColumn
->
flags
&
COL_SMA_ON
)
!=
0
);
}
}
_exit:
...
...
@@ -1211,52 +1222,47 @@ _err:
return
code
;
}
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
)
{
int32_t
code
=
0
;
// TSDBKEY
ASSERT
(
pBlockData
->
suid
||
pBlockData
->
uid
);
// uid
if
(
pBlockData
->
uid
==
0
)
{
ASSERT
(
uid
);
code
=
tRealloc
((
uint8_t
**
)
&
pBlockData
->
aUid
,
sizeof
(
int64_t
)
*
(
pBlockData
->
nRow
+
1
));
if
(
code
)
goto
_err
;
pBlockData
->
aUid
[
pBlockData
->
nRow
]
=
uid
;
}
// version
code
=
tRealloc
((
uint8_t
**
)
&
pBlockData
->
aVersion
,
sizeof
(
int64_t
)
*
(
pBlockData
->
nRow
+
1
));
if
(
code
)
goto
_err
;
pBlockData
->
aVersion
[
pBlockData
->
nRow
]
=
TSDBROW_VERSION
(
pRow
);
// timestamp
code
=
tRealloc
((
uint8_t
**
)
&
pBlockData
->
aTSKEY
,
sizeof
(
TSKEY
)
*
(
pBlockData
->
nRow
+
1
));
if
(
code
)
goto
_err
;
pBlockData
->
aVersion
[
pBlockData
->
nRow
]
=
TSDBROW_VERSION
(
pRow
);
pBlockData
->
aTSKEY
[
pBlockData
->
nRow
]
=
TSDBROW_TS
(
pRow
);
// OTHER
int32_t
iColData
=
0
;
int32_t
nColData
=
taosArrayGetSize
(
pBlockData
->
aIdx
);
SRowIter
iter
=
{
0
};
SRowIter
*
pIter
=
&
iter
;
SColData
*
pColData
;
SColVal
*
pColVal
;
SRowIter
rIter
=
{
0
};
SColVal
*
pColVal
;
if
(
nColData
==
0
)
goto
_exit
;
tRowIterInit
(
pIter
,
pRow
,
pTSchema
);
pColData
=
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
);
pColVal
=
tRowIterNext
(
pIter
);
while
(
pColData
)
{
if
(
pColVal
)
{
if
(
pColData
->
cid
==
pColVal
->
cid
)
{
code
=
tColDataAppendValue
(
pColData
,
pColVal
);
if
(
code
)
goto
_err
;
tRowIterInit
(
&
rIter
,
pRow
,
pTSchema
);
pColVal
=
tRowIterNext
(
&
rIter
);
for
(
int32_t
iColData
=
0
;
iColData
<
taosArrayGetSize
(
pBlockData
->
aIdx
);
iColData
++
)
{
SColData
*
pColData
=
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
);
pColVal
=
tRowIterNext
(
pIter
);
pColData
=
((
++
iColData
)
<
nColData
)
?
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
)
:
NULL
;
}
else
if
(
pColData
->
cid
<
pColVal
->
cid
)
{
code
=
tColDataAppendValue
(
pColData
,
&
COL_VAL_NONE
(
pColData
->
cid
,
pColData
->
type
));
if
(
code
)
goto
_err
;
while
(
pColVal
&&
pColVal
->
cid
<
pColData
->
cid
)
{
pColVal
=
tRowIterNext
(
&
rIter
);
}
pColData
=
((
++
iColData
)
<
nColData
)
?
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
)
:
NULL
;
}
else
{
pColVal
=
tRowIterNext
(
pIter
);
}
}
else
{
if
(
pColVal
==
NULL
||
pColVal
->
cid
>
pColData
->
cid
)
{
code
=
tColDataAppendValue
(
pColData
,
&
COL_VAL_NONE
(
pColData
->
cid
,
pColData
->
type
));
if
(
code
)
goto
_err
;
pColData
=
((
++
iColData
)
<
nColData
)
?
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
)
:
NULL
;
}
else
{
code
=
tColDataAppendValue
(
pColData
,
pColVal
);
if
(
code
)
goto
_err
;
pColVal
=
tRowIterNext
(
&
rIter
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录