提交 6b36c2ae 编写于 作者: H Hongze Cheng

more

上级 e861bdeb
......@@ -65,7 +65,7 @@ typedef struct STbCfg {
struct {
/// super table UID
tb_uid_t suid;
SRow * pTag;
SKVRow pTag;
} ctbCfg;
};
} STbCfg;
......
......@@ -162,14 +162,14 @@ typedef struct {
char info[];
} SVnodeRsp;
#define VNODE_INIT_CREATE_STB_REQ(VER, NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \
{ .ver = (VER), .ctReq = META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) }
#define VNODE_INIT_CREATE_STB_REQ(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \
{ .ver = 0, .ctReq = META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) }
#define VNODE_INIT_CREATE_CTB_REQ(VER, NAME, TTL, KEEP, SUID, PTAG) \
{ .ver = (VER), .ctReq = META_INIT_CTB_CFG(NAME, TTL, KEEP, SUID, PTAG) }
#define VNODE_INIT_CREATE_CTB_REQ(NAME, TTL, KEEP, SUID, PTAG) \
{ .ver = 0, .ctReq = META_INIT_CTB_CFG(NAME, TTL, KEEP, SUID, PTAG) }
#define VNODE_INIT_CREATE_NTB_REQ(VER, NAME, TTL, KEEP, SUID, PSCHEMA) \
{ .ver = (VER), .ctReq = META_INIT_NTB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA) }
#define VNODE_INIT_CREATE_NTB_REQ(NAME, TTL, KEEP, SUID, PSCHEMA) \
{ .ver = 0, .ctReq = META_INIT_NTB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA) }
int vnodeBuildReq(void **buf, const SVnodeReq *pReq, uint8_t type);
void *vnodeParseReq(void *buf, SVnodeReq *pReq, uint8_t type);
......
......@@ -3,6 +3,63 @@
#include "vnode.h"
static STSchema *createBasicSchema() {
STSchemaBuilder sb;
STSchema * pSchema = NULL;
tdInitTSchemaBuilder(&sb, 0);
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
for (int i = 1; i < 10; i++) {
tdAddColToSchema(&sb, TSDB_DATA_TYPE_INT, i, 0);
}
pSchema = tdGetSchemaFromBuilder(&sb);
tdDestroyTSchemaBuilder(&sb);
return pSchema;
}
static STSchema *createBasicTagSchema() {
STSchemaBuilder sb;
STSchema * pSchema = NULL;
tdInitTSchemaBuilder(&sb, 0);
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
for (int i = 10; i < 12; i++) {
tdAddColToSchema(&sb, TSDB_DATA_TYPE_BINARY, i, 20);
}
pSchema = tdGetSchemaFromBuilder(&sb);
tdDestroyTSchemaBuilder(&sb);
return pSchema;
}
static SKVRow createBasicTag() {
SKVRowBuilder rb;
SKVRow pTag;
tdInitKVRowBuilder(&rb);
for (int i = 10; i < 12; i++) {
void *pVal = malloc(sizeof(VarDataLenT) + strlen("foo"));
varDataLen(pVal) = strlen("foo");
memcpy(varDataVal(pVal), "foo", strlen("foo"));
tdAddColToKVRow(&rb, i, TSDB_DATA_TYPE_BINARY, pVal);
free(pVal);
}
pTag = tdGetKVRowFromBuilder(&rb);
tdDestroyKVRowBuilder(&rb);
return pTag;
}
TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
GTEST_ASSERT_GE(vnodeInit(), 0);
......@@ -13,12 +70,12 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
tb_uid_t suid = 1638166374163;
{
// Create a super table
STSchema *pSchema = NULL;
STSchema *pTagSchema = NULL;
STSchema *pSchema = createBasicSchema();
STSchema *pTagSchema = createBasicTagSchema();
char tbname[128] = "st";
SArray * pMsgs = (SArray *)taosArrayInit(1, sizeof(SRpcMsg *));
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(0, tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
int zs = vnodeBuildReq(NULL, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + zs);
......@@ -36,6 +93,8 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
free(pMsg);
taosArrayClear(pMsgs);
tdFreeSchema(pSchema);
tdFreeSchema(pTagSchema);
}
{
......@@ -45,10 +104,10 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
for (int i = 0; i < ntables / batch; i++) {
SArray *pMsgs = (SArray *)taosArrayInit(batch, sizeof(SRpcMsg *));
for (int j = 0; j < batch; j++) {
SRow *pTag = NULL;
char tbname[128];
SKVRow pTag = createBasicTag();
char tbname[128];
sprintf(tbname, "tb%d", i * batch + j);
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(0, tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
int tz = vnodeBuildReq(NULL, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + tz);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册