Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db2399fa
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,发现更多精彩内容 >>
提交
db2399fa
编写于
12月 30, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more progress
上级
a4cb6467
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
71 addition
and
50 deletion
+71
-50
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+8
-1
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+2
-1
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+58
-13
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+3
-35
未找到文件。
include/dnode/vnode/meta/meta.h
浏览文件 @
db2399fa
...
...
@@ -37,6 +37,11 @@ typedef struct SMetaCfg {
uint64_t
lruSize
;
}
SMetaCfg
;
typedef
struct
{
int32_t
nCols
;
SSchema
*
pSchema
;
}
SSchemaWrapper
;
typedef
SVCreateTbReq
STbCfg
;
// SMeta operations
...
...
@@ -48,7 +53,9 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
int
metaCommit
(
SMeta
*
pMeta
);
// For Query
STbCfg
*
metaGetTableInfo
(
SMeta
*
pMeta
,
char
*
tbname
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
...
...
source/dnode/vnode/impl/inc/vnodeDef.h
浏览文件 @
db2399fa
...
...
@@ -31,10 +31,10 @@
#include "vnodeCommit.h"
#include "vnodeFS.h"
#include "vnodeMemAllocator.h"
#include "vnodeQuery.h"
#include "vnodeRequest.h"
#include "vnodeStateMgr.h"
#include "vnodeSync.h"
#include "vnodeQuery.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -62,6 +62,7 @@ typedef struct SVnodeMgr {
extern
SVnodeMgr
vnodeMgr
;
struct
SVnode
{
int32_t
vgId
;
char
*
path
;
SVnodeCfg
config
;
SVState
state
;
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
db2399fa
...
...
@@ -45,25 +45,70 @@ 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;
STableInfoMsg
*
pReq
=
(
STableInfoMsg
*
)(
pMsg
->
pCont
);
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pStbCfg
=
NULL
;
tb_uid_t
uid
;
int32_t
nCols
;
int32_t
nTagCols
;
SSchemaWrapper
*
pSW
;
STableMetaMsg
*
pTbMetaMsg
;
SSchema
*
pTagSchema
;
if (metaGetTableInfo(pVnode->pMeta, pReq->tableFname, &pRspMsg) < 0) {
return -1;
pTbCfg
=
metaGetTbInfoByName
(
pVnode
->
pMeta
,
pReq
->
tableFname
,
&
uid
);
if
(
pTbCfg
==
NULL
)
{
return
NULL
;
}
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
pStbCfg
=
metaGetTbInfoByUid
(
pVnode
->
pMeta
,
pTbCfg
->
ctbCfg
.
suid
);
if
(
pStbCfg
==
NULL
)
{
return
NULL
;
}
pSW
=
metaGetTableSchema
(
pVnode
->
pMeta
,
pTbCfg
->
ctbCfg
.
suid
,
0
,
true
);
}
else
{
pSW
=
metaGetTableSchema
(
pVnode
->
pMeta
,
uid
,
0
,
true
);
}
nCols
=
pSW
->
nCols
;
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
nTagCols
=
pTbCfg
->
stbCfg
.
nTagCols
;
pTagSchema
=
pTbCfg
->
stbCfg
.
pTagSchema
;
}
else
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
nTagCols
=
pStbCfg
->
stbCfg
.
nTagCols
;
pTagSchema
=
pStbCfg
->
stbCfg
.
pTagSchema
;
}
else
{
nTagCols
=
0
;
pTagSchema
=
NULL
;
}
*pRsp = malloc(sizeof(SRpcMsg));
if (TD_IS_NULL(*pRsp)) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
free(pMsg);
pTbMetaMsg
=
(
STableMetaMsg
*
)
calloc
(
1
,
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
nCols
+
nTagCols
));
if
(
pTbMetaMsg
==
NULL
)
{
return
-
1
;
}
// TODO
(*pRsp)->pCont = pRspMsg;
strcpy
(
pTbMetaMsg
->
tbFname
,
pTbCfg
->
name
);
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
strcpy
(
pTbMetaMsg
->
stbFname
,
pStbCfg
->
name
);
pTbMetaMsg
->
suid
=
htobe64
(
pTbCfg
->
ctbCfg
.
suid
);
}
pTbMetaMsg
->
numOfTags
=
htonl
(
nTagCols
);
pTbMetaMsg
->
numOfColumns
=
htonl
(
nCols
);
pTbMetaMsg
->
tableType
=
pTbCfg
->
type
;
pTbMetaMsg
->
tuid
=
htobe64
(
uid
);
pTbMetaMsg
->
vgId
=
htonl
(
pVnode
->
vgId
);
memcpy
(
pTbMetaMsg
->
pSchema
,
pSW
->
pSchema
,
sizeof
(
SSchema
)
*
pSW
->
nCols
);
if
(
nTagCols
)
{
memcpy
(
POINTER_SHIFT
(
pTbMetaMsg
->
pSchema
,
sizeof
(
SSchema
)
*
pSW
->
nCols
),
pTagSchema
,
sizeof
(
SSchema
)
*
nTagCols
);
}
for
(
int
i
=
0
;
i
<
nCols
+
nTagCols
;
i
++
)
{
SSchema
*
pSch
=
pTbMetaMsg
->
pSchema
+
i
;
pSch
->
colId
=
htonl
(
pSch
->
colId
);
pSch
->
bytes
=
htonl
(
pSch
->
bytes
);
}
#endif
return
0
;
}
\ No newline at end of file
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
db2399fa
...
...
@@ -38,11 +38,6 @@ struct SMetaDB {
DB_ENV
*
pEvn
;
};
typedef
struct
{
int32_t
nCols
;
SSchema
*
pSchema
;
}
SSchemaWrapper
;
typedef
int
(
*
bdbIdxCbPtr
)(
DB
*
,
const
DBT
*
,
const
DBT
*
,
DBT
*
);
static
SMetaDB
*
metaNewDB
();
...
...
@@ -60,9 +55,6 @@ 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
,
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))
...
...
@@ -439,31 +431,7 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
}
/* ------------------------ FOR QUERY ------------------------ */
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
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
...
...
@@ -491,7 +459,7 @@ static STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
return
pTbCfg
;
}
static
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
...
...
@@ -521,7 +489,7 @@ static STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
return
pTbCfg
;
}
static
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
uint32_t
nCols
;
SSchemaWrapper
*
pSW
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录