Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
ccd0e000
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ccd0e000
编写于
5月 08, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #1844
上级
56c54b90
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
27 deletion
+46
-27
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-0
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+45
-27
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
ccd0e000
...
...
@@ -95,6 +95,7 @@ typedef struct STable {
void
*
streamHandler
;
// TODO
TSKEY
lastKey
;
// lastkey inserted in this table, initialized as 0, TODO: make a structure
struct
STable
*
next
;
// TODO: remove the next
struct
STable
*
prev
;
}
STable
;
#define TSDB_GET_TABLE_LAST_KEY(pTable) ((pTable)->lastKey)
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
ccd0e000
...
...
@@ -13,10 +13,10 @@
static
int
tsdbFreeTable
(
STable
*
pTable
);
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
);
static
int
tsdbAddTableToMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
,
bool
addIdx
);
static
int
tsdbAddTableIntoMap
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbEstimateTableEncodeSize
(
STable
*
pTable
);
static
int
tsdbRemoveTableFromMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
/**
* Encode a TSDB table object as a binary content
...
...
@@ -375,21 +375,9 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
tableId
.
uid
);
if
(
pTable
==
NULL
)
return
-
1
;
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
// TODO: implement drop super table
return
-
1
;
}
else
{
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
NULL
;
pMeta
->
nTables
--
;
assert
(
pMeta
->
nTables
>=
0
);
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
tsdbFreeTable
(
pTable
);
}
if
(
tsdbRemoveTableFromMeta
(
pMeta
,
pTable
)
<
0
)
return
-
1
;
return
0
;
}
// int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) {
...
...
@@ -445,10 +433,12 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) {
if
(
pMeta
->
superList
==
NULL
)
{
pMeta
->
superList
=
pTable
;
pTable
->
next
=
NULL
;
pTable
->
prev
=
NULL
;
}
else
{
STable
*
pTemp
=
pMeta
->
superList
;
pTable
->
next
=
pMeta
->
superList
;
pTable
->
prev
=
NULL
;
pTable
->
next
->
prev
=
pTable
;
pMeta
->
superList
=
pTable
;
pTable
->
next
=
pTemp
;
}
}
else
{
// add non-super table to the array
...
...
@@ -467,22 +457,50 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) {
if
(
bytes
>
pMeta
->
maxRowBytes
)
pMeta
->
maxRowBytes
=
bytes
;
}
return
tsdbAddTableIntoMap
(
pMeta
,
pTable
);
if
(
taosHashPut
(
pMeta
->
map
,
(
char
*
)(
&
pTable
->
tableId
.
uid
),
sizeof
(
pTable
->
tableId
.
uid
),
(
void
*
)(
&
pTable
),
sizeof
(
pTable
))
<
0
)
{
return
-
1
;
}
return
0
;
}
// static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) {
// // TODO
// return 0;
// }
static
int
tsdbRemoveTableFromMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
pIndex
);
while
(
tSkipListIterNext
(
pIter
))
{
STable
*
tTable
=
*
(
STable
**
)
SL_GET_NODE_DATA
(
tSkipListIterGet
(
pIter
));
ASSERT
(
tTable
!=
NULL
&&
tTable
->
type
==
TSDB_CHILD_TABLE
);
pMeta
->
tables
[
tTable
->
tableId
.
tid
]
=
NULL
;
taosHashRemove
(
pMeta
->
map
,
(
char
*
)(
&
(
pTable
->
tableId
.
uid
)),
sizeof
(
pTable
->
tableId
.
uid
));
pMeta
->
nTables
--
;
tsdbFreeTable
(
tTable
);
}
static
int
tsdbAddTableIntoMap
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
// TODO: add the table to the map
int64_t
uid
=
pTable
->
tableId
.
uid
;
if
(
taosHashPut
(
pMeta
->
map
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
(
void
*
)(
&
pTable
),
sizeof
(
pTable
))
<
0
)
{
return
-
1
;
tSkipListDestroyIter
(
pIter
);
// TODO: Remove the table from the list
if
(
pTable
->
prev
!=
NULL
)
{
pTable
->
prev
->
next
=
pTable
->
next
;
if
(
pTable
->
next
!=
NULL
)
{
pTable
->
next
->
prev
=
pTable
->
prev
;
}
}
else
{
pMeta
->
superList
=
pTable
->
next
;
}
}
else
{
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
NULL
;
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
pMeta
->
nTables
--
;
}
tsdbFreeTable
(
pTable
);
taosHashRemove
(
pMeta
->
map
,
(
char
*
)(
&
(
pTable
->
tableId
.
uid
)),
sizeof
(
pTable
->
tableId
.
uid
));
return
0
;
}
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
assert
(
pTable
->
type
==
TSDB_CHILD_TABLE
&&
pTable
!=
NULL
);
STable
*
pSTable
=
tsdbGetTableByUid
(
pMeta
,
pTable
->
superUid
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录