Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ddb82b1d
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
ddb82b1d
编写于
6月 08, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix a commit bug
上级
9d6d8a06
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
15 deletion
+16
-15
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+11
-10
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+5
-5
未找到文件。
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
ddb82b1d
...
...
@@ -764,8 +764,8 @@ static bool tsdbShouldCreateNewLast(SRWHelper *pHelper) {
static
int
tsdbWriteBlockToFile
(
SRWHelper
*
pHelper
,
SFile
*
pFile
,
SDataCols
*
pDataCols
,
int
rowsToWrite
,
SCompBlock
*
pCompBlock
,
bool
isLast
,
bool
isSuperBlock
)
{
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pDataCols
->
numOfRows
&&
rowsToWrite
<=
pHelper
->
config
.
maxRowsPerFileBlock
);
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pDataCols
->
numOfRows
&&
rowsToWrite
<=
pHelper
->
config
.
maxRowsPerFileBlock
);
ASSERT
(
isLast
?
rowsToWrite
<
pHelper
->
config
.
minRowsPerFileBlock
:
true
);
SCompData
*
pCompData
=
(
SCompData
*
)(
pHelper
->
pBuffer
);
int64_t
offset
=
0
;
...
...
@@ -905,7 +905,8 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
rowsWritten
=
MIN
((
defaultRowsToWrite
-
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
),
pDataCols
->
numOfRows
);
if
((
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfSubBlocks
<
TSDB_MAX_SUBBLOCKS
)
&&
(
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
+
rowsWritten
<
pHelper
->
config
.
minRowsPerFileBlock
)
&&
(
pHelper
->
files
.
nLastF
.
fd
)
>
0
)
{
(
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
+
rowsWritten
<
pHelper
->
config
.
minRowsPerFileBlock
)
&&
(
pHelper
->
files
.
nLastF
.
fd
)
<
0
)
{
if
(
tsdbWriteBlockToFile
(
pHelper
,
&
(
pHelper
->
files
.
lastF
),
pDataCols
,
rowsWritten
,
&
compBlock
,
true
,
false
)
<
0
)
goto
_err
;
if
(
tsdbAddSubBlock
(
pHelper
,
&
compBlock
,
blkIdx
,
rowsWritten
)
<
0
)
goto
_err
;
...
...
@@ -936,21 +937,21 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// Key must overlap with the block
ASSERT
(
keyFirst
<=
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyLast
);
TSKEY
keyLimit
=
(
blkIdx
==
pIdx
->
numOfBlocks
-
1
)
?
INT64_MAX
:
pHelper
->
pCompInfo
->
blocks
[
blkIdx
+
1
].
keyFirst
-
1
;
TSKEY
keyLimit
=
(
blkIdx
==
pIdx
->
numOfBlocks
-
1
)
?
INT64_MAX
:
blockAtIdx
(
pHelper
,
blkIdx
+
1
)
->
keyFirst
-
1
;
// rows1: number of rows must merge in this block
int
rows1
=
tsdbGetRowsInRange
(
pDataCols
,
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyFirst
,
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyLast
);
// rows2: max nuber of rows the block can have more
// rows2: max nu
m
ber of rows the block can have more
int
rows2
=
pHelper
->
config
.
maxRowsPerFileBlock
-
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
;
// rows3: number of rows between this block and the next block
int
rows3
=
tsdbGetRowsInRange
(
pDataCols
,
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyFirst
,
keyLimit
);
ASSERT
(
rows3
>=
rows1
);
if
((
rows2
>=
rows1
)
&&
((
blockAtIdx
(
pHelper
,
blkIdx
)
->
last
)
||
((
rows1
+
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
<
pHelper
->
config
.
minRowsPerFileBlock
)
&&
(
pHelper
->
files
.
nLastF
.
fd
<
0
))))
{
if
((
rows2
>=
rows1
)
&&
(
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfSubBlocks
<
TSDB_MAX_SUBBLOCKS
)
&&
((
!
blockAtIdx
(
pHelper
,
blkIdx
)
->
last
)
||
((
rows1
+
blockAtIdx
(
pHelper
,
blkIdx
)
->
numOfRows
<
pHelper
->
config
.
minRowsPerFileBlock
)
&&
(
pHelper
->
files
.
nLastF
.
fd
<
0
))))
{
rowsWritten
=
rows1
;
bool
isLast
=
false
;
SFile
*
pFile
=
NULL
;
...
...
src/util/src/tkvstore.c
浏览文件 @
ddb82b1d
...
...
@@ -45,7 +45,7 @@ static int tdUpdateKVStoreHeader(int fd, char *fname, SStoreInfo *pInfo);
int
tdCreateKVStore
(
char
*
fname
)
{
char
*
tname
=
strdup
(
fname
);
if
(
tname
==
NULL
)
return
TSDB_CODE_
SERV
_OUT_OF_MEMORY
;
if
(
tname
==
NULL
)
return
TSDB_CODE_
COM
_OUT_OF_MEMORY
;
int
fd
=
open
(
fname
,
O_RDWR
|
O_CREAT
,
0755
);
if
(
fd
<
0
)
{
...
...
@@ -247,14 +247,14 @@ static SKVStore *tdNewKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void
pStore
->
appH
=
appH
;
pStore
->
map
=
taosHashInit
(
4096
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
);
if
(
pStore
->
map
==
NULL
)
{
terrno
=
TSDB_CODE_
SERV
_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_
COM
_OUT_OF_MEMORY
;
goto
_err
;
}
return
pStore
;
_err:
terrno
=
TSDB_CODE_
SERV
_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_
COM
_OUT_OF_MEMORY
;
tdFreeKVStore
(
pStore
);
return
NULL
;
}
...
...
@@ -273,7 +273,7 @@ static char *tdGetKVStoreSnapshotFname(char *fdata) {
size_t
size
=
strlen
(
fdata
)
+
strlen
(
TD_KVSTORE_SNAP_SUFFIX
)
+
1
;
char
*
fname
=
malloc
(
size
);
if
(
fname
==
NULL
)
{
terrno
=
TSDB_CODE_
SERV
_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_
COM
_OUT_OF_MEMORY
;
return
NULL
;
}
sprintf
(
fname
,
"%s%s"
,
fdata
,
TD_KVSTORE_SNAP_SUFFIX
);
...
...
@@ -284,7 +284,7 @@ static char *tdGetKVStoreNewFname(char *fdata) {
size_t
size
=
strlen
(
fdata
)
+
strlen
(
TD_KVSTORE_NEW_SUFFIX
)
+
1
;
char
*
fname
=
malloc
(
size
);
if
(
fname
==
NULL
)
{
terrno
=
TSDB_CODE_
SERV
_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_
COM
_OUT_OF_MEMORY
;
return
NULL
;
}
sprintf
(
fname
,
"%s%s"
,
fdata
,
TD_KVSTORE_NEW_SUFFIX
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录