Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8bfe913c
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8bfe913c
编写于
12月 09, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/vnode' of github.com:taosdata/TDengine into feature/vnode
上级
9961a0ec
d9662eb6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
37 deletion
+46
-37
source/dnode/vnode/impl/test/vnodeApiTests.cpp
source/dnode/vnode/impl/test/vnodeApiTests.cpp
+2
-2
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+44
-35
未找到文件。
source/dnode/vnode/impl/test/vnodeApiTests.cpp
浏览文件 @
8bfe913c
...
...
@@ -45,7 +45,7 @@ static SKVRow createBasicTag() {
tdInitKVRowBuilder
(
&
rb
);
for
(
int
i
=
10
;
i
<
1
2
;
i
++
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
void
*
pVal
=
malloc
(
sizeof
(
VarDataLenT
)
+
strlen
(
"foo"
));
varDataLen
(
pVal
)
=
strlen
(
"foo"
);
memcpy
(
varDataVal
(
pVal
),
"foo"
,
strlen
(
"foo"
));
...
...
@@ -120,7 +120,7 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
{
// Create some child tables
int
ntables
=
100000
;
int
ntables
=
100000
0
;
int
batch
=
10
;
for
(
int
i
=
0
;
i
<
ntables
/
batch
;
i
++
)
{
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
batch
,
sizeof
(
SRpcMsg
*
));
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
8bfe913c
...
...
@@ -44,9 +44,9 @@ static SMetaDB *metaNewDB();
static
void
metaFreeDB
(
SMetaDB
*
pDB
);
static
int
metaOpenBDBEnv
(
DB_ENV
**
ppEnv
,
const
char
*
path
);
static
void
metaCloseBDBEnv
(
DB_ENV
*
pEnv
);
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
);
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
bool
isDup
);
static
void
metaCloseBDBDb
(
DB
*
pDB
);
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
);
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
,
bool
isDup
);
static
void
metaCloseBDBIdx
(
DB
*
pIdx
);
static
int
metaNameIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
...
...
@@ -76,33 +76,33 @@ int metaOpenDB(SMeta *pMeta) {
}
// Open DBs
if
(
metaOpenBDBDb
(
&
(
pDB
->
pTbDB
),
pDB
->
pEvn
,
"meta.db"
)
<
0
)
{
if
(
metaOpenBDBDb
(
&
(
pDB
->
pTbDB
),
pDB
->
pEvn
,
"meta.db"
,
false
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
if
(
metaOpenBDBDb
(
&
(
pDB
->
pSchemaDB
),
pDB
->
pEvn
,
"meta.db"
)
<
0
)
{
if
(
metaOpenBDBDb
(
&
(
pDB
->
pSchemaDB
),
pDB
->
pEvn
,
"meta.db"
,
false
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
// Open Indices
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pNameIdx
),
pDB
->
pEvn
,
"
index.db"
,
pDB
->
pTbDB
,
&
metaNameIdxCb
)
<
0
)
{
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pNameIdx
),
pDB
->
pEvn
,
"
name.index"
,
pDB
->
pTbDB
,
&
metaNameIdxCb
,
false
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pStbIdx
),
pDB
->
pEvn
,
"
index.db"
,
pDB
->
pTbDB
,
&
metaStbIdxCb
)
<
0
)
{
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pStbIdx
),
pDB
->
pEvn
,
"
stb.index"
,
pDB
->
pTbDB
,
&
metaStbIdxCb
,
false
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pNtbIdx
),
pDB
->
pEvn
,
"
index.db"
,
pDB
->
pTbDB
,
&
metaNtbIdxCb
)
<
0
)
{
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pNtbIdx
),
pDB
->
pEvn
,
"
ntb.index"
,
pDB
->
pTbDB
,
&
metaNtbIdxCb
,
false
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pCtbIdx
),
pDB
->
pEvn
,
"
index.db"
,
pDB
->
pTbDB
,
&
metaCtbIdxCb
)
<
0
)
{
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pCtbIdx
),
pDB
->
pEvn
,
"
ctb.index"
,
pDB
->
pTbDB
,
&
metaCtbIdxCb
,
true
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
...
...
@@ -150,6 +150,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
value
.
data
=
buf
;
value
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
value
.
app_data
=
pTbCfg
;
pMeta
->
pDB
->
pTbDB
->
put
(
pMeta
->
pDB
->
pTbDB
,
NULL
,
&
key
,
&
value
,
0
);
}
...
...
@@ -232,7 +233,7 @@ static void metaCloseBDBEnv(DB_ENV *pEnv) {
}
}
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
)
{
static
int
metaOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
bool
isDup
)
{
int
ret
;
DB
*
pDB
;
...
...
@@ -242,6 +243,14 @@ static int metaOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName) {
return
-
1
;
}
if
(
isDup
)
{
ret
=
pDB
->
set_flags
(
pDB
,
DB_DUPSORT
);
if
(
ret
!=
0
)
{
BDB_PERR
(
"Failed to set DB flags"
,
ret
);
return
-
1
;
}
}
ret
=
pDB
->
open
(
pDB
,
NULL
,
pFName
,
NULL
,
DB_BTREE
,
DB_CREATE
,
0
);
if
(
ret
)
{
BDB_PERR
(
"Failed to open META DB"
,
ret
);
...
...
@@ -259,11 +268,11 @@ static void metaCloseBDBDb(DB *pDB) {
}
}
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
)
{
static
int
metaOpenBDBIdx
(
DB
**
ppIdx
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
DB
*
pDB
,
bdbIdxCbPtr
cbf
,
bool
isDup
)
{
DB
*
pIdx
;
int
ret
;
if
(
metaOpenBDBDb
(
ppIdx
,
pEnv
,
pFName
)
<
0
)
{
if
(
metaOpenBDBDb
(
ppIdx
,
pEnv
,
pFName
,
isDup
)
<
0
)
{
return
-
1
;
}
...
...
@@ -283,30 +292,24 @@ static void metaCloseBDBIdx(DB *pIdx) {
}
static
int
metaNameIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
char
*
name
;
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
)
;
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
taosDecodeString
(
pValue
->
data
,
&
name
);
pSKey
->
data
=
name
;
pSKey
->
size
=
strlen
(
name
);
pSKey
->
flags
=
DB_DBT_APPMALLOC
;
pSKey
->
data
=
pTbCfg
->
name
;
pSKey
->
size
=
strlen
(
pTbCfg
->
name
);
return
0
;
}
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
STbCfg
tbCfg
=
{
0
}
;
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
)
;
metaDecodeTbInfo
(
pValue
->
data
,
&
tbCfg
);
if
(
tbCfg
.
type
==
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
pSKey
->
data
=
pKey
->
data
;
pSKey
->
size
=
pKey
->
size
;
metaClearTbCfg
(
&
tbCfg
);
return
0
;
}
else
{
return
DB_DONOTINDEX
;
...
...
@@ -314,17 +317,13 @@ static int metaStbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
}
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
STbCfg
tbCfg
=
{
0
}
;
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
)
;
metaDecodeTbInfo
(
pValue
->
data
,
&
tbCfg
);
if
(
tbCfg
.
type
==
META_NORMAL_TABLE
)
{
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
pSKey
->
data
=
pKey
->
data
;
pSKey
->
size
=
pKey
->
size
;
metaClearTbCfg
(
&
tbCfg
);
return
0
;
}
else
{
return
DB_DONOTINDEX
;
...
...
@@ -332,16 +331,26 @@ static int metaNtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
}
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
STbCfg
tbCfg
=
{
0
};
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
);
DBT
*
pDbt
;
metaDecodeTbInfo
(
pValue
->
data
,
&
tbCfg
);
if
(
tbCfg
.
type
==
META_CHILD_TABLE
)
{
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
pDbt
=
calloc
(
2
,
sizeof
(
DBT
));
pSKey
->
data
=
pKey
->
data
;
pSKey
->
size
=
pKey
->
size
;
// First key is suid
pDbt
[
0
].
data
=
&
(
pTbCfg
->
ctbCfg
.
suid
);
pDbt
[
0
].
size
=
sizeof
(
pTbCfg
->
ctbCfg
.
suid
);
// Second key is the first tag
void
*
pTagVal
=
tdGetKVRowValOfCol
(
pTbCfg
->
ctbCfg
.
pTag
,
0
);
pDbt
[
1
].
data
=
varDataVal
(
pTagVal
);
pDbt
[
1
].
size
=
varDataLen
(
pTagVal
);
metaClearTbCfg
(
&
tbCfg
);
// Set index key
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
pSKey
->
flags
=
DB_DBT_MULTIPLE
|
DB_DBT_APPMALLOC
;
pSKey
->
data
=
pDbt
;
pSKey
->
size
=
2
;
return
0
;
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录