Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
06db5c54
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看板
提交
06db5c54
编写于
2月 20, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
super table sdb
上级
95f748ca
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
191 addition
and
261 deletion
+191
-261
src/inc/mnode.h
src/inc/mnode.h
+3
-8
src/mnode/inc/mgmtSuperTable.h
src/mnode/inc/mgmtSuperTable.h
+1
-4
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+2
-3
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+1
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+6
-8
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+178
-237
未找到文件。
src/inc/mnode.h
浏览文件 @
06db5c54
...
...
@@ -150,17 +150,13 @@ typedef struct SSuperTableObj {
int32_t
vgId
;
int64_t
createdTime
;
int32_t
sversion
;
int32_t
numOfTags
;
int32_t
numOfMeters
;
int32_t
numOfTables
;
int32_t
numOfColumns
;
int32_t
schemaSize
;
int32_t
numOfTags
;
int8_t
reserved
[
7
];
int8_t
updateEnd
[
1
];
pthread_rwlock_t
rwLock
;
int16_t
nextColId
;
int8_t
*
schema
;
SSchema
*
schema
;
}
SSuperTableObj
;
typedef
struct
{
...
...
@@ -244,7 +240,6 @@ typedef struct _db_obj {
char
reserved
[
16
];
char
updateEnd
[
1
];
STabObj
*
pMetric
;
struct
_db_obj
*
prev
,
*
next
;
SVgObj
*
pHead
;
// empty vgroup first
SVgObj
*
pTail
;
// empty vgroup end
...
...
src/mnode/inc/mgmtSuperTable.h
浏览文件 @
06db5c54
...
...
@@ -31,7 +31,7 @@ void mgmtCleanUpSuperTables();
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
);
SSuperTableObj
*
mgmtGetSuperTable
(
char
*
tableId
);
int32_t
mgmtFind
TagCol
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtFind
SuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ntags
);
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
pTable
,
char
*
tagName
);
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
pTable
,
char
*
oldTagName
,
char
*
newTagName
);
...
...
@@ -40,9 +40,6 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *col
SSchema
*
mgmtGetSuperTableSchema
(
SSuperTableObj
*
pTable
);
#ifdef __cplusplus
}
#endif
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
06db5c54
...
...
@@ -36,10 +36,9 @@ int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
int32_t
mgmtGetTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
void
mgmtCleanUpMeters
();
SSchema
*
mgmtGetTableSchema
(
STabObj
*
pTable
);
// get schema for a meter
int32_t
mgmtAddMeterIntoMetric
(
S
TabObj
*
pMetric
,
STab
Obj
*
pTable
);
int32_t
mgmtRemoveMeterFromMetric
(
S
TabObj
*
pMetric
,
STab
Obj
*
pTable
);
int32_t
mgmtAddMeterIntoMetric
(
S
SuperTableObj
*
pMetric
,
SChildTable
Obj
*
pTable
);
int32_t
mgmtRemoveMeterFromMetric
(
S
SuperTableObj
*
pMetric
,
SChildTable
Obj
*
pTable
);
int32_t
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
06db5c54
...
...
@@ -323,7 +323,7 @@ SChildTableObj* mgmtGetChildTable(char *tableId) {
}
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
)
{
// int col = mgmtFind
TagCol
(pTable->superTable, tagName);
// int col = mgmtFind
SuperTableTagIndex
(pTable->superTable, tagName);
// if (col < 0 || col > pTable->superTable->numOfTags) {
// return TSDB_CODE_APP_ERROR;
// }
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
06db5c54
...
...
@@ -86,7 +86,6 @@ int32_t mgmtInitDbs() {
pDb
->
numOfMetrics
=
0
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_READY
;
pDb
->
vgTimer
=
NULL
;
pDb
->
pMetric
=
NULL
;
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
!=
NULL
)
mgmtAddDbIntoAcct
(
pAcct
,
pDb
);
...
...
@@ -265,12 +264,12 @@ bool mgmtCheckDropDbFinished(SDbObj *pDb) {
void
mgmtDropDbFromSdb
(
SDbObj
*
pDb
)
{
while
(
pDb
->
pHead
)
mgmtDropVgroup
(
pDb
,
pDb
->
pHead
);
STabObj
*
pMetric
=
pDb
->
pMetric
;
while
(
pMetric
)
{
STab
Obj
*
pNext
=
pMetric
->
next
;
mgmtDropTable
(
pDb
,
pMetric
->
meterId
,
0
);
pMetric
=
pNext
;
}
// SSuperTableObj *pMetric = pDb->pSTable
;
//
while (pMetric) {
// SSuperTable
Obj *pNext = pMetric->next;
//
mgmtDropTable(pDb, pMetric->meterId, 0);
//
pMetric = pNext;
//
}
mPrint
(
"db:%s all meters drop finished"
,
pDb
->
name
);
sdbDeleteRow
(
tsDbSdb
,
pDb
);
...
...
@@ -734,7 +733,6 @@ void *mgmtDbActionInsert(void *row, char *str, int32_t size, int32_t *ssize) {
pDb
->
numOfVgroups
=
0
;
pDb
->
numOfTables
=
0
;
pDb
->
vgTimer
=
NULL
;
pDb
->
pMetric
=
NULL
;
mgmtAddDbIntoAcct
(
pAcct
,
pDb
);
return
NULL
;
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
06db5c54
...
...
@@ -15,15 +15,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtUtil.h"
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtVgroup.h"
#include "mgmtTable.h"
#include "taosmsg.h"
#include "tast.h"
#include "textbuffer.h"
...
...
@@ -33,45 +24,28 @@
#include "tsqlfunction.h"
#include "ttime.h"
#include "tstatus.h"
#include "sdb.h"
#include "mgmtSuperTable.h"
#include "mgmtChildTable.h"
#include "tutil.h"
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
+
1
];
char
type
;
uint32_t
cols
;
char
data
[];
}
SMeterBatchUpdateMsg
;
typedef
struct
{
int32_t
col
;
int32_t
pos
;
SSchema
schema
;
}
SchemaUnit
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
+
1
];
char
action
;
int32_t
dataSize
;
char
data
[];
}
SMeterUpdateMsg
;
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtGrant.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtUtil.h"
#include "mgmtVgroup.h"
void
*
tsSuperTableSdb
;
void
*
(
*
mgmtSuperTableActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
(
*
mgmtSuperTableActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
);
void
*
mgmtSuperTableActionInsert
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionDelete
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionUpdate
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionEncode
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionDecode
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
);
static
void
mgmtDestroySuperTable
(
SSuperTableObj
*
pTable
)
{
free
(
pTable
->
schema
);
...
...
@@ -88,51 +62,56 @@ static void mgmtSuperTableActionInit() {
mgmtSuperTableActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtSuperTableActionDestroy
;
}
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
row
;
int
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int
32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
memcpy
(
pTable
,
str
,
tsize
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
pTable
->
schemaSize
);
memcpy
(
pTable
->
schema
,
str
+
tsize
,
pTable
->
schemaSize
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
);
memcpy
(
pTable
->
schema
,
str
+
tsize
,
schemaSize
);
return
NULL
;
}
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
row
;
mgmtDestroySuperTable
(
pTable
);
return
NULL
;
}
void
*
mgmtSuperTableActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionInsert
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
return
NULL
;
}
void
*
mgmtSuperTableActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionDelete
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
return
NULL
;
}
void
*
mgmtSuperTableActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionUpdate
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
return
mgmtSuperTableActionReset
(
row
,
str
,
size
,
NULL
);
}
void
*
mgmtSuperTableActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionEncode
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
row
;
assert
(
row
!=
NULL
&&
str
!=
NULL
);
int
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
if
(
size
<
tsize
+
pTable
->
schemaSize
+
1
)
{
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
if
(
size
<
tsize
+
schemaSize
+
1
)
{
*
ssize
=
-
1
;
return
NULL
;
}
memcpy
(
str
,
pTable
,
tsize
);
memcpy
(
str
+
tsize
,
pTable
->
schema
,
pTable
->
schemaSize
);
*
ssize
=
tsize
+
pTable
->
schemaSize
;
memcpy
(
str
+
tsize
,
pTable
->
schema
,
schemaSize
);
*
ssize
=
tsize
+
schemaSize
;
return
NULL
;
}
void
*
mgmtSuperTableActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableActionDecode
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
assert
(
str
!=
NULL
);
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
malloc
(
sizeof
(
SSuperTableObj
));
...
...
@@ -141,24 +120,25 @@ void *mgmtSuperTableActionDecode(void *row, char *str, int size, int *ssize) {
}
memset
(
pTable
,
0
,
sizeof
(
STabObj
));
int
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int
32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
if
(
size
<
tsize
)
{
mgmtDestroySuperTable
(
pTable
);
return
NULL
;
}
memcpy
(
pTable
,
str
,
tsize
);
pTable
->
schema
=
malloc
(
pTable
->
schemaSize
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
pTable
->
schema
=
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroySuperTable
(
pTable
);
return
NULL
;
}
memcpy
(
pTable
->
schema
,
str
+
tsize
,
pTable
->
schemaSize
);
memcpy
(
pTable
->
schema
,
str
+
tsize
,
schemaSize
);
return
(
void
*
)
pTable
;
}
void
*
mgmtSuperTableAction
(
char
action
,
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtSuperTableAction
(
char
action
,
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
if
(
mgmtSuperTableActionFp
[(
uint8_t
)
action
]
!=
NULL
)
{
return
(
*
(
mgmtSuperTableActionFp
[(
uint8_t
)
action
]))(
row
,
str
,
size
,
ssize
);
}
...
...
@@ -170,13 +150,12 @@ int32_t mgmtInitSuperTables() {
void
*
pLastNode
=
NULL
;
SSuperTableObj
*
pTable
=
NULL
;
// TODO: Make sure this function only run once
mgmtSuperTableActionInit
();
tsSuperTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
STabObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_MAX_SQL_LEN
,
"
meters
"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtSuperTableAction
);
"
stable
"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtSuperTableAction
);
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init
meter
data"
);
mError
(
"failed to init
super table
data"
);
return
-
1
;
}
...
...
@@ -194,7 +173,7 @@ int32_t mgmtInitSuperTables() {
pNode
=
pLastNode
;
continue
;
}
pTable
->
numOf
Meter
s
=
0
;
pTable
->
numOf
Table
s
=
0
;
}
mgmtSetVgroupIdPool
();
...
...
@@ -207,44 +186,44 @@ void mgmtCleanUpSuperTables() {
}
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
int
numOfTables
=
sdbGetNumOfRows
(
tsSuperTableSdb
);
int
32_t
numOfTables
=
sdbGetNumOfRows
(
tsSuperTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_TABLES
)
{
mError
(
"super table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
meterId
,
numOfTables
,
TSDB_MAX_TABLES
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
SSuperTableObj
*
p
Metric
=
(
SSuperTableObj
*
)
calloc
(
sizeof
(
SSuperTableObj
),
1
);
if
(
p
Metric
==
NULL
)
{
SSuperTableObj
*
p
Stable
=
(
SSuperTableObj
*
)
calloc
(
sizeof
(
SSuperTableObj
),
1
);
if
(
p
Stable
==
NULL
)
{
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
p
Metric
->
tableId
,
pCreate
->
meterId
);
p
Metric
->
createdTime
=
taosGetTimestampMs
();
p
Metric
->
vgId
=
0
;
p
Metric
->
sid
=
0
;
p
Metric
->
uid
=
(((
uint64_t
)
pMetric
->
createdTime
)
<<
16
)
+
((
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
p
Metric
->
sversion
=
0
;
p
Metric
->
numOfColumns
=
pCreate
->
numOfColumns
;
p
Metric
->
numOfTags
=
pCreate
->
numOfTags
;
p
Metric
->
numOfMeter
s
=
0
;
int
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
pMetric
->
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
p
Metric
->
schema
=
(
int8_t
*
)
calloc
(
1
,
pMetric
->
schemaSize
);
if
(
p
Metric
->
schema
==
NULL
)
{
free
(
p
Metric
);
strcpy
(
p
Stable
->
tableId
,
pCreate
->
meterId
);
p
Stable
->
createdTime
=
taosGetTimestampMs
();
p
Stable
->
vgId
=
0
;
p
Stable
->
sid
=
0
;
p
Stable
->
uid
=
(((
uint64_t
)
pStable
->
createdTime
)
<<
16
)
+
((
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
p
Stable
->
sversion
=
0
;
p
Stable
->
numOfColumns
=
pCreate
->
numOfColumns
;
p
Stable
->
numOfTags
=
pCreate
->
numOfTags
;
p
Stable
->
numOfTable
s
=
0
;
int
32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
p
Stable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
if
(
p
Stable
->
schema
==
NULL
)
{
free
(
p
Stable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meterId
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
p
Metric
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
p
Stable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
p
Metric
->
nextColId
=
0
;
for
(
int
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
SSchema
*
tschema
=
(
SSchema
*
)
p
Metric
->
schema
;
tschema
[
col
].
colId
=
p
Metric
->
nextColId
++
;
p
Stable
->
nextColId
=
0
;
for
(
int
32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
SSchema
*
tschema
=
(
SSchema
*
)
p
Stable
->
schema
;
tschema
[
col
].
colId
=
p
Stable
->
nextColId
++
;
}
if
(
sdbInsertRow
(
tsSuperTableSdb
,
p
Metric
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsSuperTableSdb
,
p
Stable
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meterId
);
return
TSDB_CODE_SDB_ERROR
;
}
...
...
@@ -261,9 +240,9 @@ SSuperTableObj* mgmtGetSuperTable(char *tableId) {
return
(
SSuperTableObj
*
)
sdbGetRow
(
tsSuperTableSdb
,
tableId
);
}
int32_t
mgmtFind
TagCol
(
SSuperTableObj
*
pMetric
,
const
char
*
tagName
)
{
for
(
int
i
=
0
;
i
<
pMetric
->
numOfTags
;
i
++
)
{
SSchema
*
schema
=
(
SSchema
*
)(
p
Metric
->
schema
+
(
pMetric
->
numOfColumns
+
i
)
*
sizeof
(
SSchema
));
int32_t
mgmtFind
SuperTableTagIndex
(
SSuperTableObj
*
pStable
,
const
char
*
tagName
)
{
for
(
int
32_t
i
=
0
;
i
<
pStable
->
numOfTags
;
i
++
)
{
SSchema
*
schema
=
(
SSchema
*
)(
p
Stable
->
schema
+
(
pStable
->
numOfColumns
+
i
)
*
sizeof
(
SSchema
));
if
(
strcasecmp
(
tagName
,
schema
->
name
)
==
0
)
{
return
i
;
}
...
...
@@ -272,143 +251,128 @@ int32_t mgmtFindTagCol(SSuperTableObj *pMetric, const char *tagName) {
return
-
1
;
}
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
p
Metric
,
SSchema
schema
[],
int32_t
ntags
)
{
if
(
p
Metric
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
p
Stable
,
SSchema
schema
[],
int32_t
ntags
)
{
if
(
p
Stable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
return
TSDB_CODE_APP_ERROR
;
}
// check if schemas have the same name
for
(
int
i
=
1
;
i
<
ntags
;
i
++
)
{
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
for
(
int
32_t
i
=
1
;
i
<
ntags
;
i
++
)
{
for
(
int
32_t
j
=
0
;
j
<
i
;
j
++
)
{
if
(
strcasecmp
(
schema
[
i
].
name
,
schema
[
j
].
name
)
==
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
}
}
for
(
int
i
=
0
;
i
<
ntags
;
i
++
)
{
if
(
mgmtFindTagCol
(
pMetric
,
schema
[
i
].
name
)
>=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"meter: %s not belongs to any database"
,
pStable
->
tableId
)
;
return
TSDB_CODE_APP_ERROR
;
}
uint32_t
size
=
sizeof
(
SMeterBatchUpdateMsg
)
+
sizeof
(
SSchema
)
*
ntags
;
SMeterBatchUpdateMsg
*
msg
=
(
SMeterBatchUpdateMsg
*
)
malloc
(
size
);
memset
(
msg
,
0
,
size
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"DB: %s not belongs to andy account"
,
pDb
->
name
);
return
TSDB_CODE_APP_ERROR
;
}
memcpy
(
msg
->
meterId
,
pMetric
->
tableId
,
TSDB_TABLE_ID_LEN
);
msg
->
type
=
SDB_TYPE_INSERT
;
msg
->
cols
=
ntags
;
memcpy
(
msg
->
data
,
schema
,
sizeof
(
SSchema
)
*
ntags
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ntags
);
int32_t
ret
=
sdbBatchUpdateRow
(
tsSuperTableSdb
,
msg
,
size
);
tfree
(
msg
);
//
// if (msg->type == SDB_TYPE_INSERT) { // Insert schema
// uint32_t total_cols = pTable->numOfColumns + pTable->numOfTags;
// pTable->schema = realloc(pTable->schema, (total_cols + msg->cols) * sizeof(SSchema));
// pTable->schemaSize = (total_cols + msg->cols) * sizeof(SSchema);
// pTable->numOfTags += msg->cols;
// memcpy(pTable->schema + total_cols * sizeof(SSchema), msg->data, msg->cols * sizeof(SSchema));
//
// }
memmove
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
ntags
),
pStable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
,
sizeof
(
SSchema
)
*
pStable
->
numOfTags
);
memcpy
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
SSchema
)
*
ntags
);
if
(
ret
<
0
)
{
mError
(
"Failed to add tag column %s to table %s"
,
schema
[
0
].
name
,
pMetric
->
tableId
);
return
TSDB_CODE_APP_ERROR
;
SSchema
*
tschema
=
(
SSchema
*
)
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
);
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
tschema
[
i
].
colId
=
pStable
->
nextColId
++
;
}
mTrace
(
"Succeed to add tag column %s to table %s"
,
schema
[
0
].
name
,
pMetric
->
tableId
);
pStable
->
numOfColumns
+=
ntags
;
pStable
->
sversion
++
;
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ntags
*
pStable
->
numOfTables
);
sdbUpdateRow
(
tsSuperTableSdb
,
pStable
,
0
,
1
);
mTrace
(
"Succeed to add tag column %s to table %s"
,
schema
[
0
].
name
,
pStable
->
tableId
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
p
Metric
,
char
*
tagName
)
{
int
col
=
mgmtFindTagCol
(
pMetric
,
tagName
);
if
(
col
<=
0
||
col
>=
p
Metric
->
numOfTags
)
{
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
p
Stable
,
char
*
tagName
)
{
int
32_t
col
=
mgmtFindSuperTableTagIndex
(
pStable
,
tagName
);
if
(
col
<=
0
||
col
>=
p
Stable
->
numOfTags
)
{
return
TSDB_CODE_APP_ERROR
;
}
// Pack message to do batch update
uint32_t
size
=
sizeof
(
SMeterBatchUpdateMsg
)
+
sizeof
(
SchemaUnit
);
SMeterBatchUpdateMsg
*
msg
=
(
SMeterBatchUpdateMsg
*
)
malloc
(
size
);
memset
(
msg
,
0
,
size
);
memcpy
(
msg
->
meterId
,
pMetric
->
tableId
,
TSDB_TABLE_ID_LEN
);
msg
->
type
=
SDB_TYPE_DELETE
;
msg
->
cols
=
1
;
//
// // Make sure the order of tag columns
// SchemaUnit *schemaUnit = (SchemaUnit *)(msg->data);
// int col = schemaUnit->col;
// assert(col > 0 && col < pTable->numOfTags);
// if (col < pTable->numOfTags - 1) {
// memmove(pTable->schema + sizeof(SSchema) * (pTable->numOfColumns + col),
// pTable->schema + sizeof(SSchema) * (pTable->numOfColumns + col + 1),
// pTable->schemaSize - (sizeof(SSchema) * (pTable->numOfColumns + col + 1)));
// }
// pTable->schemaSize -= sizeof(SSchema);
// pTable->numOfTags--;
// pTable->schema = realloc(pTable->schema, pTable->schemaSize);
//
((
SchemaUnit
*
)
(
msg
->
data
))
->
col
=
col
;
((
SchemaUnit
*
)
(
msg
->
data
))
->
pos
=
mgmtGetTagsLength
(
pMetric
,
col
)
+
TSDB_TABLE_ID_LEN
;
((
SchemaUnit
*
)
(
msg
->
data
))
->
schema
=
*
(
SSchema
*
)
(
pMetric
->
schema
+
sizeof
(
SSchema
)
*
(
pMetric
->
numOfColumns
+
col
));
int32_t
ret
=
sdbBatchUpdateRow
(
tsSuperTableSdb
,
msg
,
size
);
tfree
(
msg
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"table: %s not belongs to any database"
,
pStable
->
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
if
(
ret
<
0
)
{
mError
(
"Failed to drop tag column: %d from table: %s"
,
col
,
pMetric
->
tableId
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"DB: %s not belongs to any account"
,
pDb
->
name
);
return
TSDB_CODE_APP_ERROR
;
}
mTrace
(
"Succeed to drop tag column: %d from table: %s"
,
col
,
pMetric
->
tableId
);
memmove
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SSchema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfTags
--
;
pStable
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
);
sdbUpdateRow
(
tsSuperTableSdb
,
pStable
,
0
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
p
Metric
,
char
*
oldTagName
,
char
*
newTagName
)
{
int
col
=
mgmtFindTagCol
(
pMetric
,
oldTagName
);
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
p
Stable
,
char
*
oldTagName
,
char
*
newTagName
)
{
int
32_t
col
=
mgmtFindSuperTableTagIndex
(
pStable
,
oldTagName
);
if
(
col
<
0
)
{
// Tag name does not exist
mError
(
"Failed to modify table %s tag column, oname: %s, nname: %s"
,
p
Metric
->
tableId
,
oldTagName
,
newTagName
);
mError
(
"Failed to modify table %s tag column, oname: %s, nname: %s"
,
p
Stable
->
tableId
,
oldTagName
,
newTagName
);
return
TSDB_CODE_INVALID_MSG_TYPE
;
}
int
rowSize
=
0
;
int
32_t
rowSize
=
0
;
uint32_t
len
=
strlen
(
newTagName
);
if
(
col
>=
p
Metric
->
numOfTags
||
len
>=
TSDB_COL_NAME_LEN
||
mgmtFindTagCol
(
pMetric
,
newTagName
)
>=
0
)
{
if
(
col
>=
p
Stable
->
numOfTags
||
len
>=
TSDB_COL_NAME_LEN
||
mgmtFindSuperTableTagIndex
(
pStable
,
newTagName
)
>=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
// update
SSchema
*
schema
=
(
SSchema
*
)
(
p
Metric
->
schema
+
(
pMetric
->
numOfColumns
+
col
)
*
sizeof
(
SSchema
));
SSchema
*
schema
=
(
SSchema
*
)
(
p
Stable
->
schema
+
(
pStable
->
numOfColumns
+
col
)
*
sizeof
(
SSchema
));
strncpy
(
schema
->
name
,
newTagName
,
TSDB_COL_NAME_LEN
);
// Encode string
int
size
=
1
+
sizeof
(
STabObj
)
+
TSDB_MAX_BYTES_PER_ROW
;
int
32_t
size
=
1
+
sizeof
(
STabObj
)
+
TSDB_MAX_BYTES_PER_ROW
;
char
*
msg
=
(
char
*
)
malloc
(
size
);
if
(
msg
==
NULL
)
return
TSDB_CODE_APP_ERROR
;
memset
(
msg
,
0
,
size
);
mgmtSuperTableActionEncode
(
p
Metric
,
msg
,
size
,
&
rowSize
);
mgmtSuperTableActionEncode
(
p
Stable
,
msg
,
size
,
&
rowSize
);
int32_t
ret
=
sdbUpdateRow
(
tsSuperTableSdb
,
msg
,
rowSize
,
1
);
tfree
(
msg
);
if
(
ret
<
0
)
{
mError
(
"Failed to modify table %s tag column"
,
p
Metric
->
tableId
);
mError
(
"Failed to modify table %s tag column"
,
p
Stable
->
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
mTrace
(
"Succeed to modify table %s tag column"
,
p
Metric
->
tableId
);
mTrace
(
"Succeed to modify table %s tag column"
,
p
Stable
->
tableId
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtFindSuperTableColumnIndex
(
SSuperTableObj
*
pMetric
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pMetric
->
schema
;
for
(
int32_t
i
=
0
;
i
<
pMetric
->
numOfColumns
;
i
++
)
{
static
int32_t
mgmtFindSuperTableColumnIndex
(
SSuperTableObj
*
pStable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pStable
->
schema
;
for
(
int32_t
i
=
0
;
i
<
pStable
->
numOfColumns
;
i
++
)
{
if
(
strcasecmp
(
schema
[
i
].
name
,
colName
)
==
0
)
{
return
i
;
}
...
...
@@ -417,20 +381,20 @@ static int32_t mgmtFindSuperTableColumnIndex(SSuperTableObj *pMetric, char *colN
return
-
1
;
}
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
p
Metric
,
SSchema
schema
[],
in
t
ncols
)
{
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
p
Stable
,
SSchema
schema
[],
int32_
t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
for
(
int
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mgmtFindSuperTableColumnIndex
(
p
Metric
,
schema
[
i
].
name
)
>
0
)
{
for
(
int
32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mgmtFindSuperTableColumnIndex
(
p
Stable
,
schema
[
i
].
name
)
>
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
p
Metric
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
p
Stable
->
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"meter: %s not belongs to any database"
,
p
Metric
->
tableId
);
mError
(
"meter: %s not belongs to any database"
,
p
Stable
->
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -440,36 +404,36 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pMetric, SSchema schema[], int n
return
TSDB_CODE_APP_ERROR
;
}
pMetric
->
schema
=
realloc
(
pMetric
->
schema
,
pMetric
->
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
memmove
(
p
Metric
->
schema
+
sizeof
(
SSchema
)
*
(
pMetric
->
numOfColumns
+
ncols
),
p
Metric
->
schema
+
sizeof
(
SSchema
)
*
pMetric
->
numOfColumns
,
sizeof
(
SSchema
)
*
pMetric
->
numOfTags
);
memcpy
(
p
Metric
->
schema
+
sizeof
(
SSchema
)
*
pMetric
->
numOfColumns
,
schema
,
sizeof
(
SSchema
)
*
ncols
);
memmove
(
p
Stable
->
schema
+
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
ncols
),
p
Stable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
,
sizeof
(
SSchema
)
*
pStable
->
numOfTags
);
memcpy
(
p
Stable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
SSchema
)
*
ncols
);
SSchema
*
tschema
=
(
SSchema
*
)
(
p
Metric
->
schema
+
sizeof
(
SSchema
)
*
pMetric
->
numOfColumns
);
for
(
int
i
=
0
;
i
<
ncols
;
i
++
)
{
tschema
[
i
].
colId
=
p
Metric
->
nextColId
++
;
SSchema
*
tschema
=
(
SSchema
*
)
(
p
Stable
->
schema
+
sizeof
(
SSchema
)
*
pStable
->
numOfColumns
);
for
(
int
32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
tschema
[
i
].
colId
=
p
Stable
->
nextColId
++
;
}
pMetric
->
schemaSize
+=
sizeof
(
SSchema
)
*
ncols
;
pMetric
->
numOfColumns
+=
ncols
;
pMetric
->
sversion
++
;
pStable
->
numOfColumns
+=
ncols
;
pStable
->
sversion
++
;
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ncols
*
p
Metric
->
numOfMeter
s
);
sdbUpdateRow
(
tsSuperTableSdb
,
p
Metric
,
0
,
1
);
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ncols
*
p
Stable
->
numOfTable
s
);
sdbUpdateRow
(
tsSuperTableSdb
,
p
Stable
,
0
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
p
Metric
,
char
*
colName
)
{
int32_t
col
=
mgmtFindSuperTableColumnIndex
(
p
Metric
,
colName
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
p
Stable
,
char
*
colName
)
{
int32_t
col
=
mgmtFindSuperTableColumnIndex
(
p
Stable
,
colName
);
if
(
col
<
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
p
Metric
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
p
Stable
->
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"table: %s not belongs to any database"
,
p
Metric
->
tableId
);
mError
(
"table: %s not belongs to any database"
,
p
Stable
->
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -479,23 +443,23 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pMetric, char *colName) {
return
TSDB_CODE_APP_ERROR
;
}
memmove
(
pMetric
->
schema
+
sizeof
(
SSchema
)
*
col
,
pMetric
->
schema
+
sizeof
(
SSchema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pMetric
->
numOfColumns
+
pMetric
->
numOfTags
-
col
-
1
));
memmove
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SSchema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfColumns
--
;
pStable
->
sversion
++
;
pMetric
->
schemaSize
-=
sizeof
(
SSchema
);
pMetric
->
numOfColumns
--
;
pMetric
->
schema
=
realloc
(
pMetric
->
schema
,
pMetric
->
schemaSize
);
pMetric
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
);
pAcct
->
acctInfo
.
numOfTimeSeries
-=
(
p
Metric
->
numOfMeter
s
);
sdbUpdateRow
(
tsSuperTableSdb
,
p
Metric
,
0
,
1
);
pAcct
->
acctInfo
.
numOfTimeSeries
-=
(
p
Stable
->
numOfTable
s
);
sdbUpdateRow
(
tsSuperTableSdb
,
p
Stable
,
0
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int32_t
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int32_t
cols
=
0
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
...
...
@@ -538,7 +502,7 @@ int mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
pDb
->
numOfMetrics
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
...
...
@@ -546,10 +510,10 @@ int mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
int
32_t
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
)
{
int
32_t
numOfRows
=
0
;
char
*
pWrite
;
int
cols
=
0
;
int
32_t
cols
=
0
;
SSuperTableObj
*
pTable
=
NULL
;
char
prefix
[
20
]
=
{
0
};
int32_t
prefixLen
;
...
...
@@ -611,7 +575,7 @@ int mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int rows, SConnObj *pCo
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pTable
->
numOf
Meter
s
;
*
(
int32_t
*
)
pWrite
=
pTable
->
numOf
Table
s
;
cols
++
;
numOfRows
++
;
...
...
@@ -621,37 +585,14 @@ int mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int rows, SConnObj *pCo
return
numOfRows
;
}
int
mgmtAddMeterIntoMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
)
{
if
(
pTable
==
NULL
||
pMetric
==
NULL
)
return
-
1
;
pthread_rwlock_wrlock
(
&
(
pMetric
->
rwLock
));
// add meter into skip list
pTable
->
next
=
pMetric
->
pHead
;
pTable
->
prev
=
NULL
;
if
(
pMetric
->
pHead
)
pMetric
->
pHead
->
prev
=
pTable
;
pMetric
->
pHead
=
pTable
;
pMetric
->
numOfMeters
++
;
pthread_rwlock_unlock
(
&
(
pMetric
->
rwLock
));
int32_t
mgmtAddMeterIntoMetric
(
SSuperTableObj
*
pStable
,
SChildTableObj
*
pTable
)
{
if
(
pTable
!=
NULL
&&
pStable
!=
NULL
)
return
-
1
;
pStable
->
numOfTables
++
;
return
0
;
}
int
mgmtRemoveMeterFromMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
)
{
pthread_rwlock_wrlock
(
&
(
pMetric
->
rwLock
));
if
(
pTable
->
prev
)
pTable
->
prev
->
next
=
pTable
->
next
;
if
(
pTable
->
next
)
pTable
->
next
->
prev
=
pTable
->
prev
;
if
(
pTable
->
prev
==
NULL
)
pMetric
->
pHead
=
pTable
->
next
;
pMetric
->
numOfMeters
--
;
pthread_rwlock_unlock
(
&
(
pMetric
->
rwLock
));
int32_t
mgmtRemoveMeterFromMetric
(
SSuperTableObj
*
pStable
,
SChildTableObj
*
pTable
)
{
if
(
pTable
!=
NULL
&&
pStable
!=
NULL
)
return
-
1
;
pStable
->
numOfTables
--
;
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录