Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
49b750bd
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,发现更多精彩内容 >>
提交
49b750bd
编写于
10月 19, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/TD-6129 add table delete logic for json tag table
上级
fd7f1268
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
27 deletion
+70
-27
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+70
-27
未找到文件。
src/tsdb/src/tsdbMeta.c
浏览文件 @
49b750bd
...
...
@@ -1493,13 +1493,43 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
return
buf
;
}
static
SArray
*
getJsonTagTableList
(
STable
*
pTable
){
SArray
**
pRecord
=
taosHashIterate
(
pTable
->
jsonKeyMap
,
NULL
);
SArray
*
tablist
=
taosArrayInit
(
32
,
sizeof
(
JsonMapValue
));
while
(
pRecord
){
SArray
*
tallistOld
=
*
pRecord
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tallistOld
);
++
i
)
{
// sort to elimate dumplicate
void
*
element
=
taosArrayGet
(
tallistOld
,
i
);
void
*
pFind
=
taosArraySearch
(
tablist
,
element
,
tsdbCompareJsonMapValue
,
TD_EQ
);
if
(
pFind
==
NULL
){
void
*
p
=
taosArraySearch
(
tablist
,
element
,
tsdbCompareJsonMapValue
,
TD_GE
);
if
(
p
==
NULL
){
taosArrayPush
(
tablist
,
element
);
}
else
{
taosArrayInsert
(
tablist
,
TARRAY_ELEM_IDX
(
tablist
,
p
),
element
);
}
}
}
pRecord
=
taosHashIterate
(
pTable
->
jsonKeyMap
,
pRecord
);
}
return
tablist
;
}
static
int
tsdbGetTableEncodeSize
(
int8_t
act
,
STable
*
pTable
)
{
int
tlen
=
0
;
if
(
act
==
TSDB_UPDATE_META
)
{
tlen
=
sizeof
(
SListNode
)
+
sizeof
(
SActObj
)
+
sizeof
(
SActCont
)
+
tsdbEncodeTable
(
NULL
,
pTable
)
+
sizeof
(
TSCKSUM
);
}
else
{
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
tlen
=
(
int
)((
sizeof
(
SListNode
)
+
sizeof
(
SActObj
))
*
(
SL_SIZE
(
pTable
->
pIndex
)
+
1
));
int
tableSize
=
0
;
if
(
pTable
->
tagSchema
->
columns
[
0
].
type
==
TSDB_DATA_TYPE_JSON
){
SArray
*
tablist
=
getJsonTagTableList
(
pTable
);
tableSize
=
taosArrayGetSize
(
tablist
);
}
else
{
tableSize
=
SL_SIZE
(
pTable
->
pIndex
);
}
tlen
=
(
int
)((
sizeof
(
SListNode
)
+
sizeof
(
SActObj
))
*
(
tableSize
+
1
));
}
else
{
tlen
=
sizeof
(
SListNode
)
+
sizeof
(
SActObj
);
}
...
...
@@ -1539,19 +1569,29 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
void
*
pBuf
=
buf
;
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
pIndex
);
if
(
pIter
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
pTable
->
tagSchema
->
columns
[
0
].
type
==
TSDB_DATA_TYPE_JSON
){
SArray
*
tablist
=
getJsonTagTableList
(
pTable
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tablist
);
++
i
)
{
JsonMapValue
*
p
=
taosArrayGet
(
tablist
,
i
);
ASSERT
(
TABLE_TYPE
((
STable
*
)(
p
->
table
))
==
TSDB_CHILD_TABLE
);
pBuf
=
tsdbInsertTableAct
(
pRepo
,
TSDB_DROP_META
,
pBuf
,
p
->
table
);
}
taosArrayDestroy
(
tablist
);
}
else
{
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
pIndex
);
if
(
pIter
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
while
(
tSkipListIterNext
(
pIter
))
{
STable
*
tTable
=
(
STable
*
)
SL_GET_NODE_DATA
(
tSkipListIterGet
(
pIter
));
ASSERT
(
TABLE_TYPE
(
tTable
)
==
TSDB_CHILD_TABLE
);
pBuf
=
tsdbInsertTableAct
(
pRepo
,
TSDB_DROP_META
,
pBuf
,
tTable
);
}
while
(
tSkipListIterNext
(
pIter
))
{
STable
*
tTable
=
(
STable
*
)
SL_GET_NODE_DATA
(
tSkipListIterGet
(
pIter
));
ASSERT
(
TABLE_TYPE
(
tTable
)
==
TSDB_CHILD_TABLE
);
pBuf
=
tsdbInsertTableAct
(
pRepo
,
TSDB_DROP_META
,
pBuf
,
tTable
);
}
tSkipListDestroyIter
(
pIter
);
tSkipListDestroyIter
(
pIter
);
}
}
pBuf
=
tsdbInsertTableAct
(
pRepo
,
TSDB_DROP_META
,
pBuf
,
pTable
);
...
...
@@ -1562,25 +1602,28 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
static
int
tsdbRmTableFromMeta
(
STsdbRepo
*
pRepo
,
STable
*
pTable
)
{
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
pIndex
);
if
(
pIter
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
tsdbWLockRepoMeta
(
pRepo
);
while
(
tSkipListIterNext
(
pIter
))
{
STable
*
tTable
=
(
STable
*
)
SL_GET_NODE_DATA
(
tSkipListIterGet
(
pIter
));
tsdbRemoveTableFromMeta
(
pRepo
,
tTable
,
false
,
false
);
if
(
pTable
->
tagSchema
->
columns
[
0
].
type
==
TSDB_DATA_TYPE_JSON
){
SArray
*
tablist
=
getJsonTagTableList
(
pTable
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tablist
);
++
i
)
{
JsonMapValue
*
p
=
taosArrayGet
(
tablist
,
i
);
tsdbRemoveTableFromMeta
(
pRepo
,
p
->
table
,
false
,
false
);
}
taosArrayDestroy
(
tablist
);
}
else
{
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
pIndex
);
if
(
pIter
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
while
(
tSkipListIterNext
(
pIter
))
{
STable
*
tTable
=
(
STable
*
)
SL_GET_NODE_DATA
(
tSkipListIterGet
(
pIter
));
tsdbRemoveTableFromMeta
(
pRepo
,
tTable
,
false
,
false
);
}
tSkipListDestroyIter
(
pIter
);
}
tsdbRemoveTableFromMeta
(
pRepo
,
pTable
,
false
,
false
);
tsdbUnlockRepoMeta
(
pRepo
);
tSkipListDestroyIter
(
pIter
);
}
else
{
if
((
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
)
&&
pTable
->
cqhandle
)
pRepo
->
appH
.
cqDropFunc
(
pTable
->
cqhandle
);
tsdbRemoveTableFromMeta
(
pRepo
,
pTable
,
true
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录