提交 48e8c6b0 编写于 作者: G Ganlin Zhao

[TD-6442]<feature>: Support OpenTSDB telnet style data import format

上级 bc95808b
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "tscParseLine.h" #include "tscParseLine.h"
#define MAX_TELNET_FILEDS_NUM 2
/* telnet style API parser */ /* telnet style API parser */
static uint64_t HandleId = 0; static uint64_t HandleId = 0;
...@@ -72,7 +74,8 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char ...@@ -72,7 +74,8 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
char *value = NULL; char *value = NULL;
start = cur = *index; start = cur = *index;
*pTS = tcalloc(1, sizeof(TAOS_SML_KV)); //allocate fields for timestamp and value
*pTS = tcalloc(MAX_TELNET_FILEDS_NUM, sizeof(TAOS_SML_KV));
while(*cur != '\0') { while(*cur != '\0') {
if (*cur == ' ') { if (*cur == ' ') {
...@@ -108,8 +111,8 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char ...@@ -108,8 +111,8 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
} }
static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const char **index, SSmlLinesInfo* info) { static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const char **index, SSmlLinesInfo* info) {
//SKip timestamp //skip timestamp
TAOS_SML_KV *pVal = *pKVs + sizeof(TAOS_SML_KV); TAOS_SML_KV *pVal = *pKVs + 1;
const char *start, *cur; const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
int len = 0; int len = 0;
...@@ -117,7 +120,6 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -117,7 +120,6 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
char *value = NULL; char *value = NULL;
start = cur = *index; start = cur = *index;
pVal = tcalloc(1, sizeof(TAOS_SML_KV));
while(*cur != '\0') { while(*cur != '\0') {
if (*cur == ' ') { if (*cur == ' ') {
...@@ -131,7 +133,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -131,7 +133,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
value = tcalloc(len + 1, 1); value = tcalloc(len + 1, 1);
memcpy(value, start, len); memcpy(value, start, len);
} else { } else {
tfree(pVal); tfree(*pKVs);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} }
...@@ -139,7 +141,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -139,7 +141,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
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);
tfree(value); tfree(value);
tfree(pVal); tfree(*pKVs);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} }
tfree(value); tfree(value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册