From 7c8a72809671b268820f6aff9b87629493a9ca01 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 17 May 2022 15:55:54 +0800 Subject: [PATCH] refactor:add the configuration of dataFormat --- include/common/tglobal.h | 1 + source/client/src/clientSml.c | 12 ++++++++---- source/common/src/tglobal.c | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 32cfb5dbaa..1f7dbb8b62 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -127,6 +127,7 @@ extern bool tsStartUdfd; // schemaless extern char tsSmlChildTableName[]; +extern bool tsSmlDataFormat; // internal extern int32_t tsTransPullupInterval; diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index cdae558653..fe574b8ef6 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -166,7 +166,7 @@ typedef struct { SMLProtocolType protocol; int8_t precision; - bool dataFormat; // true means that the name, number and order of keys in each line are the same(only for influx protocol) + bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol) SHashObj *childTables; SHashObj *superTables; @@ -1422,7 +1422,7 @@ static void smlDestroyInfo(SSmlHandle* info){ taosMemoryFreeClear(info); } -static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocolType protocol, int8_t precision, bool dataFormat){ +static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocolType protocol, int8_t precision){ int32_t code = TSDB_CODE_SUCCESS; SSmlHandle* info = (SSmlHandle*)taosMemoryCalloc(1, sizeof(SSmlHandle)); if (NULL == info) { @@ -1454,7 +1454,11 @@ static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocol info->precision = precision; info->protocol = protocol; - info->dataFormat = dataFormat; + if(protocol == TSDB_SML_LINE_PROTOCOL){ + info->dataFormat = tsSmlDataFormat; + }else{ + info->dataFormat = true; + } info->pRequest = request; info->msgBuf.buf = info->pRequest->msgBuf; info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; @@ -2335,7 +2339,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr return NULL; } - SSmlHandle* info = smlBuildSmlInfo(taos, request, (SMLProtocolType)protocol, precision, true); + SSmlHandle* info = smlBuildSmlInfo(taos, request, (SMLProtocolType)protocol, precision); if(!info){ return (TAOS_RES*)request; } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 5beb5454de..33ba9473d0 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -79,6 +79,7 @@ uint16_t tsTelemPort = 80; // schemaless char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; //user defined child table name can be specified in tag value. //If set to empty system will generate table name using MD5 hash. +bool tsSmlDataFormat = true; // true means that the name and order of cols in each line are the same(only for influx protocol) // query int32_t tsQueryPolicy = 1; @@ -324,6 +325,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1) != 0) return -1; if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 3, 1) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; + if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; tsNumOfTaskQueueThreads = tsNumOfCores / 4; tsNumOfTaskQueueThreads = TRANGE(tsNumOfTaskQueueThreads, 1, 2); @@ -518,6 +520,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { } tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN); + tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; -- GitLab