Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9e7b43c8
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9e7b43c8
编写于
5月 15, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: sma code refactor
上级
069ce051
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
30 addition
and
13 deletion
+30
-13
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-3
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-1
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+1
-0
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+4
-2
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+9
-0
source/dnode/vnode/src/meta/metaSma.c
source/dnode/vnode/src/meta/metaSma.c
+11
-4
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-3
未找到文件。
source/common/src/tmsg.c
浏览文件 @
9e7b43c8
...
...
@@ -3586,12 +3586,11 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
}
int32_t
tDecodeTSma
(
SDecoder
*
pCoder
,
STSma
*
pSma
)
{
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
version
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
version
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
intervalUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
slidingUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pSma
->
timezoneInt
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
(
const
char
**
)
&
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
To
(
pCoder
,
pSma
->
indexName
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
exprLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pSma
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pSma
->
indexUid
)
<
0
)
return
-
1
;
...
...
@@ -3645,7 +3644,7 @@ int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) {
if
(
tStartDecode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
indexUid
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
(
pCoder
,
(
const
char
**
)
&
pReq
->
indexName
)
<
0
)
return
-
1
;
if
(
tDecodeCStr
To
(
pCoder
,
pReq
->
indexName
)
<
0
)
return
-
1
;
tEndDecode
(
pCoder
);
return
0
;
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
9e7b43c8
...
...
@@ -192,7 +192,7 @@ struct SMetaEntry {
SSchemaWrapper
schema
;
}
ntbEntry
;
struct
{
STSma
Wrapper
tsma
;
STSma
*
tsma
;
}
smaEntry
;
};
};
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
9e7b43c8
...
...
@@ -73,6 +73,7 @@ struct SMeta {
TDB
*
pCtbIdx
;
TDB
*
pTagIdx
;
TDB
*
pTtlIdx
;
TDB
*
pSmaIdx
;
SMetaIdx
*
pIdx
;
};
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
9e7b43c8
...
...
@@ -36,7 +36,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schema
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
if
(
tEncodeTSma
Wrapper
(
pCoder
,
&
pME
->
smaEntry
.
tsma
)
<
0
)
return
-
1
;
if
(
tEncodeTSma
(
pCoder
,
pME
->
smaEntry
.
tsma
)
<
0
)
return
-
1
;
}
else
{
ASSERT
(
0
);
}
...
...
@@ -66,7 +66,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pME
->
ntbEntry
.
schema
)
<
0
)
return
-
1
;
}
else
{
}
else
if
(
pME
->
type
==
TSDB_TSMA_TABLE
)
{
if
(
tDecodeTSma
(
pCoder
,
pME
->
smaEntry
.
tsma
)
<
0
)
return
-
1
;
}
else
{
ASSERT
(
0
);
}
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
9e7b43c8
...
...
@@ -105,6 +105,13 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
goto
_err
;
}
// open pSmaIdx
ret
=
tdbDbOpen
(
"sma.idx"
,
sizeof
(
SSmaIdxKey
),
0
,
smaIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSmaIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d failed to open meta sma index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open index
if
(
metaOpenIdx
(
pMeta
)
<
0
)
{
metaError
(
"vgId:%d failed to open meta index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
...
...
@@ -118,6 +125,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
_err:
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pSmaIdx
)
tdbDbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbDbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdbDbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbDbClose
(
pMeta
->
pCtbIdx
);
...
...
@@ -134,6 +142,7 @@ _err:
int
metaClose
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pSmaIdx
)
tdbDbClose
(
pMeta
->
pSmaIdx
);
if
(
pMeta
->
pTtlIdx
)
tdbDbClose
(
pMeta
->
pTtlIdx
);
if
(
pMeta
->
pTagIdx
)
tdbDbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbDbClose
(
pMeta
->
pCtbIdx
);
...
...
source/dnode/vnode/src/meta/metaSma.c
浏览文件 @
9e7b43c8
...
...
@@ -23,8 +23,6 @@ int32_t metaCreateTSma(SMeta *pMeta, int64_t version, SSmaCfg *pCfg) {
// The table uid should exists and be super table or normal table.
// Check other cfg value
// TODO: add atomicity
SMetaEntry
me
=
{
0
};
int
kLen
=
0
;
int
vLen
=
0
;
...
...
@@ -55,7 +53,7 @@ int32_t metaCreateTSma(SMeta *pMeta, int64_t version, SSmaCfg *pCfg) {
me
.
type
=
TSDB_TSMA_TABLE
;
me
.
uid
=
pCfg
->
indexUid
;
me
.
name
=
pCfg
->
indexName
;
// me.smaEntry = xx
;
me
.
smaEntry
.
tsma
=
pCfg
;
if
(
metaHandleSmaEntry
(
pMeta
,
&
me
)
<
0
)
goto
_err
;
...
...
@@ -180,8 +178,15 @@ _err:
return
-
1
;
}
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbDbInsert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateSmaIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SSmaIdxKey
smaIdxKey
=
{.
uid
=
pME
->
smaEntry
.
tsma
->
tableUid
,
.
smaUid
=
pME
->
smaEntry
.
tsma
->
indexUid
};
return
tdbDbInsert
(
pMeta
->
pSmaIdx
,
&
smaIdxKey
,
sizeof
(
smaIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaHandleSmaEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
metaWLock
(
pMeta
);
...
...
@@ -190,7 +195,9 @@ static int metaHandleSmaEntry(SMeta *pMeta, const SMetaEntry *pME) {
if
(
metaSaveSmaToDB
(
pMeta
,
pME
)
<
0
)
goto
_err
;
// // update uid.idx
// if (metaUpdateUidIdx(pMeta, pME) < 0) goto _err;
if
(
metaUpdateUidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
if
(
metaUpdateSmaIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
metaULock
(
pMeta
);
return
0
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
9e7b43c8
...
...
@@ -670,12 +670,11 @@ static int vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq
pRsp
->
code
=
terrno
;
goto
_err
;
}
#if 0
if (metaCreate
STable
(pVnode->pMeta, version, &req) < 0) {
if
(
metaCreate
TSma
(
pVnode
->
pMeta
,
version
,
&
req
)
<
0
)
{
pRsp
->
code
=
terrno
;
goto
_err
;
}
#endif
tDecoderClear
(
&
coder
);
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录