more
This commit is contained in:
parent
455006cc2a
commit
a60e9e40ed
|
@ -20,8 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tdef.h"
|
||||
#include "taos.h"
|
||||
#include "tdef.h"
|
||||
|
||||
typedef uint64_t tb_uid_t;
|
||||
|
||||
#define TSWINDOW_INITIALIZER ((STimeWindow){INT64_MIN, INT64_MAX})
|
||||
#define TSWINDOW_DESC_INITIALIZER ((STimeWindow){INT64_MAX, INT64_MIN})
|
||||
|
@ -64,11 +66,7 @@ typedef enum {
|
|||
TSDB_CHECK_ITEM_MAX
|
||||
} ECheckItemType;
|
||||
|
||||
typedef enum {
|
||||
TD_ROW_DISCARD_UPDATE = 0,
|
||||
TD_ROW_OVERWRITE_UPDATE = 1,
|
||||
TD_ROW_PARTIAL_UPDATE = 2
|
||||
} TDUpdateConfig;
|
||||
typedef enum { TD_ROW_DISCARD_UPDATE = 0, TD_ROW_OVERWRITE_UPDATE = 1, TD_ROW_PARTIAL_UPDATE = 2 } TDUpdateConfig;
|
||||
|
||||
extern char *qtypeStr[];
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ extern "C" {
|
|||
|
||||
#include "taosdef.h"
|
||||
#include "taoserror.h"
|
||||
#include "tcoding.h"
|
||||
#include "tdataformat.h"
|
||||
|
||||
#define TD_MSG_NUMBER_
|
||||
|
@ -1096,6 +1097,131 @@ typedef struct {
|
|||
uint64_t tuid;
|
||||
} SDropTopicInternalMsg;
|
||||
|
||||
typedef struct SVCreateTbReq {
|
||||
uint64_t ver; // use a general definition
|
||||
char* name;
|
||||
uint32_t ttl;
|
||||
uint32_t keep;
|
||||
#define TD_SUPER_TABLE 0
|
||||
#define TD_CHILD_TABLE 1
|
||||
#define TD_NORMAL_TABLE 2
|
||||
uint8_t type;
|
||||
union {
|
||||
struct {
|
||||
tb_uid_t suid;
|
||||
uint32_t nCols;
|
||||
SSchema* pSchema;
|
||||
uint32_t nTagCols;
|
||||
SSchema* pTagSchema;
|
||||
} stbCfg;
|
||||
struct {
|
||||
tb_uid_t suid;
|
||||
SKVRow pTag;
|
||||
} ctbCfg;
|
||||
struct {
|
||||
uint32_t nCols;
|
||||
SSchema* pSchema;
|
||||
} ntbCfg;
|
||||
};
|
||||
} SVCreateTbReq;
|
||||
|
||||
static FORCE_INLINE int tSerializeSVCreateTbReq(void** buf, const SVCreateTbReq* pReq) {
|
||||
int tlen = 0;
|
||||
|
||||
tlen += taosEncodeFixedU64(buf, pReq->ver);
|
||||
tlen += taosEncodeString(buf, pReq->name);
|
||||
tlen += taosEncodeFixedU32(buf, pReq->ttl);
|
||||
tlen += taosEncodeFixedU32(buf, pReq->keep);
|
||||
tlen += taosEncodeFixedU8(buf, pReq->type);
|
||||
|
||||
switch (pReq->type) {
|
||||
case TD_SUPER_TABLE:
|
||||
tlen += taosEncodeFixedU64(buf, pReq->stbCfg.suid);
|
||||
tlen += taosEncodeFixedU32(buf, pReq->stbCfg.nCols);
|
||||
for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) {
|
||||
tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pSchema[i].type);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pSchema[i].colId);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pSchema[i].bytes);
|
||||
tlen += taosEncodeString(buf, pReq->stbCfg.pSchema[i].name);
|
||||
}
|
||||
tlen += taosEncodeFixedU32(buf, pReq->stbCfg.nTagCols);
|
||||
for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) {
|
||||
tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].type);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].colId);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes);
|
||||
tlen += taosEncodeString(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||
}
|
||||
break;
|
||||
case TD_CHILD_TABLE:
|
||||
tlen += taosEncodeFixedU64(buf, pReq->ctbCfg.suid);
|
||||
tlen += tdEncodeKVRow(buf, pReq->ctbCfg.pTag);
|
||||
break;
|
||||
case TD_NORMAL_TABLE:
|
||||
tlen += taosEncodeFixedU32(buf, pReq->ntbCfg.nCols);
|
||||
for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) {
|
||||
tlen += taosEncodeFixedI8(buf, pReq->ntbCfg.pSchema[i].type);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->ntbCfg.pSchema[i].colId);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->ntbCfg.pSchema[i].bytes);
|
||||
tlen += taosEncodeString(buf, pReq->ntbCfg.pSchema[i].name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq) {
|
||||
buf = taosDecodeFixedU64(buf, &(pReq->ver));
|
||||
buf = taosDecodeString(buf, &(pReq->name));
|
||||
buf = taosDecodeFixedU32(buf, &(pReq->ttl));
|
||||
buf = taosDecodeFixedU32(buf, &(pReq->keep));
|
||||
buf = taosDecodeFixedU8(buf, &(pReq->type));
|
||||
|
||||
switch (pReq->type) {
|
||||
case TD_SUPER_TABLE:
|
||||
buf = taosDecodeFixedU64(buf, &(pReq->stbCfg.suid));
|
||||
buf = taosDecodeFixedU32(buf, &(pReq->stbCfg.nCols));
|
||||
pReq->stbCfg.pSchema = (SSchema*)malloc(pReq->stbCfg.nCols * sizeof(SSchema));
|
||||
for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) {
|
||||
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type));
|
||||
buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].colId));
|
||||
buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].bytes));
|
||||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name);
|
||||
}
|
||||
buf = taosDecodeFixedU32(buf, &pReq->stbCfg.nTagCols);
|
||||
pReq->stbCfg.pTagSchema = (SSchema*)malloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
|
||||
for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) {
|
||||
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
|
||||
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].colId);
|
||||
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes);
|
||||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||
}
|
||||
break;
|
||||
case TD_CHILD_TABLE:
|
||||
buf = taosDecodeFixedU64(buf, &pReq->ctbCfg.suid);
|
||||
buf = tdDecodeKVRow(buf, &pReq->ctbCfg.pTag);
|
||||
break;
|
||||
case TD_NORMAL_TABLE:
|
||||
buf = taosDecodeFixedU32(buf, &pReq->ntbCfg.nCols);
|
||||
pReq->ntbCfg.pSchema = (SSchema*)malloc(pReq->ntbCfg.nCols * sizeof(SSchema));
|
||||
for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) {
|
||||
buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type);
|
||||
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].colId);
|
||||
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].bytes);
|
||||
buf = taosDecodeStringTo(buf, pReq->ntbCfg.pSchema[i].name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
typedef struct SVCreateTbRsp {
|
||||
} SVCreateTbRsp;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -138,7 +138,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_TASKS_STATUS, "vnode-tasks-status", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-super-table", SVCreateTbReq, SVCreateTbRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
||||
|
|
|
@ -25,7 +25,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
// Types exported
|
||||
typedef uint64_t tb_uid_t;
|
||||
typedef struct SMeta SMeta;
|
||||
|
||||
#define META_SUPER_TABLE 0
|
||||
|
|
|
@ -357,6 +357,17 @@ static FORCE_INLINE void *taosDecodeString(void *buf, char **value) {
|
|||
return POINTER_SHIFT(buf, size);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
|
||||
uint64_t size = 0;
|
||||
|
||||
buf = taosDecodeVariantU64(buf, &size);
|
||||
memcpy(value, buf, (size_t)size);
|
||||
|
||||
value[size] = '\0';
|
||||
|
||||
return POINTER_SHIFT(buf, size);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue