From 65013096a3aa654a7bdfe30134fbac88ebc5dbe7 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 6 Sep 2021 12:32:49 +0800 Subject: [PATCH] [TD-6443]: Support OpenTSDB HTTP JSON data import format --- src/client/src/tscParseLineProtocol.c | 9 +++++---- src/client/src/tscParseOpenTSDB.c | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index c9ad7361ef..e26e439492 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2128,11 +2128,12 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { int32_t code = 0; - SSmlLinesInfo* info = calloc(1, sizeof(SSmlLinesInfo)); + SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); info->id = genLinesSmlId(); if (numLines <= 0 || numLines > 65536) { tscError("SML:0x%"PRIx64" taos_insert_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines); + tfree(info); code = TSDB_CODE_TSC_APP_ERROR; return code; } @@ -2140,7 +2141,7 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { for (int i = 0; i < numLines; ++i) { if (lines[i] == NULL) { tscError("SML:0x%"PRIx64" taos_insert_lines line %d is NULL", info->id, i); - free(info); + tfree(info); code = TSDB_CODE_TSC_APP_ERROR; return code; } @@ -2149,7 +2150,7 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT)); if (lpPoints == NULL) { tscError("SML:0x%"PRIx64" taos_insert_lines failed to allocate memory", info->id); - free(info); + tfree(info); return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -2177,7 +2178,7 @@ cleanup: taosArrayDestroy(lpPoints); - free(info); + tfree(info); return code; } diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 2d2587960f..7683ac0a56 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -893,11 +893,11 @@ int32_t tscParseMultiJSONPayload(char* payload, SArray* points, SSmlLinesInfo* i ret = tscParseJSONPayload(dataPoint, &point, info); if (ret != TSDB_CODE_SUCCESS) { - tscError("OTD:0x%"PRIx64" data point line parse failed", info->id); + tscError("OTD:0x%"PRIx64" JSON data point parse failed", info->id); destroySmlDataPoint(&point); return ret; } else { - tscDebug("OTD:0x%"PRIx64" data point line parse success", info->id); + tscDebug("OTD:0x%"PRIx64" JSON data point parse success", info->id); } taosArrayPush(points, &point); } @@ -913,6 +913,7 @@ int taos_insert_json_payload(TAOS* taos, char* payload) { if (payload == NULL) { tscError("OTD:0x%"PRIx64" taos_insert_json_payload payload is NULL", info->id); + tfree(info); code = TSDB_CODE_TSC_APP_ERROR; return code; }