提交 31d461ba 编写于 作者: G Ganlin Zhao

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

上级 345da2ef
...@@ -1677,7 +1677,7 @@ static int32_t getTimeStampValue(char *value, uint16_t len, ...@@ -1677,7 +1677,7 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
if (len >= 2) { if (len >= 2) {
for (int i = 0; i < len - 2; ++i) { for (int i = 0; i < len - 2; ++i) {
if(!isdigit(value[i])) { if(!isdigit(value[i])) {
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_TIME_STAMP;
} }
} }
} }
...@@ -1712,7 +1712,7 @@ static int32_t getTimeStampValue(char *value, uint16_t len, ...@@ -1712,7 +1712,7 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
break; break;
} }
default: { default: {
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_TIME_STAMP;
} }
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -1725,7 +1725,7 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -1725,7 +1725,7 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
int64_t tsVal; int64_t tsVal;
if (!isTimeStamp(value, len, &type)) { if (!isTimeStamp(value, len, &type)) {
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_TIME_STAMP;
} }
ret = getTimeStampValue(value, len, type, &tsVal); ret = getTimeStampValue(value, len, type, &tsVal);
......
...@@ -47,7 +47,7 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index, ...@@ -47,7 +47,7 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
if (len > TSDB_TABLE_NAME_LEN) { if (len > TSDB_TABLE_NAME_LEN) {
tscError("OTD:0x%"PRIx64" Metric cannot exceeds 193 characters", info->id); tscError("OTD:0x%"PRIx64" Metric cannot exceeds 193 characters", info->id);
tfree(pSml->stableName); tfree(pSml->stableName);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
} }
if (*cur == ' ') { if (*cur == ' ') {
...@@ -147,7 +147,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch ...@@ -147,7 +147,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
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);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_VALUE;
} }
tfree(value); tfree(value);
...@@ -172,7 +172,7 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj ...@@ -172,7 +172,7 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
while (*cur != '\0') { while (*cur != '\0') {
if (len > TSDB_COL_NAME_LEN) { if (len > TSDB_COL_NAME_LEN) {
tscError("OTD:0x%"PRIx64" Tag key cannot exceeds 65 characters", info->id); tscError("OTD:0x%"PRIx64" Tag key cannot exceeds 65 characters", info->id);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
} }
if (*cur == '=') { if (*cur == '=') {
break; break;
...@@ -188,7 +188,7 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj ...@@ -188,7 +188,7 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
key[len] = '\0'; key[len] = '\0';
if (checkDuplicateKey(key, pHash, info)) { if (checkDuplicateKey(key, pHash, info)) {
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_DUP_TAG_NAMES;
} }
pKV->key = tcalloc(len + 1, 1); pKV->key = tcalloc(len + 1, 1);
...@@ -231,7 +231,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index, ...@@ -231,7 +231,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
//free previous alocated key field //free previous alocated key field
tfree(pKV->key); tfree(pKV->key);
tfree(value); tfree(value);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_INVALID_VALUE;
} }
tfree(value); tfree(value);
...@@ -348,14 +348,14 @@ int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, SArray* ...@@ -348,14 +348,14 @@ int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, SArray*
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tscError("OTD:0x%"PRIx64" data point line parse failed. line %d : %s", info->id, i, lines[i]); tscError("OTD:0x%"PRIx64" data point line parse failed. line %d : %s", info->id, i, lines[i]);
destroySmlDataPoint(&point); destroySmlDataPoint(&point);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return code;
} else { } else {
tscDebug("OTD:0x%"PRIx64" data point line parse success. line %d", info->id, i); tscDebug("OTD:0x%"PRIx64" data point line parse success. line %d", info->id, i);
} }
taosArrayPush(points, &point); taosArrayPush(points, &point);
} }
return 0; return TSDB_CODE_SUCCESS;
} }
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines) { int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines) {
......
...@@ -106,6 +106,7 @@ int32_t* taosGetErrno(); ...@@ -106,6 +106,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D) //"duplicated column names") #define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D) //"duplicated column names")
#define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E) //"Invalid tag length") #define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E) //"Invalid tag length")
#define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F) //"Invalid column length") #define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F) //"Invalid column length")
#define TSDB_CODE_TSC_DUP_TAG_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220) //"duplicated tag names")
// mnode // mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed") #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
......
...@@ -112,9 +112,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too lon ...@@ -112,9 +112,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too lon
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_FILE_EMPTY, "File is empty") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_FILE_EMPTY, "File is empty")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_LINE_SYNTAX_ERROR, "Syntax error in Line") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_LINE_SYNTAX_ERROR, "Syntax error in Line")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_META_CACHED, "No table meta cached") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_META_CACHED, "No table meta cached")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DUP_COL_NAMES, "duplicated column names") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DUP_COL_NAMES, "duplicated column names")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TAG_LENGTH, "Invalid tag length") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TAG_LENGTH, "Invalid tag length")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, "Invalid column length") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, "Invalid column length")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DUP_TAG_NAMES, "duplicated tag names")
// mnode // mnode
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册