Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
ab22c7f6
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ab22c7f6
编写于
3月 29, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-34
上级
ffb02d97
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
24 deletion
+52
-24
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+52
-24
未找到文件。
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
ab22c7f6
...
...
@@ -900,6 +900,9 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
int
hasDataToCommit
=
tsdbHasDataToCommit
(
iters
,
pCfg
->
maxTables
,
minKey
,
maxKey
);
if
(
!
hasDataToCommit
)
return
0
;
// No data to commit, just return
// TODO: make it more flexible
pCompInfo
=
(
SCompInfo
*
)
malloc
(
sizeof
(
SCompInfo
)
+
sizeof
(
SCompBlock
)
*
1000
);
// Create and open files for commit
tsdbGetDataDirName
(
pRepo
,
dataDir
);
if
(
tsdbCreateFGroup
(
pFileH
,
dataDir
,
fid
,
pCfg
->
maxTables
)
<
0
)
{
/* TODO */
...
...
@@ -908,7 +911,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
if
(
pGroup
==
NULL
)
{
/* TODO */
}
tsdbCreateFile
(
dataDir
,
fid
,
".h"
,
pCfg
->
maxTables
,
&
hFile
,
1
,
0
);
if
(
1
/*pGroup->files[TSDB_FILE_TYPE_LAST].size > TSDB_MAX_LAST_FILE_SIZE*/
)
{
if
(
0
/*pGroup->files[TSDB_FILE_TYPE_LAST].size > TSDB_MAX_LAST_FILE_SIZE*/
)
{
// TODO: make it not to write the last file every time
tsdbCreateFile
(
dataDir
,
fid
,
".l"
,
pCfg
->
maxTables
,
&
lFile
,
0
,
0
);
isNewLastFile
=
1
;
...
...
@@ -929,6 +932,8 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
SSkipListIterator
*
pIter
=
iters
[
tid
];
SCompIdx
*
pIdx
=
&
pIndices
[
tid
];
int
nNewBlocks
=
0
;
if
(
pTable
==
NULL
||
pIter
==
NULL
)
continue
;
/* If no new data to write for this table, just write the old data to new file
...
...
@@ -936,8 +941,10 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
*/
if
(
!
tsdbHasDataInRange
(
pIter
,
minKey
,
maxKey
))
{
// has old data
if
(
pIdx
->
offset
>
0
)
{
if
(
isNewLastFile
&&
pIdx
->
hasLast
)
{
if
(
pIdx
->
len
>
0
)
{
goto
_table_over
;
// if (isNewLastFile && pIdx->hasLast) {
if
(
0
)
{
// need to move the last block to new file
if
((
pCompInfo
=
(
SCompInfo
*
)
realloc
((
void
*
)
pCompInfo
,
pIdx
->
len
))
==
NULL
)
{
/* TODO */
}
...
...
@@ -976,9 +983,14 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
continue
;
}
pCompInfo
->
delimiter
=
TSDB_FILE_DELIMITER
;
pCompInfo
->
checksum
=
0
;
pCompInfo
->
uid
=
pTable
->
tableId
.
uid
;
// Load SCompBlock part if neccessary
int
isCompBlockLoaded
=
0
;
if
(
pIdx
->
offset
>
0
)
{
if
(
0
)
{
// if (pIdx->offset > 0) {
if
(
pIdx
->
hasLast
||
tsdbHasDataInRange
(
pIter
,
minKey
,
pIdx
->
maxKey
))
{
// has last block || cache key overlap with commit key
pCompInfo
=
(
SCompInfo
*
)
realloc
((
void
*
)
pCompInfo
,
pIdx
->
len
+
sizeof
(
SCompBlock
)
*
100
);
...
...
@@ -998,34 +1010,50 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
tsdbReadRowsFromCache
(
pIter
,
maxKey
,
maxRowsToRead
,
pCols
);
if
(
pCols
->
numOfPoints
==
0
)
break
;
int
pointsWritten
=
0
;
// { // TODO : try to write the block data to file
// if (!isCompBlockLoaded) { // Just append
// if (pCols->numOfPoints > pCfg->minRowsPerFileBlock) { // write directly to .data file
// lseek(pGroup->files[TSDB_FILE_TYPE_DATA], 0, SEEK_END);
// } else {
// if (isNewLastFile) { // write directly to .l file
// } else { // write directly to .last file
int
pointsWritten
=
pCols
->
numOfPoints
;
// TODO: all write to the end of .data file
int64_t
toffset
=
0
;
int32_t
tlen
=
0
;
tsdbWriteBlockToFileImpl
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pCols
,
pCols
->
numOfPoints
,
&
toffset
,
&
tlen
,
pTable
->
tableId
.
uid
);
// Make the compBlock
SCompBlock
*
pTBlock
=
pCompInfo
->
blocks
+
nNewBlocks
++
;
pTBlock
->
offset
=
toffset
;
pTBlock
->
len
=
tlen
;
pTBlock
->
keyFirst
=
dataColsKeyFirst
(
pCols
);
pTBlock
->
keyLast
=
dataColsKeyLast
(
pCols
);
pTBlock
->
last
=
0
;
pTBlock
->
algorithm
=
0
;
pTBlock
->
numOfPoints
=
pCols
->
numOfPoints
;
pTBlock
->
sversion
=
pTable
->
sversion
;
pTBlock
->
numOfSubBlocks
=
1
;
if
(
dataColsKeyLast
(
pCols
)
>
pIdx
->
maxKey
)
pIdx
->
maxKey
=
dataColsKeyLast
(
pCols
);
// }
// }
// } else { // Need to append
// // SCompBlock *pTBlock = NULL;
// }
// }
// pointsWritten = pCols->numOfPoints;
tdPopDataColsPoints
(
pCols
,
pointsWritten
);
maxRowsToRead
=
pCfg
->
maxRowsPerFileBlock
*
4
/
5
-
pCols
->
numOfPoints
;
}
_table_over:
// Write the SCompBlock part
if
(
isCompBlockLoaded
)
{
// merge the block into old and update pIdx
pIdx
->
offset
=
lseek
(
hFile
.
fd
,
0
,
SEEK_END
);
if
(
pIdx
->
len
>
0
)
{
sendfile
(
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
].
fd
,
hFile
.
fd
,
NULL
,
pIdx
->
len
);
if
(
nNewBlocks
>
0
)
{
write
(
hFile
.
fd
,
(
void
*
)(
pCompInfo
->
blocks
),
sizeof
(
SCompBlock
)
*
nNewBlocks
);
pIdx
->
len
+=
(
sizeof
(
SCompBlock
)
*
nNewBlocks
);
}
}
else
{
// sendfile the SCompBlock part and update the pIdx
if
(
nNewBlocks
>
0
)
{
write
(
hFile
.
fd
,
(
void
*
)
pCompInfo
,
sizeof
(
SCompInfo
)
+
sizeof
(
SCompBlock
)
*
nNewBlocks
);
pIdx
->
len
+=
sizeof
(
SCompInfo
)
+
sizeof
(
SCompBlock
)
*
nNewBlocks
;
}
}
pIdx
->
checksum
=
0
;
pIdx
->
numOfSuperBlocks
+=
nNewBlocks
;
pIdx
->
hasLast
=
0
;
}
// Write the SCompIdx part
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录