Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7c9a9d21
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看板
提交
7c9a9d21
编写于
12月 25, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add catalog ut
上级
454a488c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
397 addition
and
56 deletion
+397
-56
CMakeLists.txt
CMakeLists.txt
+1
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+2
-9
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+377
-31
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+17
-16
未找到文件。
CMakeLists.txt
浏览文件 @
7c9a9d21
...
...
@@ -11,6 +11,7 @@ set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib")
include
(
${
CMAKE_SUPPORT_DIR
}
/cmake.options
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC -gdwarf-2 -msse4.2 -mfma -g3"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fPIC -gdwarf-2 -msse4.2 -mfma -g3"
)
# contrib
add_subdirectory
(
contrib
)
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
7c9a9d21
...
...
@@ -295,14 +295,6 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
pCatalog
->
tableCache
.
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
ctgError
(
"init hash[%d] for tablemeta cache failed"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
pCatalog
->
tableCache
.
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
...
...
@@ -329,7 +321,8 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
}
}
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
),
output
->
tbMeta
,
sizeof
(
*
output
->
tbMeta
))
!=
0
)
{
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
ctgError
(
"push table[%s] to table cache failed"
,
output
->
tbFname
);
goto
error_exit
;
}
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
7c9a9d21
...
...
@@ -32,31 +32,25 @@
#include "stub.h"
#include "addr_any.h"
typedef
struct
SAppInstInfo
{
int64_t
numOfConns
;
SCorEpSet
mgmtEp
;
}
SAppInstInfo
;
typedef
struct
STscObj
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
];
char
acctId
[
TSDB_ACCT_ID_LEN
];
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
uint32_t
connId
;
uint64_t
id
;
// ref ID returned by taosAddRef
// struct SSqlObj *sqlList;
void
*
pTransporter
;
pthread_mutex_t
mutex
;
// used to protect the operation on db
int32_t
numOfReqs
;
// number of sqlObj from this tscObj
SAppInstInfo
*
pAppInfo
;
}
STscObj
;
namespace
{
void
ctgTestSetPrepareCTableMeta
();
void
ctgTestSetPrepareSTableMeta
();
int32_t
ctgTestVgNum
=
10
;
int32_t
ctgTestColNum
=
2
;
int32_t
ctgTestTagNum
=
1
;
int32_t
ctgTestSVersion
=
1
;
int32_t
ctgTestTVersion
=
1
;
char
*
ctgTestClusterId
=
"cluster1"
;
char
*
ctgTestDbname
=
"1.db1"
;
char
*
ctgTestTablename
=
"table1"
;
char
*
ctgTestCTablename
=
"ctable1"
;
char
*
ctgTestSTablename
=
"stable1"
;
void
sendCreateDbMsg
(
void
*
shandle
,
SEpSet
*
pEpSet
)
{
...
...
@@ -94,7 +88,7 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) {
ASSERT_EQ
(
rpcRsp
.
code
,
0
);
}
void
__rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
void
ctgTestPrepareDbVgroups
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
SUseDbRsp
*
rspMsg
=
NULL
;
//todo
pRsp
->
code
=
0
;
...
...
@@ -102,8 +96,8 @@ void __rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
SUseDbRsp
*
)
pRsp
->
pCont
;
strcpy
(
rspMsg
->
db
,
ctgTestDbname
);
rspMsg
->
vgVersion
=
1
;
rspMsg
->
vgNum
=
ctgTestVgNum
;
rspMsg
->
vgVersion
=
htonl
(
1
)
;
rspMsg
->
vgNum
=
htonl
(
ctgTestVgNum
)
;
rspMsg
->
hashMethod
=
0
;
SVgroupInfo
*
vg
=
NULL
;
...
...
@@ -111,33 +105,239 @@ void __rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
for
(
int32_t
i
=
0
;
i
<
ctgTestVgNum
;
++
i
)
{
vg
=
&
rspMsg
->
vgroupInfo
[
i
];
vg
->
vgId
=
i
+
1
;
vg
->
hashBegin
=
i
*
hashUnit
;
vg
->
hashEnd
=
h
ashUnit
*
(
i
+
1
)
-
1
;
vg
->
vgId
=
htonl
(
i
+
1
)
;
vg
->
hashBegin
=
htonl
(
i
*
hashUnit
)
;
vg
->
hashEnd
=
h
tonl
(
hashUnit
*
(
i
+
1
)
-
1
)
;
vg
->
numOfEps
=
i
%
TSDB_MAX_REPLICA
+
1
;
vg
->
inUse
=
i
%
vg
->
numOfEps
;
for
(
int32_t
n
=
0
;
n
<
vg
->
numOfEps
;
++
n
)
{
SEpAddrMsg
*
addr
=
&
vg
->
epAddr
[
n
];
strcpy
(
addr
->
fqdn
,
"a0"
);
addr
->
port
=
n
+
22
;
addr
->
port
=
htons
(
n
+
22
)
;
}
}
vg
->
hashEnd
=
UINT32_MAX
;
vg
->
hashEnd
=
htonl
(
UINT32_MAX
);
return
;
}
void
ctgTestPrepareDbVgroupsAndChildMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
ctgTestPrepareDbVgroups
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
ctgTestSetPrepareCTableMeta
();
return
;
}
void
ctgTestPrepareDbVgroupsAndSuperMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
ctgTestPrepareDbVgroups
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
ctgTestSetPrepareSTableMeta
();
return
;
}
void
initTestEnv
()
{
void
ctgTestPrepareTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
STableMetaMsg
*
rspMsg
=
NULL
;
//todo
pRsp
->
code
=
0
;
pRsp
->
contLen
=
sizeof
(
STableMetaMsg
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaMsg
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestTablename
);
rspMsg
->
numOfTags
=
0
;
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
tableType
=
TSDB_NORMAL_TABLE
;
rspMsg
->
update
=
1
;
rspMsg
->
sversion
=
htonl
(
ctgTestSVersion
);
rspMsg
->
tversion
=
htonl
(
ctgTestTVersion
);
rspMsg
->
suid
=
0
;
rspMsg
->
tuid
=
htobe64
(
0x0000000000000001
);
rspMsg
->
vgId
=
htonl
(
8
);
SSchema
*
s
=
NULL
;
s
=
&
rspMsg
->
pSchema
[
0
];
s
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
s
->
colId
=
htonl
(
0
);
s
->
bytes
=
htonl
(
8
);
strcpy
(
s
->
name
,
"ts"
);
s
=
&
rspMsg
->
pSchema
[
1
];
s
->
type
=
TSDB_DATA_TYPE_INT
;
s
->
colId
=
htonl
(
1
);
s
->
bytes
=
htonl
(
4
);
strcpy
(
s
->
name
,
"col1"
);
return
;
}
void
ctgTestPrepareCTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
STableMetaMsg
*
rspMsg
=
NULL
;
//todo
pRsp
->
code
=
0
;
pRsp
->
contLen
=
sizeof
(
STableMetaMsg
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaMsg
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestCTablename
);
sprintf
(
rspMsg
->
stbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
tableType
=
TSDB_CHILD_TABLE
;
rspMsg
->
update
=
1
;
rspMsg
->
sversion
=
htonl
(
ctgTestSVersion
);
rspMsg
->
tversion
=
htonl
(
ctgTestTVersion
);
rspMsg
->
suid
=
htobe64
(
0x0000000000000002
);
rspMsg
->
tuid
=
htobe64
(
0x0000000000000003
);
rspMsg
->
vgId
=
htonl
(
9
);
SSchema
*
s
=
NULL
;
s
=
&
rspMsg
->
pSchema
[
0
];
s
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
s
->
colId
=
htonl
(
0
);
s
->
bytes
=
htonl
(
8
);
strcpy
(
s
->
name
,
"ts"
);
s
=
&
rspMsg
->
pSchema
[
1
];
s
->
type
=
TSDB_DATA_TYPE_INT
;
s
->
colId
=
htonl
(
1
);
s
->
bytes
=
htonl
(
4
);
strcpy
(
s
->
name
,
"col1s"
);
s
=
&
rspMsg
->
pSchema
[
2
];
s
->
type
=
TSDB_DATA_TYPE_BINARY
;
s
->
colId
=
htonl
(
2
);
s
->
bytes
=
htonl
(
12
);
strcpy
(
s
->
name
,
"tag1s"
);
return
;
}
void
ctgTestPrepareSTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
STableMetaMsg
*
rspMsg
=
NULL
;
//todo
pRsp
->
code
=
0
;
pRsp
->
contLen
=
sizeof
(
STableMetaMsg
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaMsg
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
sprintf
(
rspMsg
->
stbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
tableType
=
TSDB_SUPER_TABLE
;
rspMsg
->
update
=
1
;
rspMsg
->
sversion
=
htonl
(
ctgTestSVersion
);
rspMsg
->
tversion
=
htonl
(
ctgTestTVersion
);
rspMsg
->
suid
=
htobe64
(
0x0000000000000002
);
rspMsg
->
tuid
=
htobe64
(
0x0000000000000003
);
rspMsg
->
vgId
=
0
;
SSchema
*
s
=
NULL
;
s
=
&
rspMsg
->
pSchema
[
0
];
s
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
s
->
colId
=
htonl
(
0
);
s
->
bytes
=
htonl
(
8
);
strcpy
(
s
->
name
,
"ts"
);
s
=
&
rspMsg
->
pSchema
[
1
];
s
->
type
=
TSDB_DATA_TYPE_INT
;
s
->
colId
=
htonl
(
1
);
s
->
bytes
=
htonl
(
4
);
strcpy
(
s
->
name
,
"col1s"
);
s
=
&
rspMsg
->
pSchema
[
2
];
s
->
type
=
TSDB_DATA_TYPE_BINARY
;
s
->
colId
=
htonl
(
2
);
s
->
bytes
=
htonl
(
12
);
strcpy
(
s
->
name
,
"tag1s"
);
return
;
}
void
ctgTestSetPrepareDbVgroups
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareDbVgroups
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
ctgTestPrepareDbVgroups
);
}
}
}
void
ctgTestSetPrepareTableMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareTableMeta
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
ctgTestPrepareTableMeta
);
}
}
}
void
ctgTestSetPrepareCTableMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareCTableMeta
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
ctgTestPrepareCTableMeta
);
}
}
}
void
ctgTestSetPrepareSTableMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareSTableMeta
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
ctgTestPrepareSTableMeta
);
}
}
}
void
ctgTestSetPrepareDbVgroupsAndChildMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
__rpcSendRecv
);
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareDbVgroupsAndChildMeta
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
__rpcSendRecv
);
stub
.
set
(
f
.
second
,
(
rpcSendRecv
,
ctgTestPrepareDbVgroupsAndChildMeta
));
}
}
}
void
ctgTestSetPrepareDbVgroupsAndSuperMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestPrepareDbVgroupsAndSuperMeta
);
{
AddrAny
any
(
"libtransport.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendRecv$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
(
rpcSendRecv
,
ctgTestPrepareDbVgroupsAndSuperMeta
));
}
}
}
...
...
@@ -145,12 +345,12 @@ void initTestEnv() {
}
TEST
(
testCase
,
normalCase
)
{
TEST
(
testCase
,
normal
Table
Case
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
SVgroupInfo
vgInfo
=
{
0
};
initTestEnv
();
ctgTestSetPrepareDbVgroups
();
initQueryModuleMsgHandle
();
...
...
@@ -164,6 +364,152 @@ TEST(testCase, normalCase) {
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
vgInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
vgInfo
.
vgId
,
8
);
ASSERT_EQ
(
vgInfo
.
numOfEps
,
3
);
ctgTestSetPrepareTableMeta
();
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
0
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
8
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_NORMAL_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
0
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
catalogDestroy
();
}
TEST
(
testCase
,
childTableCase
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
SVgroupInfo
vgInfo
=
{
0
};
ctgTestSetPrepareDbVgroupsAndChildMeta
();
initQueryModuleMsgHandle
();
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestSTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
catalogDestroy
();
}
TEST
(
testCase
,
superTableCase
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
SVgroupInfo
vgInfo
=
{
0
};
ctgTestSetPrepareDbVgroupsAndSuperMeta
();
initQueryModuleMsgHandle
();
//sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
STableMeta
*
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestSTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
0
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_SUPER_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ctgTestSetPrepareCTableMeta
();
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
ctgTestDbname
,
ctgTestCTablename
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
tableMeta
->
vgId
,
9
);
ASSERT_EQ
(
tableMeta
->
tableType
,
TSDB_CHILD_TABLE
);
ASSERT_EQ
(
tableMeta
->
sversion
,
ctgTestSVersion
);
ASSERT_EQ
(
tableMeta
->
tversion
,
ctgTestTVersion
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfColumns
,
ctgTestColNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
numOfTags
,
ctgTestTagNum
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
catalogDestroy
();
}
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
7c9a9d21
...
...
@@ -92,8 +92,8 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
return
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
;
}
pRsp
->
vgVersion
=
hton
l
(
pRsp
->
vgVersion
);
pRsp
->
vgNum
=
hton
l
(
pRsp
->
vgNum
);
pRsp
->
vgVersion
=
ntoh
l
(
pRsp
->
vgVersion
);
pRsp
->
vgNum
=
ntoh
l
(
pRsp
->
vgNum
);
if
(
pRsp
->
vgNum
<
0
)
{
qError
(
"invalid db[%s] vgroup number[%d]"
,
pRsp
->
db
,
pRsp
->
vgNum
);
...
...
@@ -115,12 +115,12 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
vgNum
;
++
i
)
{
pRsp
->
vgroupInfo
[
i
].
vgId
=
hton
l
(
pRsp
->
vgroupInfo
[
i
].
vgId
);
pRsp
->
vgroupInfo
[
i
].
hashBegin
=
hton
l
(
pRsp
->
vgroupInfo
[
i
].
hashBegin
);
pRsp
->
vgroupInfo
[
i
].
hashEnd
=
hton
l
(
pRsp
->
vgroupInfo
[
i
].
hashEnd
);
pRsp
->
vgroupInfo
[
i
].
vgId
=
ntoh
l
(
pRsp
->
vgroupInfo
[
i
].
vgId
);
pRsp
->
vgroupInfo
[
i
].
hashBegin
=
ntoh
l
(
pRsp
->
vgroupInfo
[
i
].
hashBegin
);
pRsp
->
vgroupInfo
[
i
].
hashEnd
=
ntoh
l
(
pRsp
->
vgroupInfo
[
i
].
hashEnd
);
for
(
int32_t
n
=
0
;
n
<
pRsp
->
vgroupInfo
[
i
].
numOfEps
;
++
n
)
{
pRsp
->
vgroupInfo
[
i
].
epAddr
[
n
].
port
=
hton
s
(
pRsp
->
vgroupInfo
[
i
].
epAddr
[
n
].
port
);
pRsp
->
vgroupInfo
[
i
].
epAddr
[
n
].
port
=
ntoh
s
(
pRsp
->
vgroupInfo
[
i
].
epAddr
[
n
].
port
);
}
if
(
0
!=
taosHashPut
(
pOut
->
dbVgroup
.
vgInfo
,
&
pRsp
->
vgroupInfo
[
i
].
vgId
,
sizeof
(
pRsp
->
vgroupInfo
[
i
].
vgId
),
&
pRsp
->
vgroupInfo
[
i
],
sizeof
(
pRsp
->
vgroupInfo
[
i
])))
{
...
...
@@ -142,13 +142,13 @@ _return:
}
static
int32_t
queryConvertTableMetaMsg
(
STableMetaMsg
*
pMetaMsg
)
{
pMetaMsg
->
numOfTags
=
hton
l
(
pMetaMsg
->
numOfTags
);
pMetaMsg
->
numOfColumns
=
hton
l
(
pMetaMsg
->
numOfColumns
);
pMetaMsg
->
sversion
=
hton
l
(
pMetaMsg
->
sversion
);
pMetaMsg
->
tversion
=
hton
l
(
pMetaMsg
->
tversion
);
pMetaMsg
->
numOfTags
=
ntoh
l
(
pMetaMsg
->
numOfTags
);
pMetaMsg
->
numOfColumns
=
ntoh
l
(
pMetaMsg
->
numOfColumns
);
pMetaMsg
->
sversion
=
ntoh
l
(
pMetaMsg
->
sversion
);
pMetaMsg
->
tversion
=
ntoh
l
(
pMetaMsg
->
tversion
);
pMetaMsg
->
tuid
=
htobe64
(
pMetaMsg
->
tuid
);
pMetaMsg
->
suid
=
htobe64
(
pMetaMsg
->
suid
);
pMetaMsg
->
vgId
=
hton
l
(
pMetaMsg
->
vgId
);
pMetaMsg
->
vgId
=
ntoh
l
(
pMetaMsg
->
vgId
);
if
(
pMetaMsg
->
numOfTags
<
0
||
pMetaMsg
->
numOfTags
>
TSDB_MAX_TAGS
)
{
qError
(
"invalid numOfTags[%d] in table meta rsp msg"
,
pMetaMsg
->
numOfTags
);
...
...
@@ -179,8 +179,8 @@ static int32_t queryConvertTableMetaMsg(STableMetaMsg* pMetaMsg) {
int32_t
numOfTotalCols
=
pMetaMsg
->
numOfColumns
+
pMetaMsg
->
numOfTags
;
for
(
int
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
pSchema
->
bytes
=
hton
l
(
pSchema
->
bytes
);
pSchema
->
colId
=
hton
l
(
pSchema
->
colId
);
pSchema
->
bytes
=
ntoh
l
(
pSchema
->
bytes
);
pSchema
->
colId
=
ntoh
l
(
pSchema
->
colId
);
pSchema
++
;
}
...
...
@@ -202,7 +202,8 @@ int32_t queryCreateTableMetaFromMsg(STableMetaMsg* msg, bool isSuperTable, STabl
qError
(
"calloc size[%d] failed"
,
metaSize
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pTableMeta
->
vgId
=
isSuperTable
?
0
:
msg
->
vgId
;
pTableMeta
->
tableType
=
isSuperTable
?
TSDB_SUPER_TABLE
:
msg
->
tableType
;
pTableMeta
->
uid
=
msg
->
suid
;
pTableMeta
->
suid
=
msg
->
suid
;
...
...
@@ -213,12 +214,12 @@ int32_t queryCreateTableMetaFromMsg(STableMetaMsg* msg, bool isSuperTable, STabl
pTableMeta
->
tableInfo
.
precision
=
msg
->
precision
;
pTableMeta
->
tableInfo
.
numOfColumns
=
msg
->
numOfColumns
;
memcpy
(
pTableMeta
->
schema
,
msg
->
pSchema
,
sizeof
(
SSchema
)
*
total
);
for
(
int32_t
i
=
0
;
i
<
msg
->
numOfColumns
;
++
i
)
{
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
}
memcpy
(
pTableMeta
->
schema
,
msg
->
pSchema
,
sizeof
(
SSchema
)
*
total
);
*
pMeta
=
pTableMeta
;
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录