Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c011e7b5
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看板
提交
c011e7b5
编写于
6月 22, 2020
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix coverity issue
上级
c2432e6b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
90 addition
and
44 deletion
+90
-44
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+41
-17
src/query/src/qUtil.c
src/query/src/qUtil.c
+1
-1
src/query/src/qpercentile.c
src/query/src/qpercentile.c
+6
-5
src/query/src/qtsbuf.c
src/query/src/qtsbuf.c
+42
-21
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
c011e7b5
...
@@ -5153,9 +5153,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
...
@@ -5153,9 +5153,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
}
}
if
(
!
validateQuerySourceCols
(
pQueryMsg
,
*
pExpr
))
{
if
(
!
validateQuerySourceCols
(
pQueryMsg
,
*
pExpr
))
{
tfree
(
*
pExpr
);
goto
_cleanup
;
return
TSDB_CODE_QRY_INVALID_MSG
;
}
}
pMsg
=
createTableIdList
(
pQueryMsg
,
pMsg
,
pTableIdList
);
pMsg
=
createTableIdList
(
pQueryMsg
,
pMsg
,
pTableIdList
);
...
@@ -5227,8 +5225,17 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
...
@@ -5227,8 +5225,17 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pQueryMsg
,
pQueryMsg
->
numOfTables
,
pQueryMsg
->
queryType
,
pQueryMsg
->
window
.
skey
,
pQueryMsg
->
window
.
ekey
,
pQueryMsg
->
numOfGroupCols
,
pQueryMsg
,
pQueryMsg
->
numOfTables
,
pQueryMsg
->
queryType
,
pQueryMsg
->
window
.
skey
,
pQueryMsg
->
window
.
ekey
,
pQueryMsg
->
numOfGroupCols
,
pQueryMsg
->
order
,
pQueryMsg
->
numOfOutput
,
pQueryMsg
->
numOfCols
,
pQueryMsg
->
intervalTime
,
pQueryMsg
->
order
,
pQueryMsg
->
numOfOutput
,
pQueryMsg
->
numOfCols
,
pQueryMsg
->
intervalTime
,
pQueryMsg
->
fillType
,
pQueryMsg
->
tsLen
,
pQueryMsg
->
tsNumOfBlocks
,
pQueryMsg
->
limit
,
pQueryMsg
->
offset
);
pQueryMsg
->
fillType
,
pQueryMsg
->
tsLen
,
pQueryMsg
->
tsNumOfBlocks
,
pQueryMsg
->
limit
,
pQueryMsg
->
offset
);
return
0
;
return
0
;
_cleanup:
tfree
(
*
pExpr
);
taosArrayDestroy
(
*
pTableIdList
);
*
pTableIdList
=
NULL
;
tfree
(
*
tbnameCond
);
tfree
(
*
groupbyCols
);
tfree
(
*
tagCols
);
tfree
(
*
tagCond
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
}
static
int32_t
buildAirthmeticExprFromMsg
(
SExprInfo
*
pArithExprInfo
,
SQueryTableMsg
*
pQueryMsg
)
{
static
int32_t
buildAirthmeticExprFromMsg
(
SExprInfo
*
pArithExprInfo
,
SQueryTableMsg
*
pQueryMsg
)
{
...
@@ -5494,6 +5501,8 @@ static int compareTableIdInfo(const void* a, const void* b) {
...
@@ -5494,6 +5501,8 @@ static int compareTableIdInfo(const void* a, const void* b) {
return
0
;
return
0
;
}
}
static
void
freeQInfo
(
SQInfo
*
pQInfo
);
static
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SArray
*
pTableIdList
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
static
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SArray
*
pTableIdList
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
)
{
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
calloc
(
1
,
sizeof
(
SQInfo
));
SQInfo
*
pQInfo
=
(
SQInfo
*
)
calloc
(
1
,
sizeof
(
SQInfo
));
...
@@ -5634,22 +5643,27 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
...
@@ -5634,22 +5643,27 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
return
pQInfo
;
return
pQInfo
;
_cleanup:
_cleanup:
tfree
(
pQuery
->
fillVal
);
//
tfree(pQuery->fillVal);
if
(
pQuery
->
sdata
!=
NULL
)
{
//
if (pQuery->sdata != NULL) {
for
(
int16_t
col
=
0
;
col
<
pQuery
->
numOfOutput
;
++
col
)
{
//
for (int16_t col = 0; col < pQuery->numOfOutput; ++col) {
tfree
(
pQuery
->
sdata
[
col
]);
//
tfree(pQuery->sdata[col]);
}
//
}
}
//
}
tfree
(
pQuery
->
sdata
);
//
tfree
(
pQuery
->
pFilterInfo
);
//tfree(pQuery->sdata);
tfree
(
pQuery
->
colList
);
//tfree(pQuery->pFilterInfo);
//tfree(pQuery->colList);
tfree
(
pExprs
);
//
tfree(pExprs);
tfree
(
pGroupbyExpr
);
//
tfree(pGroupbyExpr);
tfree
(
pQInfo
);
//taosArrayDestroy(pQInfo->arrTableIdInfo);
//tsdbDestoryTableGroup(&pQInfo->tableGroupInfo);
//
//tfree(pQInfo);
freeQInfo
(
pQInfo
);
return
NULL
;
return
NULL
;
}
}
...
@@ -5668,7 +5682,6 @@ static bool isValidQInfo(void *param) {
...
@@ -5668,7 +5682,6 @@ static bool isValidQInfo(void *param) {
return
(
sig
==
(
uint64_t
)
pQInfo
);
return
(
sig
==
(
uint64_t
)
pQInfo
);
}
}
static
void
freeQInfo
(
SQInfo
*
pQInfo
);
static
int32_t
initQInfo
(
SQueryTableMsg
*
pQueryMsg
,
void
*
tsdb
,
int32_t
vgId
,
SQInfo
*
pQInfo
,
bool
isSTable
)
{
static
int32_t
initQInfo
(
SQueryTableMsg
*
pQueryMsg
,
void
*
tsdb
,
int32_t
vgId
,
SQInfo
*
pQInfo
,
bool
isSTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -5889,6 +5902,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
...
@@ -5889,6 +5902,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
SExprInfo
*
pExprs
=
NULL
;
SExprInfo
*
pExprs
=
NULL
;
if
((
code
=
createQFunctionExprFromMsg
(
pQueryMsg
,
&
pExprs
,
pExprMsg
,
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
createQFunctionExprFromMsg
(
pQueryMsg
,
&
pExprs
,
pExprMsg
,
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pExprMsg
);
goto
_over
;
goto
_over
;
}
}
...
@@ -5939,6 +5953,10 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
...
@@ -5939,6 +5953,10 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
}
}
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
pTableIdList
,
pGroupbyExpr
,
pExprs
,
&
tableGroupInfo
,
pTagColumnInfo
);
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
pTableIdList
,
pGroupbyExpr
,
pExprs
,
&
tableGroupInfo
,
pTagColumnInfo
);
pExprs
=
NULL
;
pGroupbyExpr
=
NULL
;
pTagColumnInfo
=
NULL
;
if
((
*
pQInfo
)
==
NULL
)
{
if
((
*
pQInfo
)
==
NULL
)
{
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
goto
_over
;
goto
_over
;
...
@@ -5950,6 +5968,12 @@ _over:
...
@@ -5950,6 +5968,12 @@ _over:
tfree
(
tagCond
);
tfree
(
tagCond
);
tfree
(
tbnameCond
);
tfree
(
tbnameCond
);
tfree
(
pGroupColIndex
);
tfree
(
pGroupColIndex
);
if
(
pGroupbyExpr
!=
NULL
)
{
taosArrayDestroy
(
pGroupbyExpr
->
columnInfo
);
tfree
(
pGroupbyExpr
);
}
tfree
(
pTagColumnInfo
);
tfree
(
pExprs
);
taosArrayDestroy
(
pTableIdList
);
taosArrayDestroy
(
pTableIdList
);
//pQInfo already freed in initQInfo, but *pQInfo may not pointer to null;
//pQInfo already freed in initQInfo, but *pQInfo may not pointer to null;
...
...
src/query/src/qUtil.c
浏览文件 @
c011e7b5
...
@@ -138,7 +138,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
...
@@ -138,7 +138,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
SWindowResult
*
pResult
=
&
pWindowResInfo
->
pResult
[
k
];
SWindowResult
*
pResult
=
&
pWindowResInfo
->
pResult
[
k
];
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
window
.
skey
,
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
window
.
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
);
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
);
assert
(
p
!=
NULL
);
int32_t
v
=
(
*
p
-
num
);
int32_t
v
=
(
*
p
-
num
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
taosHashPut
(
pWindowResInfo
->
hashList
,
(
char
*
)
&
pResult
->
window
.
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
,
taosHashPut
(
pWindowResInfo
->
hashList
,
(
char
*
)
&
pResult
->
window
.
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
,
...
...
src/query/src/qpercentile.c
浏览文件 @
c011e7b5
...
@@ -879,8 +879,8 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
...
@@ -879,8 +879,8 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
UNUSED
(
ret
);
UNUSED
(
ret
);
for
(
uint32_t
jx
=
0
;
jx
<
pFlushInfo
->
numOfPages
;
++
jx
)
{
for
(
uint32_t
jx
=
0
;
jx
<
pFlushInfo
->
numOfPages
;
++
jx
)
{
ret
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
size_t
sz
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
ret
);
UNUSED
(
sz
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
}
}
...
@@ -965,10 +965,11 @@ char *getFirstElemOfMemBuffer(tMemBucketSegment *pSeg, int32_t slotIdx, tFilePag
...
@@ -965,10 +965,11 @@ char *getFirstElemOfMemBuffer(tMemBucketSegment *pSeg, int32_t slotIdx, tFilePag
*/
*/
tFlushoutInfo
*
pFlushInfo
=
&
pMemBuffer
->
fileMeta
.
flushoutData
.
pFlushoutInfo
[
0
];
tFlushoutInfo
*
pFlushInfo
=
&
pMemBuffer
->
fileMeta
.
flushoutData
.
pFlushoutInfo
[
0
];
assert
(
pFlushInfo
->
numOfPages
==
pMemBuffer
->
fileMeta
.
nFileSize
);
assert
(
pFlushInfo
->
numOfPages
==
pMemBuffer
->
fileMeta
.
nFileSize
);
int32_t
ret
;
fseek
(
pMemBuffer
->
file
,
pFlushInfo
->
startPageId
*
pMemBuffer
->
pageSize
,
SEEK_SET
);
ret
=
fseek
(
pMemBuffer
->
file
,
pFlushInfo
->
startPageId
*
pMemBuffer
->
pageSize
,
SEEK_SET
);
size_t
ret
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
ret
);
UNUSED
(
ret
);
size_t
sz
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
sz
);
thisVal
=
pPage
->
data
;
thisVal
=
pPage
->
data
;
}
}
return
thisVal
;
return
thisVal
;
...
...
src/query/src/qtsbuf.c
浏览文件 @
c011e7b5
...
@@ -65,8 +65,10 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -65,8 +65,10 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// validate the file magic number
// validate the file magic number
STSBufFileHeader
header
=
{
0
};
STSBufFileHeader
header
=
{
0
};
fseek
(
pTSBuf
->
f
,
0
,
SEEK_SET
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
0
,
SEEK_SET
);
fread
(
&
header
,
1
,
sizeof
(
STSBufFileHeader
),
pTSBuf
->
f
);
UNUSED
(
ret
);
size_t
sz
=
fread
(
&
header
,
1
,
sizeof
(
STSBufFileHeader
),
pTSBuf
->
f
);
UNUSED
(
sz
);
// invalid file
// invalid file
if
(
header
.
magic
!=
TS_COMP_FILE_MAGIC
)
{
if
(
header
.
magic
!=
TS_COMP_FILE_MAGIC
)
{
...
@@ -97,22 +99,30 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -97,22 +99,30 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
size_t
infoSize
=
sizeof
(
STSVnodeBlockInfo
)
*
pTSBuf
->
numOfVnodes
;
size_t
infoSize
=
sizeof
(
STSVnodeBlockInfo
)
*
pTSBuf
->
numOfVnodes
;
STSVnodeBlockInfo
*
buf
=
(
STSVnodeBlockInfo
*
)
calloc
(
1
,
infoSize
);
STSVnodeBlockInfo
*
buf
=
(
STSVnodeBlockInfo
*
)
calloc
(
1
,
infoSize
);
if
(
buf
==
NULL
)
{
tsBufDestory
(
pTSBuf
);
return
NULL
;
}
//int64_t pos = ftell(pTSBuf->f); //pos not used
//int64_t pos = ftell(pTSBuf->f); //pos not used
fread
(
buf
,
infoSize
,
1
,
pTSBuf
->
f
);
sz
=
fread
(
buf
,
infoSize
,
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
// the length value for each vnode is not kept in file, so does not set the length value
// the length value for each vnode is not kept in file, so does not set the length value
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOfVnodes
;
++
i
)
{
STSVnodeBlockInfoEx
*
pBlockList
=
&
pTSBuf
->
pData
[
i
];
STSVnodeBlockInfoEx
*
pBlockList
=
&
pTSBuf
->
pData
[
i
];
memcpy
(
&
pBlockList
->
info
,
&
buf
[
i
],
sizeof
(
STSVnodeBlockInfo
));
memcpy
(
&
pBlockList
->
info
,
&
buf
[
i
],
sizeof
(
STSVnodeBlockInfo
));
}
}
free
(
buf
);
free
(
buf
);
fseek
(
pTSBuf
->
f
,
0
,
SEEK_END
);
ret
=
fseek
(
pTSBuf
->
f
,
0
,
SEEK_END
);
UNUSED
(
ret
);
struct
stat
fileStat
;
struct
stat
fileStat
;
fstat
(
fileno
(
pTSBuf
->
f
),
&
fileStat
);
if
(
fstat
(
fileno
(
pTSBuf
->
f
),
&
fileStat
)
!=
0
)
{
tsBufDestory
(
pTSBuf
);
return
NULL
;
}
pTSBuf
->
fileSize
=
(
uint32_t
)
fileStat
.
st_size
;
pTSBuf
->
fileSize
=
(
uint32_t
)
fileStat
.
st_size
;
tsBufResetPos
(
pTSBuf
);
tsBufResetPos
(
pTSBuf
);
...
@@ -278,19 +288,24 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
...
@@ -278,19 +288,24 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
* set the right position for the reversed traverse, the reversed traverse is started from
* set the right position for the reversed traverse, the reversed traverse is started from
* the end of each comp data block
* the end of each comp data block
*/
*/
fseek
(
pTSBuf
->
f
,
-
sizeof
(
pBlock
->
padding
),
SEEK_CUR
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
-
sizeof
(
pBlock
->
padding
),
SEEK_CUR
);
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
size_t
sz
=
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
pBlock
->
compLen
=
pBlock
->
padding
;
pBlock
->
compLen
=
pBlock
->
padding
;
int32_t
offset
=
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
int32_t
offset
=
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
fseek
(
pTSBuf
->
f
,
-
offset
,
SEEK_CUR
);
ret
=
fseek
(
pTSBuf
->
f
,
-
offset
,
SEEK_CUR
);
UNUSED
(
ret
);
}
}
fread
(
&
pBlock
->
tag
,
sizeof
(
pBlock
->
tag
),
1
,
pTSBuf
->
f
);
size_t
sz
=
fread
(
&
pBlock
->
tag
,
sizeof
(
pBlock
->
tag
),
1
,
pTSBuf
->
f
);
fread
(
&
pBlock
->
numOfElem
,
sizeof
(
pBlock
->
numOfElem
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
sz
=
fread
(
&
pBlock
->
numOfElem
,
sizeof
(
pBlock
->
numOfElem
),
1
,
pTSBuf
->
f
);
fread
(
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
fread
(
pBlock
->
payload
,
(
size_t
)
pBlock
->
compLen
,
1
,
pTSBuf
->
f
);
sz
=
fread
(
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
sz
=
fread
(
pBlock
->
payload
,
(
size_t
)
pBlock
->
compLen
,
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
if
(
decomp
)
{
if
(
decomp
)
{
pTSBuf
->
tsData
.
len
=
pTSBuf
->
tsData
.
len
=
...
@@ -299,12 +314,13 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
...
@@ -299,12 +314,13 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
}
}
// read the comp length at the length of comp block
// read the comp length at the length of comp block
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
sz
=
fread
(
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
// for backwards traverse, set the start position at the end of previous block
// for backwards traverse, set the start position at the end of previous block
if
(
order
==
TSDB_ORDER_DESC
)
{
if
(
order
==
TSDB_ORDER_DESC
)
{
int32_t
offset
=
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
int32_t
offset
=
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
int
64
_t
r
=
fseek
(
pTSBuf
->
f
,
-
offset
,
SEEK_CUR
);
int
32
_t
r
=
fseek
(
pTSBuf
->
f
,
-
offset
,
SEEK_CUR
);
UNUSED
(
r
);
UNUSED
(
r
);
}
}
...
@@ -441,7 +457,8 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int
...
@@ -441,7 +457,8 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int
STSBlock
*
pBlock
=
&
pTSBuf
->
block
;
STSBlock
*
pBlock
=
&
pTSBuf
->
block
;
int32_t
compBlockSize
=
int32_t
compBlockSize
=
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
pBlock
->
compLen
+
sizeof
(
pBlock
->
compLen
)
*
2
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
tag
);
fseek
(
pTSBuf
->
f
,
-
compBlockSize
,
SEEK_CUR
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
-
compBlockSize
,
SEEK_CUR
);
UNUSED
(
ret
);
}
}
return
0
;
return
0
;
...
@@ -538,7 +555,7 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
...
@@ -538,7 +555,7 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
assert
(
pHeader
->
tsOrder
==
TSDB_ORDER_ASC
||
pHeader
->
tsOrder
==
TSDB_ORDER_DESC
);
assert
(
pHeader
->
tsOrder
==
TSDB_ORDER_ASC
||
pHeader
->
tsOrder
==
TSDB_ORDER_DESC
);
int
64
_t
r
=
fseek
(
pTSBuf
->
f
,
0
,
SEEK_SET
);
int
32
_t
r
=
fseek
(
pTSBuf
->
f
,
0
,
SEEK_SET
);
if
(
r
!=
0
)
{
if
(
r
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -743,7 +760,9 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) {
...
@@ -743,7 +760,9 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) {
int32_t
oldSize
=
pDestBuf
->
fileSize
;
int32_t
oldSize
=
pDestBuf
->
fileSize
;
struct
stat
fileStat
;
struct
stat
fileStat
;
fstat
(
fileno
(
pDestBuf
->
f
),
&
fileStat
);
if
(
fstat
(
fileno
(
pDestBuf
->
f
),
&
fileStat
)
!=
0
)
{
return
-
1
;
}
pDestBuf
->
fileSize
=
(
uint32_t
)
fileStat
.
st_size
;
pDestBuf
->
fileSize
=
(
uint32_t
)
fileStat
.
st_size
;
assert
(
pDestBuf
->
fileSize
==
oldSize
+
size
);
assert
(
pDestBuf
->
fileSize
==
oldSize
+
size
);
...
@@ -766,8 +785,10 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
...
@@ -766,8 +785,10 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
// update prev vnode length info in file
// update prev vnode length info in file
TSBufUpdateVnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnodes
-
1
,
pBlockInfo
);
TSBufUpdateVnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnodes
-
1
,
pBlockInfo
);
fseek
(
pTSBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
);
fwrite
((
void
*
)
pData
,
1
,
len
,
pTSBuf
->
f
);
UNUSED
(
ret
);
size_t
sz
=
fwrite
((
void
*
)
pData
,
1
,
len
,
pTSBuf
->
f
);
UNUSED
(
sz
);
pTSBuf
->
fileSize
+=
len
;
pTSBuf
->
fileSize
+=
len
;
pTSBuf
->
tsOrder
=
order
;
pTSBuf
->
tsOrder
=
order
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录