Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3e738363
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,发现更多精彩内容 >>
提交
3e738363
编写于
1月 11, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add/delete tag index
上级
7e720269
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
164 addition
and
7 deletion
+164
-7
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+1
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+0
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+161
-3
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+2
-2
未找到文件。
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
3e738363
...
...
@@ -2678,7 +2678,7 @@ int32_t mndAddIndexImpl(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pSt
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions2
(
pMnode
,
pTrans
,
pDb
,
pStb
,
alterOriData
,
alterOriDataL
en
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions2
(
pMnode
,
pTrans
,
pDb
,
pStb
,
sql
,
l
en
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
return
code
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
3e738363
...
...
@@ -129,7 +129,6 @@ int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
int
metaAlterCache
(
SMeta
*
pMeta
,
int32_t
nPage
);
int
metaAddIndexToSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
}
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int64_t
metaGetTimeSeriesNum
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
3e738363
...
...
@@ -390,8 +390,166 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
return
0
;
}
int
metaAddIndexToSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
// impl later
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
void
*
pData
;
int
nData
;
int64_t
oversion
;
SDecoder
dc
=
{
0
};
int32_t
ret
;
int32_t
c
=
-
2
;
tb_uid_t
suid
=
pReq
->
suid
;
// get super table
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
)
{
ret
=
-
1
;
goto
_err
;
}
// tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
// ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
// if (ret < 0 || c) {
// tdbTbcClose(pUidIdxc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
// return -1;
//}
// ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
// if (ret < 0) {
// tdbTbcClose(pUidIdxc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
// return -1;
//}
// oversion = ((SUidIdxVal *)pData)[0].version;
// tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
// ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
// if (!(ret == 0 && c == 0)) {
// metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
// return -1;
// }
// ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
// if (ret < 0) {
// tdbTbcClose(pTbDbc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
// return -1;
//}
oStbEntry
.
pBuf
=
taosMemoryMalloc
(
nData
);
memcpy
(
oStbEntry
.
pBuf
,
pData
,
nData
);
tDecoderInit
(
&
dc
,
oStbEntry
.
pBuf
,
nData
);
metaDecodeEntry
(
&
dc
,
&
oStbEntry
);
nStbEntry
.
version
=
version
;
nStbEntry
.
type
=
TSDB_SUPER_TABLE
;
nStbEntry
.
uid
=
pReq
->
suid
;
nStbEntry
.
name
=
pReq
->
name
;
nStbEntry
.
stbEntry
.
schemaRow
=
pReq
->
schemaRow
;
nStbEntry
.
stbEntry
.
schemaTag
=
pReq
->
schemaTag
;
metaWLock
(
pMeta
);
// compare two entry
if
(
oStbEntry
.
stbEntry
.
schemaRow
.
version
!=
pReq
->
schemaRow
.
version
)
{
metaSaveToSkmDb
(
pMeta
,
&
nStbEntry
);
}
// update table.db
metaSaveToTbDb
(
pMeta
,
&
nStbEntry
);
// update uid index
metaUpdateUidIdx
(
pMeta
,
&
nStbEntry
);
// metaStatsCacheDrop(pMeta, nStbEntry.uid);
metaULock
(
pMeta
);
// Get target schema info
SSchemaWrapper
*
pTagSchema
=
&
nStbEntry
.
stbEntry
.
schemaTag
;
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
goto
_err
;
}
char
*
tagName
=
"tag_col"
;
SSchema
*
pCol
=
NULL
;
int32_t
iCol
=
0
;
for
(;;)
{
pCol
=
NULL
;
if
(
iCol
>=
pTagSchema
->
nCols
)
break
;
pCol
=
&
pTagSchema
->
pSchema
[
iCol
];
if
(
strcmp
(
pCol
->
name
,
tagName
)
==
0
)
break
;
iCol
++
;
}
if
(
iCol
==
0
)
{
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
goto
_err
;
}
if
(
pCol
==
NULL
)
{
terrno
=
TSDB_CODE_VND_COL_NOT_EXISTS
;
goto
_err
;
}
/*
* iterator all pTdDbc by uid and version
*/
TBC
*
pCtbIdxc
=
NULL
;
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
NULL
);
int
rc
=
tdbTbcMoveTo
(
pCtbIdxc
,
&
(
SCtbIdxKey
){.
suid
=
suid
,
.
uid
=
INT64_MIN
},
sizeof
(
SCtbIdxKey
),
&
c
);
if
(
rc
<
0
)
{
tdbTbcClose
(
pCtbIdxc
);
goto
_err
;
}
for
(;;)
{
void
*
pKey
,
*
pVal
;
int
nKey
,
nVal
;
rc
=
tdbTbcNext
(
pCtbIdxc
,
&
pKey
,
&
nKey
,
&
pVal
,
&
nVal
);
if
(
rc
<
0
)
break
;
if
(((
SCtbIdxKey
*
)
pKey
)
->
suid
!=
suid
)
{
tdbFree
(
pKey
);
tdbFree
(
pVal
);
continue
;
}
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
const
void
*
pTagData
=
NULL
;
int32_t
nTagData
=
0
;
SCtbIdxKey
*
table
=
(
SCtbIdxKey
*
)
pKey
;
STagVal
tagVal
=
{.
cid
=
pCol
->
colId
};
tTagGet
((
const
STag
*
)
pVal
,
&
tagVal
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pTagData
=
tagVal
.
pData
;
nTagData
=
(
int32_t
)
tagVal
.
nData
;
}
else
{
pTagData
=
&
(
tagVal
.
i64
);
nTagData
=
tDataTypes
[
pCol
->
type
].
bytes
;
}
if
(
metaCreateTagIdxKey
(
suid
,
pCol
->
colId
,
pTagData
,
nTagData
,
pCol
->
type
,
table
->
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
metaDestroyTagIdxKey
(
pTagIdxKey
);
goto
_err
;
}
tdbTbUpsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
pMeta
->
txn
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
}
if
(
oStbEntry
.
pBuf
)
taosMemoryFree
(
oStbEntry
.
pBuf
);
tDecoderClear
(
&
dc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pUidIdxc
);
return
TSDB_CODE_SUCCESS
;
_err:
return
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
}
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
// impl later
...
...
@@ -1292,7 +1450,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
goto
_err
;
}
// Get targe schema info
// Get targe
t
schema info
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
...
...
@@ -1352,7 +1510,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
pTagData
=
&
(
tagVal
.
i64
);
nTagData
=
tDataTypes
[
pCol
->
type
].
bytes
;
}
if
(
metaCreateTagIdxKey
(
uid
,
pCol
->
colId
,
pTagData
,
nTagData
,
pCol
->
type
,
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
if
(
metaCreateTagIdxKey
(
s
uid
,
pCol
->
colId
,
pTagData
,
nTagData
,
pCol
->
type
,
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
metaDestroyTagIdxKey
(
pTagIdxKey
);
goto
_err
;
}
...
...
source/libs/index/src/indexCache.c
浏览文件 @
3e738363
...
...
@@ -22,8 +22,8 @@
#define MAX_INDEX_KEY_LEN 256 // test only, change later
#define MEM_TERM_LIMIT 10 * 10000
#define MEM_THRESHOLD
8 * 512
* 1024 // 8M
#define MEM_SIGNAL_QUIT MEM_THRESHOLD *
20
#define MEM_THRESHOLD
128 * 1024
* 1024 // 8M
#define MEM_SIGNAL_QUIT MEM_THRESHOLD *
5
#define MEM_ESTIMATE_RADIO 1.5
static
void
idxMemRef
(
MemTable
*
tbl
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录