Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0c6acda1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
0c6acda1
编写于
6月 10, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact code
上级
2bf876f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
119 addition
and
107 deletion
+119
-107
source/dnode/vnode/src/tsdb/dev/tsdbDataFileRW.c
source/dnode/vnode/src/tsdb/dev/tsdbDataFileRW.c
+4
-4
source/dnode/vnode/src/tsdb/dev/tsdbSttFileRW.c
source/dnode/vnode/src/tsdb/dev/tsdbSttFileRW.c
+115
-103
未找到文件。
source/dnode/vnode/src/tsdb/dev/tsdbDataFileRW.c
浏览文件 @
0c6acda1
...
...
@@ -17,7 +17,7 @@
typedef
struct
{
SFDataPtr
brinBlkPtr
[
1
];
#if
1
#if
0
SFDataPtr blockIdxPtr[1];
#endif
SFDataPtr
rsrvd
[
2
];
...
...
@@ -40,7 +40,7 @@ struct SDataFileReader {
bool
brinBlkLoaded
;
bool
tombBlkLoaded
;
#if
1
#if
0
TABLEID tbid[1];
bool blockIdxLoaded;
#endif
...
...
@@ -53,7 +53,7 @@ struct SDataFileReader {
TBrinBlkArray
brinBlkArray
[
1
];
TTombBlkArray
tombBlkArray
[
1
];
#if
1
#if
0
TDataBlkArray dataBlkArray[1];
TBlockIdxArray blockIdxArray[1];
#endif
...
...
@@ -148,7 +148,7 @@ int32_t tsdbDataFileReaderClose(SDataFileReader **reader) {
TARRAY2_DESTROY
(
reader
[
0
]
->
tombBlkArray
,
NULL
);
TARRAY2_DESTROY
(
reader
[
0
]
->
brinBlkArray
,
NULL
);
#if
1
#if
0
TARRAY2_DESTROY(reader[0]->dataBlkArray, NULL);
TARRAY2_DESTROY(reader[0]->blockIdxArray, NULL);
#endif
...
...
source/dnode/vnode/src/tsdb/dev/tsdbSttFileRW.c
浏览文件 @
0c6acda1
...
...
@@ -369,7 +369,7 @@ _exit:
return
code
;
}
int32_t
tsdbSttFileReadTombBlock
(
SSttSegReader
*
reader
,
const
STombBlk
*
tombBlk
,
STombBlock
*
dData
)
{
int32_t
tsdbSttFileReadTombBlock
(
SSttSegReader
*
reader
,
const
STombBlk
*
tombBlk
,
STombBlock
*
tombBlock
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -380,14 +380,14 @@ int32_t tsdbSttFileReadTombBlock(SSttSegReader *reader, const STombBlk *tombBlk,
if
(
code
)
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
int64_t
size
=
0
;
tTombBlockClear
(
dData
);
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
dData
->
dataArr
);
++
i
)
{
tTombBlockClear
(
tombBlock
);
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
tombBlock
->
dataArr
);
++
i
)
{
code
=
tsdbDecmprData
(
reader
->
reader
->
config
->
bufArr
[
0
]
+
size
,
tombBlk
->
size
[
i
],
TSDB_DATA_TYPE_BIGINT
,
tombBlk
->
cmprAlg
,
&
reader
->
reader
->
config
->
bufArr
[
1
],
sizeof
(
int64_t
)
*
tombBlk
->
numRec
,
&
reader
->
reader
->
config
->
bufArr
[
2
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
TARRAY2_APPEND_BATCH
(
&
dData
->
dataArr
[
i
],
reader
->
reader
->
config
->
bufArr
[
1
],
tombBlk
->
numRec
);
code
=
TARRAY2_APPEND_BATCH
(
&
tombBlock
->
dataArr
[
i
],
reader
->
reader
->
config
->
bufArr
[
1
],
tombBlk
->
numRec
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
size
+=
tombBlk
->
size
[
i
];
...
...
@@ -401,27 +401,26 @@ _exit:
return
code
;
}
int32_t
tsdbSttFileReadStatisBlock
(
SSttSegReader
*
reader
,
const
SStatisBlk
*
statisBlk
,
STbStatisBlock
*
s
Data
)
{
int32_t
tsdbSttFileReadStatisBlock
(
SSttSegReader
*
reader
,
const
SStatisBlk
*
statisBlk
,
STbStatisBlock
*
s
tatisBlock
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
tStatisBlockClear
(
sData
);
code
=
tRealloc
(
&
reader
->
reader
->
config
->
bufArr
[
0
],
statisBlk
->
dp
->
size
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbReadFile
(
reader
->
reader
->
fd
,
statisBlk
->
dp
->
offset
,
reader
->
reader
->
config
->
bufArr
[
0
],
statisBlk
->
dp
->
size
);
if
(
code
)
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
int64_t
size
=
0
;
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
sData
->
dataArr
);
++
i
)
{
tStatisBlockClear
(
statisBlock
);
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
statisBlock
->
dataArr
);
++
i
)
{
code
=
tsdbDecmprData
(
reader
->
reader
->
config
->
bufArr
[
0
]
+
size
,
statisBlk
->
size
[
i
],
TSDB_DATA_TYPE_BIGINT
,
statisBlk
->
cmprAlg
,
&
reader
->
reader
->
config
->
bufArr
[
1
],
sizeof
(
int64_t
)
*
statisBlk
->
numRec
,
&
reader
->
reader
->
config
->
bufArr
[
2
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
TARRAY2_APPEND_BATCH
(
s
Data
->
dataArr
+
i
,
reader
->
reader
->
config
->
bufArr
[
1
],
statisBlk
->
numRec
);
code
=
TARRAY2_APPEND_BATCH
(
s
tatisBlock
->
dataArr
+
i
,
reader
->
reader
->
config
->
bufArr
[
1
],
statisBlk
->
numRec
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
size
+=
statisBlk
->
size
[
i
];
...
...
@@ -444,48 +443,48 @@ struct SSttFileWriter {
TABLEID
tbid
[
1
];
}
ctx
[
1
];
// file
STFile
file
[
1
];
STsdbFD
*
fd
;
STFile
file
[
1
];
// data
SSttFooter
footer
[
1
];
TTombBlkArray
tombBlkArray
[
1
];
TSttBlkArray
sttBlkArray
[
1
];
TStatisBlkArray
statisBlkArray
[
1
];
TTombBlkArray
tombBlkArray
[
1
];
SSttFooter
footer
[
1
];
SBlockData
bData
[
1
];
STbStatisBlock
sData
[
1
];
STombBlock
tData
[
1
];
STombBlock
tombBlock
[
1
];
STbStatisBlock
staticBlock
[
1
];
SBlockData
blockData
[
1
];
// helper data
SSkmInfo
skmTb
[
1
];
SSkmInfo
skmRow
[
1
];
uint8_t
*
bufArr
[
5
];
STsdbFD
*
fd
;
};
static
int32_t
tsdbSttFileDoWriteBlockData
(
SSttFileWriter
*
writer
)
{
if
(
writer
->
bData
->
nRow
==
0
)
return
0
;
if
(
writer
->
b
lock
Data
->
nRow
==
0
)
return
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
SSttBlk
sttBlk
[
1
]
=
{{
.
suid
=
writer
->
bData
->
suid
,
.
minUid
=
writer
->
b
Data
->
uid
?
writer
->
bData
->
uid
:
writer
->
b
Data
->
aUid
[
0
],
.
maxUid
=
writer
->
b
Data
->
uid
?
writer
->
bData
->
uid
:
writer
->
bData
->
aUid
[
writer
->
b
Data
->
nRow
-
1
],
.
minKey
=
writer
->
bData
->
aTSKEY
[
0
],
.
maxKey
=
writer
->
bData
->
aTSKEY
[
0
],
.
minVer
=
writer
->
bData
->
aVersion
[
0
],
.
maxVer
=
writer
->
bData
->
aVersion
[
0
],
.
nRow
=
writer
->
bData
->
nRow
,
.
suid
=
writer
->
b
lock
Data
->
suid
,
.
minUid
=
writer
->
b
lockData
->
uid
?
writer
->
blockData
->
uid
:
writer
->
block
Data
->
aUid
[
0
],
.
maxUid
=
writer
->
b
lockData
->
uid
?
writer
->
blockData
->
uid
:
writer
->
blockData
->
aUid
[
writer
->
block
Data
->
nRow
-
1
],
.
minKey
=
writer
->
b
lock
Data
->
aTSKEY
[
0
],
.
maxKey
=
writer
->
b
lock
Data
->
aTSKEY
[
0
],
.
minVer
=
writer
->
b
lock
Data
->
aVersion
[
0
],
.
maxVer
=
writer
->
b
lock
Data
->
aVersion
[
0
],
.
nRow
=
writer
->
b
lock
Data
->
nRow
,
}};
for
(
int32_t
iRow
=
1
;
iRow
<
writer
->
bData
->
nRow
;
iRow
++
)
{
if
(
sttBlk
->
minKey
>
writer
->
b
Data
->
aTSKEY
[
iRow
])
sttBlk
->
minKey
=
writer
->
b
Data
->
aTSKEY
[
iRow
];
if
(
sttBlk
->
maxKey
<
writer
->
b
Data
->
aTSKEY
[
iRow
])
sttBlk
->
maxKey
=
writer
->
b
Data
->
aTSKEY
[
iRow
];
if
(
sttBlk
->
minVer
>
writer
->
b
Data
->
aVersion
[
iRow
])
sttBlk
->
minVer
=
writer
->
b
Data
->
aVersion
[
iRow
];
if
(
sttBlk
->
maxVer
<
writer
->
b
Data
->
aVersion
[
iRow
])
sttBlk
->
maxVer
=
writer
->
b
Data
->
aVersion
[
iRow
];
for
(
int32_t
iRow
=
1
;
iRow
<
writer
->
b
lock
Data
->
nRow
;
iRow
++
)
{
if
(
sttBlk
->
minKey
>
writer
->
b
lockData
->
aTSKEY
[
iRow
])
sttBlk
->
minKey
=
writer
->
block
Data
->
aTSKEY
[
iRow
];
if
(
sttBlk
->
maxKey
<
writer
->
b
lockData
->
aTSKEY
[
iRow
])
sttBlk
->
maxKey
=
writer
->
block
Data
->
aTSKEY
[
iRow
];
if
(
sttBlk
->
minVer
>
writer
->
b
lockData
->
aVersion
[
iRow
])
sttBlk
->
minVer
=
writer
->
block
Data
->
aVersion
[
iRow
];
if
(
sttBlk
->
maxVer
<
writer
->
b
lockData
->
aVersion
[
iRow
])
sttBlk
->
maxVer
=
writer
->
block
Data
->
aVersion
[
iRow
];
}
int32_t
sizeArr
[
5
]
=
{
0
};
code
=
tCmprBlockData
(
writer
->
bData
,
writer
->
config
->
cmprAlg
,
NULL
,
NULL
,
writer
->
config
->
bufArr
,
sizeArr
);
code
=
tCmprBlockData
(
writer
->
b
lock
Data
,
writer
->
config
->
cmprAlg
,
NULL
,
NULL
,
writer
->
config
->
bufArr
,
sizeArr
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
sttBlk
->
bInfo
.
offset
=
writer
->
file
->
size
;
...
...
@@ -503,7 +502,7 @@ static int32_t tsdbSttFileDoWriteBlockData(SSttFileWriter *writer) {
code
=
TARRAY2_APPEND_PTR
(
writer
->
sttBlkArray
,
sttBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tBlockDataClear
(
writer
->
bData
);
tBlockDataClear
(
writer
->
b
lock
Data
);
_exit:
if
(
code
)
{
...
...
@@ -513,7 +512,7 @@ _exit:
}
static
int32_t
tsdbSttFileDoWriteStatisBlock
(
SSttFileWriter
*
writer
)
{
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
Data
)
==
0
)
return
0
;
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
taticBlock
)
==
0
)
return
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -526,44 +525,46 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
},
.
minTbid
=
{
.
suid
=
TARRAY2_FIRST
(
writer
->
s
Data
->
suid
),
.
uid
=
TARRAY2_FIRST
(
writer
->
s
Data
->
uid
),
.
suid
=
TARRAY2_FIRST
(
writer
->
s
taticBlock
->
suid
),
.
uid
=
TARRAY2_FIRST
(
writer
->
s
taticBlock
->
uid
),
},
.
maxTbid
=
{
.
suid
=
TARRAY2_LAST
(
writer
->
s
Data
->
suid
),
.
uid
=
TARRAY2_LAST
(
writer
->
s
Data
->
uid
),
.
suid
=
TARRAY2_LAST
(
writer
->
s
taticBlock
->
suid
),
.
uid
=
TARRAY2_LAST
(
writer
->
s
taticBlock
->
uid
),
},
.
minVer
=
TARRAY2_FIRST
(
writer
->
s
Data
->
minVer
),
.
maxVer
=
TARRAY2_FIRST
(
writer
->
s
Data
->
maxVer
),
.
numRec
=
STATIS_BLOCK_SIZE
(
writer
->
s
Data
),
.
minVer
=
TARRAY2_FIRST
(
writer
->
s
taticBlock
->
minVer
),
.
maxVer
=
TARRAY2_FIRST
(
writer
->
s
taticBlock
->
maxVer
),
.
numRec
=
STATIS_BLOCK_SIZE
(
writer
->
s
taticBlock
),
.
cmprAlg
=
writer
->
config
->
cmprAlg
,
}};
for
(
int32_t
i
=
1
;
i
<
STATIS_BLOCK_SIZE
(
writer
->
sData
);
i
++
)
{
statisBlk
->
minVer
=
TMIN
(
statisBlk
->
minVer
,
TARRAY2_GET
(
writer
->
sData
->
minVer
,
i
));
statisBlk
->
maxVer
=
TMAX
(
statisBlk
->
maxVer
,
TARRAY2_GET
(
writer
->
sData
->
maxVer
,
i
));
for
(
int32_t
i
=
1
;
i
<
STATIS_BLOCK_SIZE
(
writer
->
staticBlock
);
i
++
)
{
if
(
statisBlk
->
minVer
>
TARRAY2_GET
(
writer
->
staticBlock
->
minVer
,
i
))
{
statisBlk
->
minVer
=
TARRAY2_GET
(
writer
->
staticBlock
->
minVer
,
i
);
}
if
(
statisBlk
->
maxVer
<
TARRAY2_GET
(
writer
->
staticBlock
->
maxVer
,
i
))
{
statisBlk
->
maxVer
=
TARRAY2_GET
(
writer
->
staticBlock
->
maxVer
,
i
);
}
}
for
(
int32_t
i
=
0
;
i
<
STATIS_RECORD_NUM_ELEM
;
i
++
)
{
int32_t
size
;
code
=
tsdbCmprData
((
uint8_t
*
)
TARRAY2_DATA
(
writer
->
sData
->
dataArr
+
i
),
TARRAY2_DATA_LEN
(
&
writer
->
sData
->
dataArr
[
i
]),
TSDB_DATA_TYPE_BIGINT
,
statisBlk
->
cmprAlg
,
&
writer
->
config
->
bufArr
[
0
],
0
,
&
size
,
&
writer
->
config
->
bufArr
[
1
]);
code
=
tsdbCmprData
((
uint8_t
*
)
TARRAY2_DATA
(
writer
->
staticBlock
->
dataArr
+
i
),
TARRAY2_DATA_LEN
(
&
writer
->
staticBlock
->
dataArr
[
i
]),
TSDB_DATA_TYPE_BIGINT
,
statisBlk
->
cmprAlg
,
&
writer
->
config
->
bufArr
[
0
],
0
,
&
statisBlk
->
size
[
i
],
&
writer
->
config
->
bufArr
[
1
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbWriteFile
(
writer
->
fd
,
writer
->
file
->
size
,
writer
->
config
->
bufArr
[
0
],
s
ize
);
code
=
tsdbWriteFile
(
writer
->
fd
,
writer
->
file
->
size
,
writer
->
config
->
bufArr
[
0
],
s
tatisBlk
->
size
[
i
]
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
statisBlk
->
size
[
i
]
=
size
;
statisBlk
->
dp
->
size
+=
size
;
writer
->
file
->
size
+=
size
;
statisBlk
->
dp
->
size
+=
statisBlk
->
size
[
i
];
writer
->
file
->
size
+=
statisBlk
->
size
[
i
];
}
code
=
TARRAY2_APPEND_PTR
(
writer
->
statisBlkArray
,
statisBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tStatisBlockClear
(
writer
->
s
Data
);
tStatisBlockClear
(
writer
->
s
taticBlock
);
_exit:
if
(
code
)
{
...
...
@@ -573,7 +574,7 @@ _exit:
}
static
int32_t
tsdbSttFileDoWriteTombBlock
(
SSttFileWriter
*
writer
)
{
if
(
TOMB_BLOCK_SIZE
(
writer
->
t
Data
)
==
0
)
return
0
;
if
(
TOMB_BLOCK_SIZE
(
writer
->
t
ombBlock
)
==
0
)
return
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -586,44 +587,46 @@ static int32_t tsdbSttFileDoWriteTombBlock(SSttFileWriter *writer) {
},
.
minTbid
=
{
.
suid
=
TARRAY2_FIRST
(
writer
->
t
Data
->
suid
),
.
uid
=
TARRAY2_FIRST
(
writer
->
t
Data
->
uid
),
.
suid
=
TARRAY2_FIRST
(
writer
->
t
ombBlock
->
suid
),
.
uid
=
TARRAY2_FIRST
(
writer
->
t
ombBlock
->
uid
),
},
.
maxTbid
=
{
.
suid
=
TARRAY2_LAST
(
writer
->
t
Data
->
suid
),
.
uid
=
TARRAY2_LAST
(
writer
->
t
Data
->
uid
),
.
suid
=
TARRAY2_LAST
(
writer
->
t
ombBlock
->
suid
),
.
uid
=
TARRAY2_LAST
(
writer
->
t
ombBlock
->
uid
),
},
.
minVer
=
TARRAY2_FIRST
(
writer
->
t
Data
->
version
),
.
maxVer
=
TARRAY2_FIRST
(
writer
->
t
Data
->
version
),
.
numRec
=
TOMB_BLOCK_SIZE
(
writer
->
t
Data
),
.
minVer
=
TARRAY2_FIRST
(
writer
->
t
ombBlock
->
version
),
.
maxVer
=
TARRAY2_FIRST
(
writer
->
t
ombBlock
->
version
),
.
numRec
=
TOMB_BLOCK_SIZE
(
writer
->
t
ombBlock
),
.
cmprAlg
=
writer
->
config
->
cmprAlg
,
}};
for
(
int32_t
i
=
1
;
i
<
TOMB_BLOCK_SIZE
(
writer
->
tData
);
i
++
)
{
tombBlk
->
minVer
=
TMIN
(
tombBlk
->
minVer
,
TARRAY2_GET
(
writer
->
tData
->
version
,
i
));
tombBlk
->
maxVer
=
TMAX
(
tombBlk
->
maxVer
,
TARRAY2_GET
(
writer
->
tData
->
version
,
i
));
for
(
int32_t
i
=
1
;
i
<
TOMB_BLOCK_SIZE
(
writer
->
tombBlock
);
i
++
)
{
if
(
tombBlk
->
minVer
>
TARRAY2_GET
(
writer
->
tombBlock
->
version
,
i
))
{
tombBlk
->
minVer
=
TARRAY2_GET
(
writer
->
tombBlock
->
version
,
i
);
}
if
(
tombBlk
->
maxVer
<
TARRAY2_GET
(
writer
->
tombBlock
->
version
,
i
))
{
tombBlk
->
maxVer
=
TARRAY2_GET
(
writer
->
tombBlock
->
version
,
i
);
}
}
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
writer
->
tData
->
dataArr
);
i
++
)
{
int32_t
size
;
code
=
tsdbCmprData
((
uint8_t
*
)
TARRAY2_DATA
(
&
writer
->
tData
->
dataArr
[
i
]),
TARRAY2_DATA_LEN
(
&
writer
->
tData
->
dataArr
[
i
]),
TSDB_DATA_TYPE_BIGINT
,
tombBlk
->
cmprAlg
,
&
writer
->
config
->
bufArr
[
0
],
0
,
&
size
,
&
writer
->
config
->
bufArr
[
1
]);
for
(
int32_t
i
=
0
;
i
<
ARRAY_SIZE
(
writer
->
tombBlock
->
dataArr
);
i
++
)
{
code
=
tsdbCmprData
((
uint8_t
*
)
TARRAY2_DATA
(
&
writer
->
tombBlock
->
dataArr
[
i
]),
TARRAY2_DATA_LEN
(
&
writer
->
tombBlock
->
dataArr
[
i
]),
TSDB_DATA_TYPE_BIGINT
,
tombBlk
->
cmprAlg
,
&
writer
->
config
->
bufArr
[
0
],
0
,
&
tombBlk
->
size
[
i
],
&
writer
->
config
->
bufArr
[
1
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbWriteFile
(
writer
->
fd
,
writer
->
file
->
size
,
writer
->
config
->
bufArr
[
0
],
size
);
code
=
tsdbWriteFile
(
writer
->
fd
,
writer
->
file
->
size
,
writer
->
config
->
bufArr
[
0
],
tombBlk
->
size
[
i
]
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tombBlk
->
size
[
i
]
=
size
;
tombBlk
->
dp
->
size
+=
size
;
writer
->
file
->
size
+=
size
;
tombBlk
->
dp
->
size
+=
tombBlk
->
size
[
i
];
writer
->
file
->
size
+=
tombBlk
->
size
[
i
];
}
code
=
TARRAY2_APPEND_PTR
(
writer
->
tombBlkArray
,
tombBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tTombBlockClear
(
writer
->
t
Data
);
tTombBlockClear
(
writer
->
t
ombBlock
);
_exit:
if
(
code
)
{
...
...
@@ -749,9 +752,9 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
}
tDestroyTSchema
(
writer
->
skmRow
->
pTSchema
);
tDestroyTSchema
(
writer
->
skmTb
->
pTSchema
);
tTombBlockDestroy
(
writer
->
t
Data
);
tStatisBlockDestroy
(
writer
->
s
Data
);
tBlockDataDestroy
(
writer
->
bData
);
tTombBlockDestroy
(
writer
->
t
ombBlock
);
tStatisBlockDestroy
(
writer
->
s
taticBlock
);
tBlockDataDestroy
(
writer
->
b
lock
Data
);
TARRAY2_DESTROY
(
writer
->
tombBlkArray
,
NULL
);
TARRAY2_DESTROY
(
writer
->
statisBlkArray
,
NULL
);
TARRAY2_DESTROY
(
writer
->
sttBlkArray
,
NULL
);
...
...
@@ -880,7 +883,6 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
TSDBKEY
key
[
1
]
=
{
TSDBROW_KEY
(
&
row
->
row
)};
if
(
!
TABLE_SAME_SCHEMA
(
row
->
suid
,
row
->
uid
,
writer
->
ctx
->
tbid
->
suid
,
writer
->
ctx
->
tbid
->
uid
))
{
code
=
tsdbSttFileDoWriteBlockData
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -889,15 +891,24 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TABLEID
id
=
{.
suid
=
row
->
suid
,
.
uid
=
row
->
suid
?
0
:
row
->
uid
};
code
=
tBlockDataInit
(
writer
->
bData
,
&
id
,
writer
->
config
->
skmTb
->
pTSchema
,
NULL
,
0
);
code
=
tBlockDataInit
(
writer
->
b
lock
Data
,
&
id
,
writer
->
config
->
skmTb
->
pTSchema
,
NULL
,
0
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
TSDBKEY
key
[
1
];
if
(
row
->
row
.
type
==
TSDBROW_ROW_FMT
)
{
key
->
ts
=
row
->
row
.
pTSRow
->
ts
;
key
->
version
=
row
->
row
.
version
;
}
else
{
key
->
ts
=
row
->
row
.
pBlockData
->
aTSKEY
[
row
->
row
.
iRow
];
key
->
version
=
row
->
row
.
pBlockData
->
aVersion
[
row
->
row
.
iRow
];
}
if
(
writer
->
ctx
->
tbid
->
uid
!=
row
->
uid
)
{
writer
->
ctx
->
tbid
->
suid
=
row
->
suid
;
writer
->
ctx
->
tbid
->
uid
=
row
->
uid
;
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
Data
)
>=
writer
->
config
->
maxRow
)
{
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
taticBlock
)
>=
writer
->
config
->
maxRow
)
{
code
=
tsdbSttFileDoWriteStatisBlock
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -911,16 +922,20 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) {
.
maxVer
=
key
->
version
,
.
count
=
1
,
};
code
=
tStatisBlockPut
(
writer
->
s
Data
,
&
record
);
code
=
tStatisBlockPut
(
writer
->
s
taticBlock
,
&
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
ASSERT
(
key
->
ts
>=
TARRAY2_LAST
(
writer
->
s
Data
->
lastKey
));
ASSERT
(
key
->
ts
>=
TARRAY2_LAST
(
writer
->
s
taticBlock
->
lastKey
));
TARRAY2_LAST
(
writer
->
sData
->
minVer
)
=
TMIN
(
TARRAY2_LAST
(
writer
->
sData
->
minVer
),
key
->
version
);
TARRAY2_LAST
(
writer
->
sData
->
maxVer
)
=
TMAX
(
TARRAY2_LAST
(
writer
->
sData
->
maxVer
),
key
->
version
);
if
(
key
->
ts
>
TARRAY2_LAST
(
writer
->
sData
->
lastKey
))
{
TARRAY2_LAST
(
writer
->
sData
->
count
)
++
;
TARRAY2_LAST
(
writer
->
sData
->
lastKey
)
=
key
->
ts
;
if
(
TARRAY2_LAST
(
writer
->
staticBlock
->
minVer
)
>
key
->
version
)
{
TARRAY2_LAST
(
writer
->
staticBlock
->
minVer
)
=
key
->
version
;
}
if
(
TARRAY2_LAST
(
writer
->
staticBlock
->
maxVer
)
<
key
->
version
)
{
TARRAY2_LAST
(
writer
->
staticBlock
->
maxVer
)
=
key
->
version
;
}
if
(
key
->
ts
>
TARRAY2_LAST
(
writer
->
staticBlock
->
lastKey
))
{
TARRAY2_LAST
(
writer
->
staticBlock
->
count
)
++
;
TARRAY2_LAST
(
writer
->
staticBlock
->
lastKey
)
=
key
->
ts
;
}
}
...
...
@@ -931,22 +946,22 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) {
}
// row to col conversion
if
(
key
->
version
<=
writer
->
config
->
compactVersion
//
&&
writer
->
b
Data
->
nRow
>
0
//
&&
(
writer
->
bData
->
uid
//
?
writer
->
bData
->
uid
//
:
writer
->
bData
->
aUid
[
writer
->
bData
->
nRow
-
1
])
==
row
->
uid
//
&&
writer
->
bData
->
aTSKEY
[
writer
->
bData
->
nRow
-
1
]
==
key
->
ts
//
if
(
key
->
version
<=
writer
->
config
->
compactVersion
//
&&
writer
->
b
lockData
->
nRow
>
0
//
&&
writer
->
blockData
->
aTSKEY
[
writer
->
blockData
->
nRow
-
1
]
==
key
->
ts
//
&&
(
writer
->
blockData
->
uid
//
?
writer
->
blockData
->
uid
//
:
writer
->
blockData
->
aUid
[
writer
->
blockData
->
nRow
-
1
])
==
row
->
uid
//
)
{
code
=
tBlockDataUpdateRow
(
writer
->
bData
,
&
row
->
row
,
writer
->
config
->
skmRow
->
pTSchema
);
code
=
tBlockDataUpdateRow
(
writer
->
b
lock
Data
,
&
row
->
row
,
writer
->
config
->
skmRow
->
pTSchema
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
if
(
writer
->
bData
->
nRow
>=
writer
->
config
->
maxRow
)
{
if
(
writer
->
b
lock
Data
->
nRow
>=
writer
->
config
->
maxRow
)
{
code
=
tsdbSttFileDoWriteBlockData
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tBlockDataAppendRow
(
writer
->
bData
,
&
row
->
row
,
writer
->
config
->
skmRow
->
pTSchema
,
row
->
uid
);
code
=
tBlockDataAppendRow
(
writer
->
b
lock
Data
,
&
row
->
row
,
writer
->
config
->
skmRow
->
pTSchema
,
row
->
uid
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -961,7 +976,6 @@ int32_t tsdbSttFileWriteBlockData(SSttFileWriter *writer, SBlockData *bdata) {
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO: optimize here
SRowInfo
row
[
1
];
row
->
suid
=
bdata
->
suid
;
for
(
int32_t
i
=
0
;
i
<
bdata
->
nRow
;
i
++
)
{
...
...
@@ -987,23 +1001,21 @@ int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *re
code
=
tsdbSttFWriterDoOpen
(
writer
);
return
code
;
}
else
{
if
(
writer
->
bData
->
nRow
>
0
)
{
if
(
writer
->
b
lock
Data
->
nRow
>
0
)
{
code
=
tsdbSttFileDoWriteBlockData
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
Data
)
>
0
)
{
if
(
STATIS_BLOCK_SIZE
(
writer
->
s
taticBlock
)
>
0
)
{
code
=
tsdbSttFileDoWriteStatisBlock
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
// write SDelRecord
code
=
tTombBlockPut
(
writer
->
tData
,
record
);
code
=
tTombBlockPut
(
writer
->
tombBlock
,
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// write SDelBlock if need
if
(
TOMB_BLOCK_SIZE
(
writer
->
tData
)
>=
writer
->
config
->
maxRow
)
{
if
(
TOMB_BLOCK_SIZE
(
writer
->
tombBlock
)
>=
writer
->
config
->
maxRow
)
{
code
=
tsdbSttFileDoWriteTombBlock
(
writer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录