Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e88abb16
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e88abb16
编写于
6月 01, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: tsma days refactor
上级
169b3fc1
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
1136 addition
and
30 deletion
+1136
-30
include/common/tmsg.h
include/common/tmsg.h
+5
-5
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+9
-0
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+1
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+3
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+2
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+1
-1
source/dnode/vnode/src/sma/sma.c
source/dnode/vnode/src/sma/sma.c
+8
-0
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+1
-1
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+6
-6
source/dnode/vnode/src/sma/smaTimeRange2.c
source/dnode/vnode/src/sma/smaTimeRange2.c
+1084
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+8
-8
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+7
-7
未找到文件。
include/common/tmsg.h
浏览文件 @
e88abb16
...
...
@@ -2352,19 +2352,19 @@ typedef struct {
STSma
*
tSma
;
}
STSmaWrapper
;
static
FORCE_INLINE
void
t
d
DestroyTSma
(
STSma
*
pSma
)
{
static
FORCE_INLINE
void
tDestroyTSma
(
STSma
*
pSma
)
{
if
(
pSma
)
{
taosMemoryFreeClear
(
pSma
->
expr
);
taosMemoryFreeClear
(
pSma
->
tagsFilter
);
}
}
static
FORCE_INLINE
void
t
d
DestroyTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
static
FORCE_INLINE
void
tDestroyTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
if
(
pSW
)
{
if
(
pSW
->
tSma
)
{
if
(
deepCopy
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
t
d
DestroyTSma
(
pSW
->
tSma
+
i
);
tDestroyTSma
(
pSW
->
tSma
+
i
);
}
}
taosMemoryFreeClear
(
pSW
->
tSma
);
...
...
@@ -2372,8 +2372,8 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW, bool deepCopy)
}
}
static
FORCE_INLINE
void
*
t
d
FreeTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
t
d
DestroyTSmaWrapper
(
pSW
,
deepCopy
);
static
FORCE_INLINE
void
*
tFreeTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
deepCopy
)
{
tDestroyTSmaWrapper
(
pSW
,
deepCopy
);
taosMemoryFreeClear
(
pSW
);
return
NULL
;
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
e88abb16
...
...
@@ -194,6 +194,15 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
SVnodeCfg
vnodeCfg
=
{
0
};
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
if
(
createReq
.
isTsma
)
{
SMsgHead
*
smaMsg
=
createReq
.
pTsma
;
uint32_t
contLen
=
(
uint32_t
)(
htonl
(
smaMsg
->
contLen
)
-
sizeof
(
SMsgHead
));
if
(
smaGetTSmaDays
(
&
vnodeCfg
,
POINTER_SHIFT
(
smaMsg
,
sizeof
(
SMsgHead
)),
contLen
,
&
vnodeCfg
.
tsdbCfg
.
days
)
<
0
)
{
dError
(
"vgId:%d, failed to get tsma days since %s"
,
createReq
.
vgId
,
terrstr
());
return
-
1
;
}
}
SWrapperCfg
wrapperCfg
=
{
0
};
vmGenerateWrapperCfg
(
pMgmt
,
&
createReq
,
&
wrapperCfg
);
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
e88abb16
...
...
@@ -32,7 +32,7 @@ target_sources(
"src/sma/smaEnv.c"
"src/sma/smaOpen.c"
"src/sma/smaRollup.c"
"src/sma/smaTimeRange.c"
"src/sma/smaTimeRange
2
.c"
# tsdb
# "src/tsdb/tsdbTDBImpl.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
e88abb16
...
...
@@ -146,6 +146,9 @@ bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
*
pNumOfRows
,
int16_t
*
pNumOfCols
);
// sma
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
// need to reposition
// structs
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
e88abb16
...
...
@@ -223,6 +223,8 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, SSubmitReq *pMsg, int64_t version)
// TODO: This is the basic params, and should wrap the params to a queryHandle.
int32_t
tdGetTSmaDataImpl
(
SSma
*
pSma
,
char
*
pData
,
int64_t
indexUid
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
int32_t
tdGetTSmaDaysImpl
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
e88abb16
...
...
@@ -464,7 +464,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
_err:
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
pSmaIds
);
t
d
FreeTSmaWrapper
(
pSW
,
deepCopy
);
tFreeTSmaWrapper
(
pSW
,
deepCopy
);
return
NULL
;
}
...
...
source/dnode/vnode/src/sma/sma.c
浏览文件 @
e88abb16
...
...
@@ -52,3 +52,11 @@ int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey
}
return
code
;
}
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdGetTSmaDaysImpl
(
pCfg
,
pCont
,
contLen
,
days
))
<
0
)
{
smaWarn
(
"vgId:%d get tSma days failed since %s"
,
pCfg
->
vgId
,
tstrerror
(
terrno
));
}
return
code
;
}
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
e88abb16
...
...
@@ -278,7 +278,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) {
void
*
tdFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
)
{
if
(
pSmaStatItem
)
{
t
d
DestroyTSma
(
pSmaStatItem
->
pTSma
);
tDestroyTSma
(
pSmaStatItem
->
pTSma
);
taosMemoryFreeClear
(
pSmaStatItem
->
pTSma
);
taosHashCleanup
(
pSmaStatItem
->
expiredWindows
);
taosMemoryFreeClear
(
pSmaStatItem
);
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
e88abb16
...
...
@@ -828,7 +828,7 @@ int32_t tdDropTSma(SSma *pSma, char *pMsg) {
// TODO: send msg to stream computing to drop tSma
// if ((send msg to stream computing) < 0) {
// t
d
DestroyTSma(&vCreateSmaReq);
// tDestroyTSma(&vCreateSmaReq);
// return -1;
// }
//
...
...
@@ -982,25 +982,25 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, SSubmitReq *pMsg, int64_t version)
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
&
msgIter
,
pBlock
,
&
blkIter
)
<
0
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
}
while
(
true
)
{
STSRow
*
row
=
tGetSubmitBlkNext
(
&
blkIter
);
if
(
!
row
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
}
if
(
!
pSW
||
(
pTSma
&&
(
pTSma
->
tableUid
!=
msgIter
.
suid
)))
{
if
(
pSW
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
}
if
(
!
(
pSW
=
metaGetSmaInfoByTable
(
SMA_META
(
pSma
),
msgIter
.
suid
,
false
)))
{
break
;
}
if
((
pSW
->
number
)
<=
0
||
!
pSW
->
tSma
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
break
;
}
...
...
@@ -1020,7 +1020,7 @@ int32_t tdUpdateExpiredWindowImpl(SSma *pSma, SSubmitReq *pMsg, int64_t version)
if
(
lastWinSKey
!=
winSKey
)
{
lastWinSKey
=
winSKey
;
if
(
tdSetExpiredWindow
(
pSma
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
)
<
0
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
,
false
);
pSW
=
tFreeTSmaWrapper
(
pSW
,
false
);
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_FAILED
;
}
...
...
source/dnode/vnode/src/sma/smaTimeRange2.c
0 → 100644
浏览文件 @
e88abb16
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tq/tq.c
浏览文件 @
e88abb16
...
...
@@ -229,7 +229,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
}
memcpy
(
data
,
msg
,
msgLen
);
tqProcessStreamTrigger
(
pTq
,
data
);
//
tqProcessStreamTrigger(pTq, data);
}
return
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
e88abb16
...
...
@@ -515,7 +515,7 @@ static SSmaStatItem *tsdbNewSmaStatItem(int8_t state) {
static
void
*
tsdbFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
)
{
if
(
pSmaStatItem
)
{
t
d
DestroyTSma
(
pSmaStatItem
->
pSma
);
tDestroyTSma
(
pSmaStatItem
->
pSma
);
taosMemoryFreeClear
(
pSmaStatItem
->
pSma
);
taosHashCleanup
(
pSmaStatItem
->
expiredWindows
);
taosMemoryFreeClear
(
pSmaStatItem
);
...
...
@@ -718,25 +718,25 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
&
msgIter
,
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
);
pSW
=
tFreeTSmaWrapper
(
pSW
);
break
;
}
while
(
true
)
{
STSRow
*
row
=
tGetSubmitBlkNext
(
&
blkIter
);
if
(
!
row
)
{
t
d
FreeTSmaWrapper
(
pSW
);
tFreeTSmaWrapper
(
pSW
);
break
;
}
if
(
!
pSW
||
(
pTSma
->
tableUid
!=
pBlock
->
suid
))
{
if
(
pSW
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
);
pSW
=
tFreeTSmaWrapper
(
pSW
);
}
if
(
!
(
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
pBlock
->
suid
)))
{
break
;
}
if
((
pSW
->
number
)
<=
0
||
!
pSW
->
tSma
)
{
pSW
=
t
d
FreeTSmaWrapper
(
pSW
);
pSW
=
tFreeTSmaWrapper
(
pSW
);
break
;
}
...
...
@@ -1649,13 +1649,13 @@ int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg) {
// TODO: handle error
tsdbWarn
(
"vgId:%d tsma %s:%"
PRIi64
" create failed for table %"
PRIi64
" since %s"
,
REPO_ID
(
pTsdb
),
vCreateSmaReq
.
tSma
.
indexName
,
vCreateSmaReq
.
tSma
.
indexUid
,
vCreateSmaReq
.
tSma
.
tableUid
,
terrstr
(
terrno
));
t
d
DestroyTSma
(
&
vCreateSmaReq
.
tSma
);
tDestroyTSma
(
&
vCreateSmaReq
.
tSma
);
return
-
1
;
}
tsdbTSmaAdd
(
pTsdb
,
1
);
t
d
DestroyTSma
(
&
vCreateSmaReq
.
tSma
);
tDestroyTSma
(
&
vCreateSmaReq
.
tSma
);
// TODO: return directly or go on follow steps?
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1669,7 +1669,7 @@ int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg) {
// TODO: send msg to stream computing to drop tSma
// if ((send msg to stream computing) < 0) {
// t
d
DestroyTSma(&vCreateSmaReq);
// tDestroyTSma(&vCreateSmaReq);
// return -1;
// }
//
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
e88abb16
...
...
@@ -147,8 +147,8 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
// resource release
taosMemoryFreeClear
(
pSW
);
t
d
DestroyTSma
(
&
tSma
);
t
d
DestroyTSmaWrapper
(
&
dstTSmaWrapper
);
tDestroyTSma
(
&
tSma
);
tDestroyTSmaWrapper
(
&
dstTSmaWrapper
);
}
#endif
...
...
@@ -218,7 +218,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
EXPECT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
EXPECT_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
t
d
DestroyTSma
(
qSmaCfg
);
tDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
qSmaCfg
=
metaGetSmaInfoByIndex
(
pMeta
,
indexUid2
,
true
);
...
...
@@ -229,7 +229,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
EXPECT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
EXPECT_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
t
d
DestroyTSma
(
qSmaCfg
);
tDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
// get index name by table uid
...
...
@@ -265,7 +265,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
EXPECT_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
EXPECT_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tbUid
);
t
d
DestroyTSmaWrapper
(
pSW
);
tDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
// get all sma table uids
...
...
@@ -282,7 +282,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
metaRemoveSmaFromDb
(
pMeta
,
indexUid1
);
metaRemoveSmaFromDb
(
pMeta
,
indexUid2
);
t
d
DestroyTSma
(
&
tSma
);
tDestroyTSma
(
&
tSma
);
metaClose
(
pMeta
);
}
#endif
...
...
@@ -576,7 +576,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
taosArrayDestroy
(
pDataBlocks
);
// release meta
t
d
DestroyTSma
(
&
tSma
);
tDestroyTSma
(
&
tSma
);
tfsClose
(
pTsdb
->
pTfs
);
tsdbClose
(
pTsdb
);
metaClose
(
pMeta
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录