Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3278c114
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看板
提交
3278c114
编写于
12月 22, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
78e3a0e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
112 addition
and
5 deletion
+112
-5
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-0
source/dnode/vnode/src/tsdb/tsdbCompact.c
source/dnode/vnode/src/tsdb/tsdbCompact.c
+97
-4
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+0
-1
source/dnode/vnode/src/vnd/vnodeCompact.c
source/dnode/vnode/src/vnd/vnodeCompact.c
+13
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
3278c114
...
...
@@ -801,6 +801,8 @@ static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
return
pIter
->
pRow
;
}
int32_t
tRowInfoCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/tsdb/tsdbCompact.c
浏览文件 @
3278c114
...
...
@@ -38,9 +38,10 @@ typedef struct {
}
SSttDIter
;
typedef
struct
{
int32_t
flag
;
SRowInfo
rowInfo
;
char
handle
[];
int32_t
flag
;
SRowInfo
rowInfo
;
SRBTreeNode
n
;
char
handle
[];
}
STsdbDataIter
;
typedef
struct
{
...
...
@@ -56,6 +57,13 @@ typedef struct {
#define TSDB_FLG_DEEP_COMPACT 0x1
// ITER =========================
static
int32_t
tsdbDataIterCmprFn
(
const
SRBTreeNode
*
n1
,
const
SRBTreeNode
*
n2
)
{
const
STsdbDataIter
*
pIter1
=
(
STsdbDataIter
*
)((
char
*
)
n1
-
offsetof
(
STsdbDataIter
,
n
));
const
STsdbDataIter
*
pIter2
=
(
STsdbDataIter
*
)((
char
*
)
n2
-
offsetof
(
STsdbDataIter
,
n
));
return
tRowInfoCmprFn
(
&
pIter1
->
rowInfo
,
&
pIter2
->
rowInfo
);
}
static
int32_t
tsdbMemDIterOpen
(
STsdbDataIter
**
ppIter
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -87,18 +95,52 @@ static int32_t tsdbDataDIterOpen(SDataFReader *pReader, STsdbDataIter **ppIter)
goto
_exit
;
}
SDataDIter
*
pDataDIter
=
(
SDataDIter
*
)
pIter
->
handle
;
pDataDIter
->
pReader
=
pReader
;
pDataDIter
->
aBlockIdx
=
taosArrayInit
(
0
,
sizeof
(
SBlockIdx
));
if
(
pDataDIter
->
aBlockIdx
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
code
=
tsdbReadBlockIdx
(
pReader
,
pDataDIter
->
aBlockIdx
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
taosArrayGetSize
(
pDataDIter
->
aBlockIdx
)
==
0
)
goto
_clear_exit
;
code
=
tBlockDataCreate
(
&
pDataDIter
->
bData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// read first data block
pDataDIter
->
iBlockIdx
=
0
;
code
=
tsdbReadDataBlk
(
pReader
,
taosArrayGet
(
pDataDIter
->
aBlockIdx
,
pDataDIter
->
iBlockIdx
),
&
pDataDIter
->
mDataBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pDataDIter
->
iDataBlk
=
0
;
// code = tsdbReadDataBlock(pReader, tMapDat);
// TSDB_CHECK_CODE(code, lino, _exit);
pDataDIter
->
iRow
=
0
;
// TODO
_exit:
if
(
code
)
{
_clear_exit:
*
ppIter
=
NULL
;
if
(
pIter
)
{
tBlockDataDestroy
(
&
pDataDIter
->
bData
,
1
);
tMapDataClear
(
&
pDataDIter
->
mDataBlk
);
taosArrayDestroy
(
pDataDIter
->
aBlockIdx
);
taosMemoryFree
(
pIter
);
}
}
else
{
*
ppIter
=
pIter
;
}
return
code
;
}
static
int32_t
tsdbSttDIterOpen
(
SDataFReader
*
pReader
,
STsdbDataIter
**
ppIter
)
{
static
int32_t
tsdbSttDIterOpen
(
SDataFReader
*
pReader
,
int32_t
iStt
,
STsdbDataIter
**
ppIter
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -108,11 +150,40 @@ static int32_t tsdbSttDIterOpen(SDataFReader *pReader, STsdbDataIter **ppIter) {
goto
_exit
;
}
SSttDIter
*
pSttDIter
=
(
SSttDIter
*
)
pIter
->
handle
;
pSttDIter
->
pReader
=
pReader
;
pSttDIter
->
iStt
=
iStt
;
pSttDIter
->
aSttBlk
=
taosArrayInit
(
0
,
sizeof
(
SSttBlk
));
if
(
pSttDIter
->
aSttBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
code
=
tsdbReadSttBlk
(
pReader
,
pSttDIter
->
iStt
,
pSttDIter
->
aSttBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
taosArrayGetSize
(
pSttDIter
->
aSttBlk
)
==
0
)
goto
_clear_exit
;
code
=
tBlockDataCreate
(
&
pSttDIter
->
bData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pSttDIter
->
iSttBlk
=
0
;
// code = tsdbReadSttBlock(pReader, taosArrayGet(pSttDIter->aSttBlk, pSttDIter->iSttBlk), &pSttDIter->bData);
// TSDB_CHECK_CODE(code, lino, _exit);
pSttDIter
->
iRow
=
0
;
// TODO
_exit:
if
(
code
)
{
_clear_exit:
*
ppIter
=
NULL
;
if
(
pIter
)
{
tBlockDataDestroy
(
&
pSttDIter
->
bData
,
1
);
taosArrayDestroy
(
pSttDIter
->
aSttBlk
);
taosMemoryFree
(
pIter
);
}
}
else
{
*
ppIter
=
pIter
;
}
...
...
@@ -227,6 +298,27 @@ int32_t tsdbCompact(STsdb *pTsdb, int32_t flag) {
compactor
.
fid
=
compactor
.
pDFileSet
->
fid
;
code
=
tsdbDataFReaderOpen
(
&
compactor
.
pReader
,
pTsdb
,
compactor
.
pDFileSet
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// open those iterators
tRBTreeCreate
(
&
compactor
.
rtree
,
tsdbDataIterCmprFn
);
STsdbDataIter
*
pIter
;
code
=
tsdbDataDIterOpen
(
compactor
.
pReader
,
&
pIter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pIter
)
tRBTreePut
(
&
compactor
.
rtree
,
&
pIter
->
n
);
for
(
int32_t
iStt
=
0
;
iStt
<
compactor
.
pReader
->
pSet
->
nSttF
;
iStt
++
)
{
code
=
tsdbSttDIterOpen
(
compactor
.
pReader
,
iStt
,
&
pIter
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
pIter
)
tRBTreePut
(
&
compactor
.
rtree
,
&
pIter
->
n
);
}
#if 0
if (flag & TSDB_FLG_DEEP_COMPACT) {
code = tsdbDeepCompact(&compactor);
TSDB_CHECK_CODE(code, lino, _exit);
...
...
@@ -234,6 +326,7 @@ int32_t tsdbCompact(STsdb *pTsdb, int32_t flag) {
code = tsdbShallowCompact(&compactor);
TSDB_CHECK_CODE(code, lino, _exit);
}
#endif
}
_exit:
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
3278c114
...
...
@@ -63,7 +63,6 @@ struct STsdbSnapReader {
uint8_t
*
aBuf
[
5
];
};
extern
int32_t
tRowInfoCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
extern
int32_t
tsdbReadDataBlockEx
(
SDataFReader
*
pReader
,
SDataBlk
*
pDataBlk
,
SBlockData
*
pBlockData
);
extern
int32_t
tsdbUpdateTableSchema
(
SMeta
*
pMeta
,
int64_t
suid
,
int64_t
uid
,
SSkmInfo
*
pSkmInfo
);
...
...
source/dnode/vnode/src/vnd/vnodeCompact.c
浏览文件 @
3278c114
...
...
@@ -15,13 +15,26 @@
#include "vnd.h"
extern
int32_t
tsdbCompact
(
STsdb
*
pTsdb
,
int32_t
flag
);
extern
void
vnodePrepareCommit
(
SVnode
*
pVnode
);
static
int32_t
vnodeCompactImpl
(
SCommitInfo
*
pInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
SVnode
*
pVnode
=
pInfo
->
pVnode
;
code
=
tsdbCompact
(
pVnode
->
pTsdb
,
0
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
vError
(
"vgId:%d %s failed since %s"
,
TD_VID
(
pInfo
->
pVnode
),
__func__
,
tstrerror
(
code
));
}
else
{
vDebug
(
"vgId:%d %s done"
,
TD_VID
(
pInfo
->
pVnode
),
__func__
);
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录