Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ec4b6b08
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
ec4b6b08
编写于
6月 14, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
472b194a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
26 deletion
+34
-26
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+34
-26
未找到文件。
src/tsdb/src/tsdbMeta.c
浏览文件 @
ec4b6b08
...
...
@@ -100,27 +100,26 @@ int tsdbDropTable(TSDB_REPO_T *repo, STableId tableId) {
if
(
tsdbRemoveTableFromMeta
(
pMeta
,
pTable
,
true
)
<
0
)
return
-
1
;
return
0
;
}
void
*
tsdbGetTableTagVal
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
,
int32_t
colId
,
int16_t
type
,
int16_t
bytes
)
{
void
*
tsdbGetTableTagVal
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
,
int32_t
colId
,
int16_t
type
,
int16_t
bytes
)
{
// TODO: this function should be changed also
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
repo
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
repo
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
STSchema
*
pSchema
=
tsdbGetTableTagSchema
(
pMeta
,
pTable
);
STColumn
*
pCol
=
tdGetColOfID
(
pSchema
,
colId
);
if
(
pCol
==
NULL
)
{
return
NULL
;
// No matched tag volumn
}
char
*
val
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
colId
);
char
*
val
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
colId
);
assert
(
type
==
pCol
->
type
&&
bytes
==
pCol
->
bytes
);
if
(
val
!=
NULL
&&
IS_VAR_DATA_TYPE
(
type
))
{
assert
(
varDataLen
(
val
)
<
pCol
->
bytes
);
}
return
val
;
}
...
...
@@ -129,7 +128,7 @@ char *tsdbGetTableName(TSDB_REPO_T *repo, const STableId *id) {
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
if
(
pTable
==
NULL
)
{
return
NULL
;
...
...
@@ -398,7 +397,7 @@ int tsdbUpdateTable(STsdbMeta *pMeta, STable *pTable, STableCfg *pCfg) {
return
TSDB_CODE_SUCCESS
;
}
char
*
getTSTupleKey
(
const
void
*
data
)
{
char
*
getTSTupleKey
(
const
void
*
data
)
{
SDataRow
row
=
(
SDataRow
)
data
;
return
POINTER_SHIFT
(
row
,
TD_DATA_ROW_HEAD_SIZE
);
}
...
...
@@ -457,8 +456,7 @@ static int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
return
-
1
;
}
pTable
=
tsdbDecodeTable
(
cont
,
contLen
);
if
(
pTable
==
NULL
)
return
-
1
;
tsdbDecodeTable
(
cont
,
&
pTable
);
if
(
tsdbAddTableToMeta
(
pMeta
,
pTable
,
false
)
<
0
)
{
tsdbFreeTable
(
pTable
);
...
...
@@ -526,9 +524,8 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) {
goto
_err
;
}
pTable
->
tagVal
=
NULL
;
STColumn
*
pColSchema
=
schemaColAt
(
pTable
->
tagSchema
,
0
);
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
pColSchema
->
type
,
pColSchema
->
bytes
,
1
,
0
,
1
,
getTagIndexKey
);
STColumn
*
pCol
=
schemaColAt
(
pTable
->
tagSchema
,
DEFAULT_TAG_INDEX_COLUMN
);
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
colType
(
pCol
),
colBytes
(
pCol
),
1
,
0
,
1
,
getTagIndexKey
);
if
(
pTable
->
pIndex
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -648,7 +645,8 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
if
(
taosHashPut
(
pMeta
->
uidMap
,
(
char
*
)(
&
pTable
->
tableId
.
uid
),
sizeof
(
pTable
->
tableId
.
uid
),
(
void
*
)(
&
pTable
),
sizeof
(
pTable
))
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbError
(
"vgId:%d failed to add table %s to meta while put into uid map since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to add table %s to meta while put into uid map since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tstrerror
(
terrno
));
goto
_err
;
}
...
...
@@ -727,22 +725,22 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) {
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
ASSERT
(
pTable
->
type
==
TSDB_CHILD_TABLE
&&
pTable
!=
NULL
);
STable
*
pSTable
=
tsdbGetTableByUid
(
pMeta
,
pTable
->
superUid
);
STable
*
pSTable
=
tsdbGetTableByUid
(
pMeta
,
pTable
->
superUid
);
ASSERT
(
pSTable
!=
NULL
);
STSchema
*
pSchema
=
tsdbGetTableTagSchema
(
pTable
);
STColumn
*
pCol
=
schemaColAt
(
pSchema
,
DEFAULT_TAG_INDEX_COLUMN
);
char
*
key
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
pCol
->
colId
);
SArray
*
res
=
tSkipListGet
(
pSTable
->
pIndex
,
key
);
char
*
key
=
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
pCol
->
colId
);
SArray
*
res
=
tSkipListGet
(
pSTable
->
pIndex
,
key
);
size_t
size
=
taosArrayGetSize
(
res
);
ASSERT
(
size
>
0
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSkipListNode
*
pNode
=
taosArrayGetP
(
res
,
i
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSkipListNode
*
pNode
=
taosArrayGetP
(
res
,
i
);
// STableIndexElem* pElem = (STableIndexElem*) SL_GET_NODE_DATA(pNode);
if
((
STable
*
)
SL_GET_NODE_DATA
(
pNode
)
==
pTable
)
{
// this is the exact what we need
tSkipListRemoveNode
(
pSTable
->
pIndex
,
pNode
);
...
...
@@ -957,6 +955,14 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
buf
=
tdDecodeSchema
(
buf
,
&
(
pTable
->
tagSchema
));
STColumn
*
pCol
=
schemaColAt
(
pTable
->
tagSchema
,
DEFAULT_TAG_INDEX_COLUMN
);
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
colType
(
pCol
),
colBytes
(
pCol
),
1
,
0
,
1
,
getTagIndexKey
);
if
(
pTable
->
pIndex
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbFreeTable
(
pTable
);
return
NULL
;
}
}
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
)
{
...
...
@@ -964,6 +970,8 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
}
}
T_REF_INC
(
pTable
);
*
pRTable
=
pTable
;
return
buf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录