Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2a41f1d3
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看板
提交
2a41f1d3
编写于
6月 27, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
6140856e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
150 addition
and
10 deletion
+150
-10
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+8
-6
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+37
-4
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+105
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
2a41f1d3
...
...
@@ -86,8 +86,8 @@ typedef struct STsdbFSState STsdbFSState;
#define TSDBROW_VERSION(ROW) (((ROW)->type == 0) ? (ROW)->version : (ROW)->pBlockData->aVersion[(ROW)->iRow])
#define TSDBROW_SVERSION(ROW) TD_ROW_SVER((ROW)->pTSRow)
#define TSDBROW_KEY(ROW) ((TSDBKEY){.version = TSDBROW_VERSION(ROW), .ts = TSDBROW_TS(ROW)})
#define tsdbRowFromTSRow(VERSION, TSROW) ((TSDBROW){.type = 0, .version = (VERSION), .pTSRow = (TSROW)})
;
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
;
#define tsdbRowFromTSRow(VERSION, TSROW) ((TSDBROW){.type = 0, .version = (VERSION), .pTSRow = (TSROW)})
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
void
tsdbRowGetColVal
(
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
int32_t
tPutTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
);
int32_t
tGetTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
);
...
...
@@ -132,6 +132,7 @@ int32_t tCmprBlockIdx(void const *lhs, void const *rhs);
void
tColDataReset
(
SColData
*
pColData
,
int16_t
cid
,
int8_t
type
);
void
tColDataClear
(
void
*
ph
);
int32_t
tColDataAppendValue
(
SColData
*
pColData
,
SColVal
*
pColVal
);
int32_t
tColDataCopy
(
SColData
*
pColDataSrc
,
SColData
*
pColDataDest
);
int32_t
tColDataGetValue
(
SColData
*
pColData
,
int32_t
iRow
,
SColVal
*
pColVal
);
int32_t
tColDataPCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
// SBlockData
...
...
@@ -142,6 +143,8 @@ void tBlockDataReset(SBlockData *pBlockData);
void
tBlockDataClear
(
SBlockData
*
pBlockData
);
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
);
// SDelIdx
int32_t
tPutDelIdx
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetDelIdx
(
uint8_t
*
p
,
void
*
ph
);
...
...
@@ -374,9 +377,9 @@ typedef struct {
int64_t
nRow
;
int8_t
cmprAlg
;
int64_t
offset
;
int64_t
vsize
;
// VERSION size
int64_t
ksize
;
// TSKEY size
int64_t
bsize
;
int64_t
vsize
;
// VERSION size
int64_t
ksize
;
// TSKEY size
int64_t
bsize
;
// total block size
SMapData
mBlockCol
;
// SMapData<SBlockCol>
}
SSubBlock
;
...
...
@@ -412,7 +415,6 @@ struct SColData {
int32_t
*
aOffset
;
int32_t
nData
;
uint8_t
*
pData
;
uint8_t
*
pBuf
;
};
struct
SBlockData
{
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
2a41f1d3
...
...
@@ -607,7 +607,9 @@ static int32_t tsdbReadSubBlockData(SDataFReader *pReader, SBlockIdx *pBlockIdx,
int64_t
n
;
TdFilePtr
pFD
=
pBlock
->
last
?
pReader
->
pLastFD
:
pReader
->
pDataFD
;
SSubBlock
*
pSubBlock
=
&
pBlock
->
aSubBlock
[
iSubBlock
];
SBlockCol
*
pBlockCol
=
&
(
SBlockCol
){};
SBlockCol
*
pBlockCol
=
&
(
SBlockCol
){
0
};
tBlockDataReset
(
pBlockData
);
// realloc
code
=
tsdbRealloc
(
ppBuf1
,
pSubBlock
->
bsize
);
...
...
@@ -789,11 +791,42 @@ int32_t tsdbReadBlockData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *p
if
(
code
)
goto
_err
;
// read remain block data and do merg
iSubBlock
++
;
for
(;
iSubBlock
<
pBlock
->
nSubBlock
;
iSubBlock
++
)
{
ASSERT
(
0
);
if
(
pBlock
->
nSubBlock
>
1
)
{
SBlockData
*
pBlockData1
=
&
(
SBlockData
){
0
};
SBlockData
*
pBlockData2
=
&
(
SBlockData
){
0
};
for
(
iSubBlock
=
1
;
iSubBlock
<
pBlock
->
nSubBlock
;
iSubBlock
++
)
{
code
=
tsdbReadSubBlockData
(
pReader
,
pBlockIdx
,
pBlock
,
iSubBlock
,
pBlockData
,
ppBuf1
,
ppBuf2
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
goto
_err
;
}
code
=
tBlockDataCopy
(
pBlockData
,
pBlockData2
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
goto
_err
;
}
// merge two block data
code
=
tBlockDataMerge
(
pBlockData1
,
pBlockData2
,
pBlockData
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
goto
_err
;
}
}
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
}
ASSERT
(
pBlock
->
nRow
==
pBlockData
->
nRow
);
ASSERT
(
tsdbKeyCmprFn
(
&
pBlock
->
minKey
,
&
TSDBROW_KEY
(
&
tBlockDataFirstRow
(
pBlockData
)))
==
0
);
ASSERT
(
tsdbKeyCmprFn
(
&
pBlock
->
maxKey
,
&
TSDBROW_KEY
(
&
tBlockDataLastRow
(
pBlockData
)))
==
0
);
if
(
pBuf1
)
tsdbFree
(
pBuf1
);
if
(
pBuf2
)
tsdbFree
(
pBuf2
);
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
2a41f1d3
...
...
@@ -939,6 +939,29 @@ _exit:
return
code
;
}
int32_t
tColDataCopy
(
SColData
*
pColDataSrc
,
SColData
*
pColDataDest
)
{
int32_t
code
=
0
;
pColDataDest
->
cid
=
pColDataDest
->
cid
;
pColDataDest
->
type
=
pColDataDest
->
type
;
pColDataDest
->
offsetValid
=
0
;
pColDataDest
->
nVal
=
pColDataSrc
->
nVal
;
pColDataDest
->
flag
=
pColDataSrc
->
flag
;
if
(
pColDataSrc
->
flag
!=
HAS_NONE
&&
pColDataSrc
->
flag
!=
HAS_NULL
&&
pColDataSrc
->
flag
!=
HAS_VALUE
)
{
code
=
tsdbRealloc
(
&
pColDataDest
->
pBitMap
,
BIT2_SIZE
(
pColDataDest
->
nVal
));
if
(
code
)
goto
_exit
;
memcpy
(
pColDataDest
->
pBitMap
,
pColDataSrc
->
pBitMap
,
BIT2_SIZE
(
pColDataSrc
->
nVal
));
}
pColDataDest
->
nData
=
pColDataSrc
->
nData
;
code
=
tsdbRealloc
(
&
pColDataDest
->
pData
,
pColDataSrc
->
nData
);
if
(
code
)
goto
_exit
;
memcpy
(
pColDataDest
->
pData
,
pColDataSrc
->
pData
,
pColDataSrc
->
nData
);
_exit:
return
code
;
}
static
int32_t
tColDataUpdateOffset
(
SColData
*
pColData
)
{
int32_t
code
=
0
;
SValue
value
;
...
...
@@ -1169,3 +1192,85 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
_err:
return
code
;
}
int32_t
tBlockDataMerge
(
SBlockData
*
pBlockData1
,
SBlockData
*
pBlockData2
,
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
tBlockDataReset
(
pBlockData
);
// loop to merge
int32_t
iRow1
=
0
;
int32_t
nRow1
=
pBlockData1
->
nRow
;
int32_t
iRow2
=
0
;
int32_t
nRow2
=
pBlockData2
->
nRow
;
TSDBROW
row1
;
TSDBROW
row2
;
int32_t
c
;
while
(
iRow1
<
nRow1
&&
iRow2
<
nRow2
)
{
row1
=
tsdbRowFromBlockData
(
pBlockData1
,
iRow1
);
row2
=
tsdbRowFromBlockData
(
pBlockData2
,
iRow2
);
c
=
tsdbKeyCmprFn
(
&
TSDBROW_KEY
(
&
row1
),
&
TSDBROW_KEY
(
&
row2
));
if
(
c
<
0
)
{
code
=
tBlockDataAppendRow
(
pBlockData
,
&
row1
,
NULL
);
if
(
code
)
goto
_exit
;
iRow1
++
;
}
else
if
(
c
>
0
)
{
code
=
tBlockDataAppendRow
(
pBlockData
,
&
row2
,
NULL
);
if
(
code
)
goto
_exit
;
iRow2
++
;
}
else
{
ASSERT
(
0
);
}
}
while
(
iRow1
<
nRow1
)
{
row1
=
tsdbRowFromBlockData
(
pBlockData1
,
iRow1
);
code
=
tBlockDataAppendRow
(
pBlockData
,
&
row1
,
NULL
);
if
(
code
)
goto
_exit
;
iRow1
++
;
}
while
(
iRow2
<
nRow2
)
{
row2
=
tsdbRowFromBlockData
(
pBlockData2
,
iRow2
);
code
=
tBlockDataAppendRow
(
pBlockData
,
&
row2
,
NULL
);
if
(
code
)
goto
_exit
;
iRow2
++
;
}
_exit:
return
code
;
}
int32_t
tBlockDataCopy
(
SBlockData
*
pBlockDataSrc
,
SBlockData
*
pBlockDataDest
)
{
int32_t
code
=
0
;
SColData
*
pColDataSrc
;
SColData
*
pColDataDest
;
ASSERT
(
pBlockDataSrc
->
nRow
>
0
);
tBlockDataReset
(
pBlockDataDest
);
pBlockDataDest
->
nRow
=
pBlockDataSrc
->
nRow
;
// TSDBKEY
code
=
tsdbRealloc
((
uint8_t
**
)
&
pBlockDataDest
->
aVersion
,
sizeof
(
int64_t
)
*
pBlockDataSrc
->
nRow
);
if
(
code
)
goto
_exit
;
code
=
tsdbRealloc
((
uint8_t
**
)
&
pBlockDataDest
->
aTSKEY
,
sizeof
(
TSKEY
)
*
pBlockDataSrc
->
nRow
);
if
(
code
)
goto
_exit
;
memcpy
(
pBlockDataDest
->
aVersion
,
pBlockDataSrc
->
aVersion
,
sizeof
(
int64_t
)
*
pBlockDataSrc
->
nRow
);
memcpy
(
pBlockDataDest
->
aTSKEY
,
pBlockDataSrc
->
aTSKEY
,
sizeof
(
TSKEY
)
*
pBlockDataSrc
->
nRow
);
// other
for
(
size_t
iColData
=
0
;
iColData
<
taosArrayGetSize
(
pBlockDataSrc
->
aColDataP
);
iColData
++
)
{
pColDataSrc
=
(
SColData
*
)
taosArrayGetP
(
pBlockDataSrc
->
aColDataP
,
iColData
);
code
=
tBlockDataAddColData
(
pBlockDataDest
,
iColData
,
&
pColDataDest
);
if
(
code
)
goto
_exit
;
code
=
tColDataCopy
(
pColDataSrc
,
pColDataDest
);
if
(
code
)
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录