Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4cb6467
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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,发现更多精彩内容 >>
提交
a4cb6467
编写于
12月 30, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more progress
上级
21237655
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
98 addition
and
79 deletion
+98
-79
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+1
-1
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+2
-0
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+95
-78
未找到文件。
include/dnode/vnode/meta/meta.h
浏览文件 @
a4cb6467
...
...
@@ -48,7 +48,7 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
int
metaCommit
(
SMeta
*
pMeta
);
// For Query
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
);
STbCfg
*
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
);
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
a4cb6467
...
...
@@ -45,6 +45,7 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
#if 0
STableInfoMsg *pReq = (STableInfoMsg *)(pMsg->pCont);
STableMetaMsg *pRspMsg;
int ret;
...
...
@@ -63,5 +64,6 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// TODO
(*pRsp)->pCont = pRspMsg;
#endif
return
0
;
}
\ No newline at end of file
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
a4cb6467
...
...
@@ -60,7 +60,9 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
static
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
static
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
#define BDB_PERR(info, code) fprintf(stderr, info " reason: %s", db_strerror(code))
...
...
@@ -437,86 +439,89 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
}
/* ------------------------ FOR QUERY ------------------------ */
int
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
,
STableMetaMsg
**
ppMsg
)
{
#if 0
DBT key = {0};
DBT value = {0};
SMetaDB * pMetaDB = pMeta->pDB;
int ret;
STbCfg tbCfg;
SSchemaKey schemaKey;
DBT key1 = {0};
DBT value1 = {0};
uint32_t ncols;
void * pBuf;
int tlen;
STableMetaMsg *pMsg;
SSchema * pSchema;
STbCfg
*
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
)
{
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pStbCfg
=
NULL
;
tb_uid_t
uid
;
int32_t
sver
=
0
;
SSchemaWrapper
*
pSW
;
pTbCfg
=
metaGetTbInfoByName
(
pMeta
,
tbname
,
&
uid
);
if
(
pTbCfg
==
NULL
)
{
return
NULL
;
}
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
uid
=
pTbCfg
->
ctbCfg
.
suid
;
}
pSW
=
metaGetTableSchema
(
pMeta
,
uid
,
0
,
false
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
return
pTbCfg
;
}
static
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
DBT
value
=
{
0
};
int
ret
;
// Set key/value
key
.
data
=
&
uid
;
key
.
size
=
sizeof
(
uid
);
// Query
ret
=
pDB
->
pTbDB
->
get
(
pDB
->
pTbDB
,
NULL
,
&
key
,
&
value
,
0
);
if
(
ret
!=
0
)
{
return
NULL
;
}
// Decode
pTbCfg
=
(
STbCfg
*
)
malloc
(
sizeof
(
*
pTbCfg
));
if
(
pTbCfg
==
NULL
)
{
return
NULL
;
}
metaDecodeTbInfo
(
value
.
data
,
pTbCfg
);
return
pTbCfg
;
}
static
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pvalue
=
{
0
};
int
ret
;
// Set key/value
key
.
data
=
tbname
;
key.size = strlen(tbname)
+ 1
;
key
.
size
=
strlen
(
tbname
);
ret = pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0);
// Query
ret
=
pDB
->
pNameIdx
->
pget
(
pDB
->
pNameIdx
,
NULL
,
&
key
,
&
pkey
,
&
pvalue
,
0
);
if
(
ret
!=
0
)
{
// TODO
return -1;
return
NULL
;
}
metaDecodeTbInfo(value.data, &tbCfg);
switch (tbCfg.type) {
case META_SUPER_TABLE:
schemaKey.uid = tbCfg.stbCfg.suid;
schemaKey.sver = 0;
key1.data = &schemaKey;
key1.size = sizeof(schemaKey);
ret = pMetaDB->pSchemaDB->get(pMetaDB->pSchemaDB, &key1, &value1, NULL, 0);
if (ret != 0) {
// TODO
return -1;
}
pBuf = value1.data;
pBuf = taosDecodeFixedU32(pBuf, &ncols);
tlen = sizeof(STableMetaMsg) + (tbCfg.stbCfg.nTagCols + ncols) * sizeof(SSchema);
pMsg = calloc(1, tlen);
if (pMsg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
strcpy(pMsg->tbFname, tbCfg.name);
pMsg->numOfTags = tbCfg.stbCfg.nTagCols;
pMsg->numOfColumns = ncols;
pMsg->tableType = tbCfg.type;
pMsg->sversion = 0;
pMsg->tversion = 0;
pMsg->suid = tbCfg.stbCfg.suid;
pMsg->tuid = tbCfg.stbCfg.suid;
memcpy(pMsg->pSchema, tbCfg.stbCfg.pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols);
memcpy(POINTER_SHIFT(pMsg->pSchema, sizeof(SSchema) * tbCfg.stbCfg.nCols), tbCfg.stbCfg.pTagSchema,
sizeof(SSchema) * tbCfg.stbCfg.nTagCols);
break;
case META_CHILD_TABLE:
ASSERT(0);
break;
case META_NORMAL_TABLE:
ASSERT(0);
break;
default:
ASSERT(0);
break;
}
*ppMsg = pMsg;
#endif
return
0
;
// Decode
*
uid
=
*
(
tb_uid_t
*
)(
pkey
.
data
);
pTbCfg
=
(
STbCfg
*
)
malloc
(
sizeof
(
*
pTbCfg
));
if
(
pTbCfg
==
NULL
)
{
return
NULL
;
}
metaDecodeTbInfo
(
pvalue
.
data
,
pTbCfg
);
return
pTbCfg
;
}
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
uint32_t
nCols
;
SSchemaWrapper
*
pSW
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
...
...
@@ -540,12 +545,24 @@ static SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sv
// Decode the schema
pBuf
=
value
.
data
;
taosDecodeFixedI32
(
&
pBuf
,
&
nCols
);
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
)
+
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
if
(
isinline
)
{
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
)
+
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
pSW
->
pSchema
=
POINTER_SHIFT
(
pSW
,
sizeof
(
*
pSW
));
}
else
{
pSW
=
(
SSchemaWrapper
*
)
malloc
(
sizeof
(
*
pSW
));
if
(
pSW
==
NULL
)
{
return
NULL
;
}
pSW
->
pSchema
=
POINTER_SHIFT
(
pSW
,
sizeof
(
*
pSW
));
pSW
->
pSchema
=
(
SSchema
*
)
malloc
(
sizeof
(
SSchema
)
*
nCols
);
if
(
pSW
->
pSchema
==
NULL
)
{
free
(
pSW
);
return
NULL
;
}
}
for
(
int
i
=
0
;
i
<
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录