Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f0bd200e
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看板
提交
f0bd200e
编写于
3月 28, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-34
上级
12d2e463
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
68 addition
and
11 deletion
+68
-11
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+68
-11
未找到文件。
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
f0bd200e
...
@@ -1069,10 +1069,12 @@ static int tsdbWriteBlockToFileImpl(SFile *pFile, SDataCols *pCols, int pointsTo
...
@@ -1069,10 +1069,12 @@ static int tsdbWriteBlockToFileImpl(SFile *pFile, SDataCols *pCols, int pointsTo
// Write the block
// Write the block
if
(
write
(
pFile
->
fd
,
(
void
*
)
pCompData
,
size
)
<
0
)
goto
_err
;
if
(
write
(
pFile
->
fd
,
(
void
*
)
pCompData
,
size
)
<
0
)
goto
_err
;
*
len
+=
size
;
for
(
int
iCol
=
0
;
iCol
<
pCols
->
numOfCols
;
iCol
++
)
{
for
(
int
iCol
=
0
;
iCol
<
pCols
->
numOfCols
;
iCol
++
)
{
SDataCol
*
pDataCol
=
pCols
->
cols
+
iCol
;
SDataCol
*
pDataCol
=
pCols
->
cols
+
iCol
;
SCompCol
*
pCompCol
=
pCompData
->
cols
+
iCol
;
SCompCol
*
pCompCol
=
pCompData
->
cols
+
iCol
;
if
(
write
(
pFile
->
fd
,
pDataCol
->
pData
,
pCompCol
->
len
)
<
0
)
goto
_err
;
if
(
write
(
pFile
->
fd
,
pDataCol
->
pData
,
pCompCol
->
len
)
<
0
)
goto
_err
;
*
len
+=
pCompCol
->
len
;
}
}
if
(
pCompData
==
NULL
)
free
((
void
*
)
pCompData
);
if
(
pCompData
==
NULL
)
free
((
void
*
)
pCompData
);
...
@@ -1083,22 +1085,46 @@ _err:
...
@@ -1083,22 +1085,46 @@ _err:
return
-
1
;
return
-
1
;
}
}
static
int
tsdbWriteBlockToFile
(
STsdbRepo
*
pRepo
,
SCompIdx
*
pIdx
,
SCompInfo
*
pCompInfo
,
SDataCols
*
pCols
,
SCompBlock
*
pCompBlock
)
{
static
int
compareKeyBlock
(
const
void
*
arg1
,
const
void
*
arg2
)
{
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
TSKEY
key
=
*
(
TSKEY
*
)
arg1
;
SCompBlock
*
pBlock
=
(
SCompBlock
*
)
arg2
;
if
(
key
<
pBlock
->
keyFirst
)
{
return
-
1
;
}
else
if
(
key
>
pBlock
->
keyLast
)
{
return
1
;
}
return
0
;
}
static
int
tsdbWriteBlockToFile
(
STsdbRepo
*
pRepo
,
SFileGroup
*
pGroup
,
SCompIdx
*
pIdx
,
SCompInfo
*
pCompInfo
,
SDataCols
*
pCols
,
SCompBlock
*
pCompBlock
,
SFile
*
lFile
,
int64_t
uid
)
{
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
SCompData
*
pCompData
=
NULL
;
SCompData
*
pCompData
=
NULL
;
SFile
*
pFile
=
NULL
;
int
numOfPointsToWrite
=
0
;
int64_t
offset
=
0
;
int32_t
len
=
0
;
memset
((
void
*
)
pCompBlock
,
0
,
sizeof
(
SCompBlock
));
memset
((
void
*
)
pCompBlock
,
0
,
sizeof
(
SCompBlock
));
if
(
pCompInfo
==
NULL
)
{
if
(
pCompInfo
==
NULL
)
{
if
(
pCols
->
numOfPoints
>
pCfg
->
minRowsPerFileBlock
)
{
// Write to .data file
// Just append the data block to .data or .l or .last file
// tsdbWriteBlockToFileImpl()
numOfPointsToWrite
=
pCols
->
numOfPoints
;
}
else
{
// Write to .last or .l file
if
(
pCols
->
numOfPoints
>
pCfg
->
minRowsPerFileBlock
)
{
// Write to .data file
pFile
=
&
(
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]);
}
else
{
// Write to .last or .l file
pCompBlock
->
last
=
1
;
pCompBlock
->
last
=
1
;
if
(
lFile
)
{
pFile
=
lFile
;
}
else
{
pFile
=
&
(
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]);
}
}
}
// pCompBlock->offset = ;
tsdbWriteBlockToFileImpl
(
pFile
,
pCols
,
numOfPointsToWrite
,
&
offset
,
&
len
,
uid
);
// pCompBlock->len = ;
pCompBlock
->
offset
=
offset
;
pCompBlock
->
algorithm
=
2
;
// TODO : add to configuration
pCompBlock
->
len
=
len
;
pCompBlock
->
algorithm
=
2
;
// TODO : add to configuration
pCompBlock
->
sversion
=
pCols
->
sversion
;
pCompBlock
->
sversion
=
pCols
->
sversion
;
pCompBlock
->
numOfPoints
=
pCols
->
numOfPoints
;
pCompBlock
->
numOfPoints
=
pCols
->
numOfPoints
;
pCompBlock
->
numOfSubBlocks
=
1
;
pCompBlock
->
numOfSubBlocks
=
1
;
...
@@ -1106,7 +1132,38 @@ static int tsdbWriteBlockToFile(STsdbRepo *pRepo, SCompIdx *pIdx, SCompInfo *pCo
...
@@ -1106,7 +1132,38 @@ static int tsdbWriteBlockToFile(STsdbRepo *pRepo, SCompIdx *pIdx, SCompInfo *pCo
pCompBlock
->
keyFirst
=
dataColsKeyFirst
(
pCols
);
pCompBlock
->
keyFirst
=
dataColsKeyFirst
(
pCols
);
pCompBlock
->
keyLast
=
dataColsKeyLast
(
pCols
);
pCompBlock
->
keyLast
=
dataColsKeyLast
(
pCols
);
}
else
{
}
else
{
// Need to merge
// Need to merge the block to either the last block or the other block
TSKEY
keyFirst
=
dataColsKeyFirst
(
pCols
);
SCompBlock
*
pMergeBlock
=
NULL
;
// Search the block to merge in
void
*
ptr
=
taosbsearch
((
void
*
)
&
keyFirst
,
(
void
*
)(
pCompInfo
->
blocks
),
sizeof
(
SCompBlock
),
pIdx
->
numOfSuperBlocks
,
compareKeyBlock
,
TD_GE
);
if
(
ptr
==
NULL
)
{
// No block greater or equal than the key, but there are data in the .last file, need to merge the last file block
// and merge the data
pMergeBlock
=
TSDB_COMPBLOCK_AT
(
pCompInfo
,
pIdx
->
numOfSuperBlocks
-
1
);
}
else
{
pMergeBlock
=
(
SCompBlock
*
)
ptr
;
}
if
(
pMergeBlock
->
last
)
{
if
(
pMergeBlock
->
last
+
pCols
->
numOfPoints
>
pCfg
->
minRowsPerFileBlock
)
{
// Need to load the data from .last and combine data in pCols to write to .data file
}
else
{
// Just append the block to .last or .l file
if
(
lFile
)
{
// read the block from .last file and merge with pCols, write to .l file
}
else
{
// tsdbWriteBlockToFileImpl();
}
}
}
else
{
// The block need to merge in .data file
}
}
}
return
0
;
return
numOfPointsToWrite
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录