提交 a2ea28e6 编写于 作者: G Ganlin Zhao

[TD-10532]<enhance>: schemaless convert tag value to nchar

上级 e58d8737
...@@ -66,7 +66,7 @@ bool isValidFloat(char *str); ...@@ -66,7 +66,7 @@ bool isValidFloat(char *str);
int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* info); int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* info);
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info); uint16_t len, SSmlLinesInfo* info, bool isTag);
int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info); uint16_t len, SSmlLinesInfo* info);
......
...@@ -1542,11 +1542,20 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info ...@@ -1542,11 +1542,20 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info
} }
//len does not include '\0' from value. //len does not include '\0' from value.
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
uint16_t len, SSmlLinesInfo* info) { uint16_t len, SSmlLinesInfo* info, bool isTag) {
if (len <= 0) { if (len <= 0) {
return false; return false;
} }
//convert tags value to Nchar
if (isTag) {
pVal->type = TSDB_DATA_TYPE_NCHAR;
pVal->length = len;
pVal->value = calloc(pVal->length, 1);
memcpy(pVal->value, value, pVal->length);
return true;
}
//integer number //integer number
bool has_sign; bool has_sign;
if (isInteger(value, len, &has_sign)) { if (isInteger(value, len, &has_sign)) {
...@@ -1859,7 +1868,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash ...@@ -1859,7 +1868,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
bool *is_last_kv, SSmlLinesInfo* info) { bool *is_last_kv, SSmlLinesInfo* info, bool isTag) {
const char *start, *cur; const char *start, *cur;
char *value = NULL; char *value = NULL;
uint16_t len = 0; uint16_t len = 0;
...@@ -1883,7 +1892,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index, ...@@ -1883,7 +1892,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
value = calloc(len + 1, 1); value = calloc(len + 1, 1);
memcpy(value, start, len); memcpy(value, start, len);
value[len] = '\0'; value[len] = '\0';
if (!convertSmlValueType(pKV, value, len, info)) { if (!convertSmlValueType(pKV, value, len, info, isTag)) {
tscError("SML:0x%"PRIx64" Failed to convert sml value string(%s) to any type", tscError("SML:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
info->id, value); info->id, value);
//free previous alocated key field //free previous alocated key field
...@@ -1989,7 +1998,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -1989,7 +1998,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
tscError("SML:0x%"PRIx64" Unable to parse key", info->id); tscError("SML:0x%"PRIx64" Unable to parse key", info->id);
goto error; goto error;
} }
ret = parseSmlValue(pkv, &cur, &is_last_kv, info); ret = parseSmlValue(pkv, &cur, &is_last_kv, info, !isField);
if (ret) { if (ret) {
tscError("SML:0x%"PRIx64" Unable to parse value", info->id); tscError("SML:0x%"PRIx64" Unable to parse value", info->id);
goto error; goto error;
......
...@@ -153,7 +153,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -153,7 +153,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} }
if (!convertSmlValueType(pVal, value, len, info)) { if (!convertSmlValueType(pVal, value, len, info, false)) {
tscError("OTD:0x%"PRIx64" Failed to convert metric value string(%s) to any type", tscError("OTD:0x%"PRIx64" Failed to convert metric value string(%s) to any type",
info->id, value); info->id, value);
tfree(value); tfree(value);
...@@ -238,7 +238,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index, ...@@ -238,7 +238,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
value = tcalloc(len + 1, 1); value = tcalloc(len + 1, 1);
memcpy(value, start, len); memcpy(value, start, len);
value[len] = '\0'; value[len] = '\0';
if (!convertSmlValueType(pKV, value, len, info)) { if (!convertSmlValueType(pKV, value, len, info, true)) {
tscError("OTD:0x%"PRIx64" Failed to convert sml value string(%s) to any type", tscError("OTD:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
info->id, value); info->id, value);
//free previous alocated key field //free previous alocated key field
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册