Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17a3469a
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看板
提交
17a3469a
编写于
12月 10, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 retrieve stable meta
上级
13cfafaf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
66 deletion
+66
-66
source/dnode/mnode/impl/src/mndStable.c
source/dnode/mnode/impl/src/mndStable.c
+66
-66
未找到文件。
source/dnode/mnode/impl/src/mndStable.c
浏览文件 @
17a3469a
...
...
@@ -26,11 +26,11 @@
#define TSDB_STABLE_VER_NUM 1
#define TSDB_STABLE_RESERVE_SIZE 64
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pSt
able
);
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pSt
b
);
static
SSdbRow
*
mndStableActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pSt
able
);
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pSt
able
);
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldSt
able
,
SStableObj
*
pNewStable
);
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pSt
b
);
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pSt
b
);
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldSt
b
,
SStableObj
*
pNewStb
);
static
int32_t
mndProcessCreateStableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessAlterStableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropStableMsg
(
SMnodeMsg
*
pMsg
);
...
...
@@ -68,30 +68,30 @@ int32_t mndInitStable(SMnode *pMnode) {
void
mndCleanupStable
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pSt
able
)
{
int32_t
size
=
sizeof
(
SStableObj
)
+
(
pSt
able
->
numOfColumns
+
pStable
->
numOfTags
)
*
sizeof
(
SSchema
);
static
SSdbRaw
*
mndStableActionEncode
(
SStableObj
*
pSt
b
)
{
int32_t
size
=
sizeof
(
SStableObj
)
+
(
pSt
b
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STABLE
,
TSDB_STABLE_VER_NUM
,
size
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSt
able
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
able
->
createdTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
able
->
updateTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
able
->
uid
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
able
->
version
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSt
able
->
numOfColumns
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSt
able
->
numOfTags
)
for
(
int32_t
i
=
0
;
i
<
pSt
able
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
able
->
columnSchema
[
i
];
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSt
b
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
b
->
createdTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
b
->
updateTime
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
b
->
uid
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pSt
b
->
version
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSt
b
->
numOfColumns
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSt
b
->
numOfTags
)
for
(
int32_t
i
=
0
;
i
<
pSt
b
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
b
->
columnSchema
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pSt
able
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
able
->
tagSchema
[
i
];
for
(
int32_t
i
=
0
;
i
<
pSt
b
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
b
->
tagSchema
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
);
...
...
@@ -116,31 +116,31 @@ static SSdbRow *mndStableActionDecode(SSdbRaw *pRaw) {
int32_t
size
=
sizeof
(
SStableObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
SStableObj
*
pSt
able
=
sdbGetRowObj
(
pRow
);
if
(
pSt
able
==
NULL
)
return
NULL
;
SStableObj
*
pSt
b
=
sdbGetRowObj
(
pRow
);
if
(
pSt
b
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pSt
able
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
createdTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
updateTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
uid
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
version
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
numOfColumns
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
able
->
numOfTags
)
pSt
able
->
columnSchema
=
calloc
(
pStable
->
numOfColumns
,
sizeof
(
SSchema
));
pSt
able
->
tagSchema
=
calloc
(
pStable
->
numOfTags
,
sizeof
(
SSchema
));
for
(
int32_t
i
=
0
;
i
<
pSt
able
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
able
->
columnSchema
[
i
];
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pSt
b
->
name
,
TSDB_TABLE_NAME_LEN
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
createdTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
updateTime
)
SDB_GET_INT64
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
uid
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
version
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
numOfColumns
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSt
b
->
numOfTags
)
pSt
b
->
columnSchema
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pSt
b
->
tagSchema
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
for
(
int32_t
i
=
0
;
i
<
pSt
b
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
b
->
columnSchema
[
i
];
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
type
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
colId
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
bytes
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pSt
able
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
able
->
tagSchema
[
i
];
for
(
int32_t
i
=
0
;
i
<
pSt
b
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pSt
b
->
tagSchema
[
i
];
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
type
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
colId
);
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pSchema
->
bytes
);
...
...
@@ -152,37 +152,37 @@ static SSdbRow *mndStableActionDecode(SSdbRaw *pRaw) {
return
pRow
;
}
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pSt
able
)
{
mTrace
(
"stable:%s, perform insert action"
,
pSt
able
->
name
);
static
int32_t
mndStableActionInsert
(
SSdb
*
pSdb
,
SStableObj
*
pSt
b
)
{
mTrace
(
"stable:%s, perform insert action"
,
pSt
b
->
name
);
return
0
;
}
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pSt
able
)
{
mTrace
(
"stable:%s, perform delete action"
,
pSt
able
->
name
);
static
int32_t
mndStableActionDelete
(
SSdb
*
pSdb
,
SStableObj
*
pSt
b
)
{
mTrace
(
"stable:%s, perform delete action"
,
pSt
b
->
name
);
return
0
;
}
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldSt
able
,
SStableObj
*
pNewStable
)
{
mTrace
(
"stable:%s, perform update action"
,
pOldSt
able
->
name
);
atomic_exchange_32
(
&
pOldSt
able
->
updateTime
,
pNewStable
->
updateTime
);
atomic_exchange_32
(
&
pOldSt
able
->
version
,
pNewStable
->
version
);
static
int32_t
mndStableActionUpdate
(
SSdb
*
pSdb
,
SStableObj
*
pOldSt
b
,
SStableObj
*
pNewStb
)
{
mTrace
(
"stable:%s, perform update action"
,
pOldSt
b
->
name
);
atomic_exchange_32
(
&
pOldSt
b
->
updateTime
,
pNewStb
->
updateTime
);
atomic_exchange_32
(
&
pOldSt
b
->
version
,
pNewStb
->
version
);
taosWLockLatch
(
&
pOldSt
able
->
lock
);
int32_t
numOfTags
=
pNewSt
able
->
numOfTags
;
taosWLockLatch
(
&
pOldSt
b
->
lock
);
int32_t
numOfTags
=
pNewSt
b
->
numOfTags
;
int32_t
tagSize
=
numOfTags
*
sizeof
(
SSchema
);
int32_t
numOfColumns
=
pNewSt
able
->
numOfColumns
;
int32_t
numOfColumns
=
pNewSt
b
->
numOfColumns
;
int32_t
columnSize
=
numOfColumns
*
sizeof
(
SSchema
);
if
(
pOldSt
able
->
numOfTags
<
numOfTags
)
{
pOldSt
able
->
tagSchema
=
malloc
(
tagSize
);
if
(
pOldSt
b
->
numOfTags
<
numOfTags
)
{
pOldSt
b
->
tagSchema
=
malloc
(
tagSize
);
}
if
(
pOldSt
able
->
numOfColumns
<
numOfColumns
)
{
pOldSt
able
->
columnSchema
=
malloc
(
columnSize
);
if
(
pOldSt
b
->
numOfColumns
<
numOfColumns
)
{
pOldSt
b
->
columnSchema
=
malloc
(
columnSize
);
}
memcpy
(
pOldSt
able
->
tagSchema
,
pNewStable
->
tagSchema
,
tagSize
);
memcpy
(
pOldSt
able
->
columnSchema
,
pNewStable
->
columnSchema
,
columnSize
);
taosWUnLockLatch
(
&
pOldSt
able
->
lock
);
memcpy
(
pOldSt
b
->
tagSchema
,
pNewStb
->
tagSchema
,
tagSize
);
memcpy
(
pOldSt
b
->
columnSchema
,
pNewStb
->
columnSchema
,
columnSize
);
taosWUnLockLatch
(
&
pOldSt
b
->
lock
);
return
0
;
}
...
...
@@ -293,15 +293,15 @@ static int32_t mndGetNumOfStables(SMnode *pMnode, char *dbName, int32_t *pNumOfS
int32_t
numOfStables
=
0
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SStableObj
*
pSt
able
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pSt
able
);
SStableObj
*
pSt
b
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pSt
b
);
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pSt
able
->
db
,
dbName
)
==
0
)
{
if
(
strcmp
(
pSt
b
->
db
,
dbName
)
==
0
)
{
numOfStables
++
;
}
sdbRelease
(
pSdb
,
pSt
able
);
sdbRelease
(
pSdb
,
pSt
b
);
}
*
pNumOfStables
=
numOfStables
;
...
...
@@ -374,7 +374,7 @@ static int32_t mndRetrieveStables(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SStableObj
*
pSt
able
=
NULL
;
SStableObj
*
pSt
b
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
...
...
@@ -384,36 +384,36 @@ static int32_t mndRetrieveStables(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STABLE
,
pShow
->
pIter
,
(
void
**
)
&
pSt
able
);
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STABLE
,
pShow
->
pIter
,
(
void
**
)
&
pSt
b
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
strncmp
(
pSt
able
->
name
,
prefix
,
prefixLen
)
!=
0
)
{
sdbRelease
(
pSdb
,
pSt
able
);
if
(
strncmp
(
pSt
b
->
name
,
prefix
,
prefixLen
)
!=
0
)
{
sdbRelease
(
pSdb
,
pSt
b
);
continue
;
}
cols
=
0
;
char
stableName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
memcpy
(
stableName
,
pSt
able
->
name
+
prefixLen
,
TSDB_TABLE_FNAME_LEN
-
prefixLen
);
memcpy
(
stableName
,
pSt
b
->
name
+
prefixLen
,
TSDB_TABLE_FNAME_LEN
-
prefixLen
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
stableName
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pSt
able
->
createdTime
;
*
(
int64_t
*
)
pWrite
=
pSt
b
->
createdTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pSt
able
->
numOfColumns
;
*
(
int16_t
*
)
pWrite
=
pSt
b
->
numOfColumns
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pSt
able
->
numOfTags
;
*
(
int16_t
*
)
pWrite
=
pSt
b
->
numOfTags
;
cols
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pSt
able
);
sdbRelease
(
pSdb
,
pSt
b
);
}
pShow
->
numOfReads
+=
numOfRows
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录