From 30b1378bde065065e209b1fe52efe464609797fd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 22 Dec 2022 22:23:03 +0800 Subject: [PATCH] add create_tag_index msg --- include/common/tmsg.h | 17 +++++++++++++++++ include/libs/nodes/cmdnodes.h | 2 +- include/util/tdef.h | 3 ++- source/common/src/tmsg.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8c0cd63fc3..045ea81ea7 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2764,6 +2764,23 @@ typedef struct { int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq); int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq); +typedef struct { + char dbFName[TSDB_DB_FNAME_LEN]; + char stbName[TSDB_TABLE_NAME_LEN]; + char colName[TSDB_COL_NAME_LEN]; + char idxName[TSDB_COL_NAME_LEN]; + int8_t idxType; +} SCreateTagIndexReq; + +int32_t tSerializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq); +int32_t tDeserializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq); + +typedef struct { + char dbFName[TSDB_DB_FNAME_LEN]; + char stb[TSDB_TABLE_FNAME_LEN]; + int8_t indexType; +} SDropTagIndexReq; + typedef struct { int8_t version; // for compatibility(default 0) int8_t intervalUnit; // MACRO: TIME_UNIT_XXX diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 66988ff135..22b8381aef 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -295,7 +295,7 @@ typedef struct SShowTableTagsStmt { SNodeList* pTags; } SShowTableTagsStmt; -typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType; +typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType; typedef struct SIndexOptions { ENodeType type; diff --git a/include/util/tdef.h b/include/util/tdef.h index e1d421a399..0c32623233 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -104,6 +104,7 @@ extern const int32_t TYPE_BYTES[16]; #define TSDB_INDEX_TYPE_SMA "SMA" #define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT" +#define TSDB_INDEX_TYPE_NORMAL "NORMAL" #define TSDB_INS_USER_STABLES_DBNAME_COLID 2 @@ -310,7 +311,7 @@ typedef enum ELogicConditionType { #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. #define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved. -#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years +#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MINROWS_FBLOCK 10 #define TSDB_MAX_MINROWS_FBLOCK 1000 #define TSDB_DEFAULT_MINROWS_FBLOCK 100 diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 95625e8d93..3826af8c5b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -918,6 +918,39 @@ int32_t tDeserializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) tDecoderClear(&decoder); return 0; } + +int32_t tSerializeSCreateTagIdxReq(void *buf, int32_t bufLen, SCreateTagIndexReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->stbName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->colName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->idxName) < 0) return -1; + if (tEncodeI8(&encoder, pReq->idxType) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} +int32_t tDeserializeSCreateTagIdxReq(void *buf, int32_t bufLen, SCreateTagIndexReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->stbName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->colName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->idxName) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->idxType) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} int32_t tSerializeSMCreateFullTextReq(void *buf, int32_t bufLen, SMCreateFullTextReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen);