Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d17d6c50
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看板
提交
d17d6c50
编写于
6月 20, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
0359254b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
30 deletion
+87
-30
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+13
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+52
-21
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+20
-8
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-0
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+1
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
d17d6c50
...
...
@@ -72,6 +72,7 @@ typedef struct SDelFReader SDelFReader;
#define HAS_VALUE ((int8_t)0x4)
// tsdbUtil.c ==============================================================================================
// TSDBROW
#define TSDBROW_SVERSION(ROW) TD_ROW_SVER((ROW)->pTSRow)
#define tsdbRowFromTSRow(VERSION, TSROW) ((TSDBROW){.type = 0, .version = (VERSION), .pTSRow = (TSROW)});
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .pTSRow = (IROW)});
TSDBKEY
tsdbRowKey
(
TSDBROW
*
pRow
);
...
...
@@ -149,9 +150,18 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, S
TSDBROW
*
tsdbTbDataIterGet
(
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
// tsdbFile.c ==============================================================================================
// SDataFSet
// SHeadFile
void
tsdbHeadFileName
(
STsdb
*
pTsdb
,
SHeadFile
*
pFile
,
char
fname
[]);
// SDataFile
void
tsdbDataFileName
(
STsdb
*
pTsdb
,
SDataFile
*
pFile
,
char
fname
[]);
// SLastFile
void
tsdbLastFileName
(
STsdb
*
pTsdb
,
SLastFile
*
pFile
,
char
fname
[]);
// SSmaFile
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SSmaFile
*
pFile
,
char
fname
[]);
// SDelFile
#define tsdbDelFileCreate() ((SDelFile){.info = KEYINFO_INIT_VAL, .size = 0, .offset = 0})
char
*
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
);
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[]
);
// tsdbFS.c ==============================================================================================
typedef
struct
STsdbFS
STsdbFS
;
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
,
STsdbFS
**
ppFS
);
...
...
@@ -442,6 +452,8 @@ struct SSmaFile {
};
struct
SDFileSet
{
SDiskID
diskId
;
int32_t
nRef
;
SHeadFile
*
pHeadFile
;
SDataFile
*
pDataFile
;
SLastFile
*
pLastFile
;
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
d17d6c50
...
...
@@ -339,10 +339,16 @@ _err:
static
int32_t
tsdbCommitMemoryData
(
SCommitter
*
pCommitter
,
SBlockIdx
*
pBlockIdx
,
STbDataIter
*
pIter
,
TSDBKEY
eKey
,
bool
toDataOnly
)
{
int32_t
code
=
0
;
TSDBROW
*
pRow
;
SBlock
block
=
tBlockInit
();
int32_t
code
=
0
;
TSDBROW
*
pRow
;
STSchema
*
pTSchema
=
NULL
;
// TODO
TSDBKEY
key
;
SBlock
*
pBlock
=
&
pCommitter
->
nBlock
;
if
(
pIter
==
NULL
)
goto
_exit
;
tBlockReset
(
pBlock
);
tBlockDataReset
(
&
pCommitter
->
nBlockData
);
while
(
true
)
{
pRow
=
tsdbTbDataIterGet
(
pIter
);
...
...
@@ -354,30 +360,55 @@ static int32_t tsdbCommitMemoryData(SCommitter *pCommitter, SBlockIdx *pBlockIdx
}
}
code
=
tBlockDataAppendRow
(
&
pCommitter
->
nBlockData
,
pRow
,
NULL
/*TODO*/
);
// update schema
if
(
pTSchema
==
NULL
||
pTSchema
->
version
!=
TSDBROW_SVERSION
(
pRow
))
{
// TODO
// pTSchema = NULL;
}
// append row
code
=
tBlockDataAppendRow
(
&
pCommitter
->
nBlockData
,
pRow
,
pTSchema
);
if
(
code
)
goto
_err
;
// update info
key
=
tsdbRowKey
(
pRow
);
if
(
tsdbKeyCmprFn
(
&
key
,
&
pBlock
->
info
.
maxKey
)
>
0
)
pBlock
->
info
.
maxKey
=
key
;
if
(
tsdbKeyCmprFn
(
&
key
,
&
pBlock
->
info
.
minKey
)
<
0
)
pBlock
->
info
.
minKey
=
key
;
if
(
key
.
version
>
pBlock
->
info
.
maxVersion
)
pBlock
->
info
.
maxVersion
=
key
.
version
;
if
(
key
.
version
<
pBlock
->
info
.
minVerion
)
pBlock
->
info
.
minVerion
=
key
.
version
;
// iter next
tsdbTbDataIterNext
(
pIter
);
// check write
if
(
pCommitter
->
nBlockData
.
nRow
<
pCommitter
->
maxRow
*
4
/
5
)
{
continue
;
}
_write_block_data:
if
(
!
toDataOnly
&&
pCommitter
->
nBlockData
.
nRow
<
pCommitter
->
minKey
)
{
b
lock
.
last
=
1
;
pCommitter
->
nB
lock
.
last
=
1
;
}
else
{
b
lock
.
last
=
0
;
pCommitter
->
nB
lock
.
last
=
0
;
}
code
=
tsdbWriteBlockData
(
pCommitter
->
pWriter
,
&
pCommitter
->
nBlockData
,
NULL
,
NULL
,
pBlockIdx
,
&
b
lock
);
code
=
tsdbWriteBlockData
(
pCommitter
->
pWriter
,
&
pCommitter
->
nBlockData
,
NULL
,
NULL
,
pBlockIdx
,
pB
lock
);
if
(
code
)
goto
_err
;
code
=
tMapDataPutItem
(
&
pCommitter
->
nBlockMap
,
&
b
lock
,
tPutBlock
);
code
=
tMapDataPutItem
(
&
pCommitter
->
nBlockMap
,
pB
lock
,
tPutBlock
);
if
(
code
)
goto
_err
;
tBlockReset
(
&
block
);
// update info
if
(
tsdbKeyCmprFn
(
&
pBlock
->
info
.
minKey
,
&
pBlockIdx
->
info
.
minKey
)
<
0
)
pBlock
->
info
.
minKey
=
pBlockIdx
->
info
.
minKey
;
if
(
tsdbKeyCmprFn
(
&
pBlock
->
info
.
maxKey
,
&
pBlockIdx
->
info
.
maxKey
)
<
0
)
pBlock
->
info
.
maxKey
=
pBlockIdx
->
info
.
maxKey
;
if
(
pBlock
->
info
.
minVerion
<
pBlockIdx
->
info
.
minVerion
)
pBlockIdx
->
info
.
minVerion
=
pBlock
->
info
.
minVerion
;
if
(
pBlock
->
info
.
maxVersion
<
pBlockIdx
->
info
.
maxVersion
)
pBlockIdx
->
info
.
maxVersion
=
pBlock
->
info
.
maxVersion
;
tBlockReset
(
pBlock
);
tBlockDataReset
(
&
pCommitter
->
nBlockData
);
}
_exit:
return
code
;
_err:
...
...
@@ -465,14 +496,12 @@ _err:
static
int32_t
tsdbMergeCommit
(
SCommitter
*
pCommitter
,
SBlockIdx
*
pBlockIdx
,
STbDataIter
*
pIter
,
SBlock
*
pBlock
,
int8_t
isLastBlock
)
{
int32_t
code
=
0
;
TSDBROW
*
pRow
;
SBlock
block
=
tBlockInit
();
SBlockData
nBlockData
;
TSDBKEY
key
;
int32_t
c
;
int32_t
code
=
0
;
TSDBROW
*
pRow
;
TSDBKEY
key
;
int32_t
c
;
if
(
pBlock
==
NULL
)
{
if
(
pBlock
==
NULL
)
{
// (pIter && pBlock == NULL)
key
.
ts
=
pCommitter
->
maxKey
;
key
.
version
=
INT64_MAX
;
code
=
tsdbCommitMemoryData
(
pCommitter
,
pBlockIdx
,
pIter
,
key
,
0
);
...
...
@@ -481,12 +510,14 @@ static int32_t tsdbMergeCommit(SCommitter *pCommitter, SBlockIdx *pBlockIdx, STb
// merge
code
=
tsdbMergeCommitImpl
(
pCommitter
,
pBlockIdx
,
pIter
,
pBlock
,
0
);
if
(
code
)
goto
_err
;
}
else
{
}
else
{
// pBlock && pBlock->last == 0 && (pIter == NULL || pIter)
// memory
key
.
ts
=
pBlock
->
info
.
minKey
.
ts
;
key
.
version
=
pBlock
->
info
.
minKey
.
version
-
1
;
code
=
tsdbCommitMemoryData
(
pCommitter
,
pBlockIdx
,
pIter
,
key
,
1
);
if
(
code
)
goto
_err
;
if
(
pIter
)
{
key
.
ts
=
pBlock
->
info
.
minKey
.
ts
;
key
.
version
=
pBlock
->
info
.
minKey
.
version
-
1
;
code
=
tsdbCommitMemoryData
(
pCommitter
,
pBlockIdx
,
pIter
,
key
,
1
);
if
(
code
)
goto
_err
;
}
// merge or move block
pRow
=
tsdbTbDataIterGet
(
pIter
);
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
d17d6c50
...
...
@@ -15,17 +15,29 @@
#include "tsdb.h"
static
const
char
*
tsdbFileSuffix
[]
=
{
".
tombstone"
,
".cache"
,
".index
"
,
".data"
,
".last"
,
".sma"
,
""
};
static
const
char
*
tsdbFileSuffix
[]
=
{
".
del"
,
".cache"
,
".head
"
,
".data"
,
".last"
,
".sma"
,
""
};
// .tombstone
// SHeadFile ===============================================
void
tsdbHeadFileName
(
STsdb
*
pTsdb
,
SHeadFile
*
pFile
,
char
fname
[])
{
// TODO
}
// SD
el
File ===============================================
char
*
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
)
{
char
*
pName
=
NULL
;
int32_t
size
;
// SD
ata
File ===============================================
void
tsdbDataFileName
(
STsdb
*
pTsdb
,
SDataFile
*
pFile
,
char
fname
[]
)
{
// TODO
}
// SLastFile ===============================================
void
tsdbLastFileName
(
STsdb
*
pTsdb
,
SLastFile
*
pFile
,
char
fname
[])
{
// TODO
// sprintf(pName, "", pTsdb->path, );
}
return
pName
;
// SSmaFile ===============================================
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SSmaFile
*
pFile
,
char
fname
[])
{
// TODO
}
// SDelFile ===============================================
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[])
{
// snprintf(fname, TSDB_FILENAME_LEN, "", pTsdb->path);
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
d17d6c50
...
...
@@ -218,6 +218,7 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDa
pIter
->
pTbData
=
pTbData
;
pIter
->
backward
=
backward
;
pIter
->
pRow
=
NULL
;
pIter
->
row
.
type
=
0
;
if
(
pFrom
==
NULL
)
{
// create from head or tail
if
(
backward
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
d17d6c50
...
...
@@ -727,6 +727,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
int32_t
code
=
0
;
if
(
pRow
->
type
==
0
)
{
ASSERT
(
pTSchema
);
code
=
tsdbBlockDataAppendRow0
(
pBlockData
,
pRow
,
pTSchema
);
}
else
if
(
pRow
->
type
==
1
)
{
code
=
tsdbBlockDataAppendRow1
(
pBlockData
,
pRow
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录