From 0318c20eda15a64928e1120ad60c60e3357e1e80 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 8 Oct 2022 13:59:39 +0800 Subject: [PATCH] fix:change the new interface name of schemaless --- src/client/inc/tscParseLine.h | 6 ++-- src/client/src/tscParseLineProtocol.c | 41 ++++++++++++++------------- src/client/src/tscParseOpenTSDB.c | 32 ++++++++++----------- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/client/inc/tscParseLine.h b/src/client/inc/tscParseLine.h index 802e88eef9..8e84d0831d 100644 --- a/src/client/inc/tscParseLine.h +++ b/src/client/inc/tscParseLine.h @@ -103,11 +103,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, void destroySmlDataPoint(TAOS_SML_DATA_POINT* point); -int taos_insert_lines(TAOS* taos, char* data, int32_t len, char* lines[], int numLines, SMLProtocolType protocol, +int taos_insert_lines(TAOS* taos, char* data, int32_t len, char* lines[], int *numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows); -int taos_insert_telnet_lines(TAOS* taos, char* data, int32_t len, char* lines[], int numLines, SMLProtocolType protocol, +int taos_insert_telnet_lines(TAOS* taos, char* data, int32_t len, char* lines[], int *numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows); -int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, +int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, int *numLines, SMLTimeStampType tsType, int* affectedRows); diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index a8cde1d20a..f8153abd67 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2699,7 +2699,7 @@ int32_t tscParseLines(char* data, int32_t len, char* lines[], int numLines, SArr return code; } -int taos_insert_lines(TAOS* taos, char* data, int len, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int *affectedRows) { +int taos_insert_lines(TAOS* taos, char* data, int len, char* lines[], int *numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int *affectedRows) { int32_t code = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); @@ -2708,26 +2708,26 @@ int taos_insert_lines(TAOS* taos, char* data, int len, char* lines[], int numLin info->protocol = protocol; if (data){ - numLines = 0; + *numLines = 0; for(int i = 0; i < len; i++){ if(data[i] == '\0'){ data[i] = '0'; } if(data[i] == '\n' || i == len - 1){ - numLines++; + (*numLines)++; } } } - if (numLines <= 0 || numLines > 65536*32) { - tscError("SML:0x%"PRIx64" taos_insert_lines numLines should be between 1 and 65536*32. numLines: %d", info->id, numLines); + if (*numLines <= 0 || *numLines > 65536*32) { + tscError("SML:0x%"PRIx64" taos_insert_lines numLines should be between 1 and 65536*32. numLines: %d", info->id, *numLines); tfree(info); code = TSDB_CODE_TSC_APP_ERROR; return code; } if(lines){ - for (int i = 0; i < numLines; ++i) { + 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); tfree(info); @@ -2737,22 +2737,22 @@ int taos_insert_lines(TAOS* taos, char* data, int len, char* lines[], int numLin } } - SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT)); + 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); tfree(info); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - tscDebug("SML:0x%"PRIx64" taos_insert_lines begin inserting %d lines", info->id, numLines); - code = tscParseLines(data, len, lines, numLines, lpPoints, NULL, info); + tscDebug("SML:0x%"PRIx64" taos_insert_lines begin inserting %d lines", info->id, *numLines); + code = tscParseLines(data, len, lines, *numLines, lpPoints, NULL, info); size_t numPoints = taosArrayGetSize(lpPoints); + TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); if (code != 0) { goto cleanup; } - TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); code = tscSmlInsert(taos, points, (int)numPoints, info); if (code != 0) { tscError("SML:0x%"PRIx64" taos_sml_insert error: %s", info->id, tstrerror((code))); @@ -2762,9 +2762,7 @@ int taos_insert_lines(TAOS* taos, char* data, int len, char* lines[], int numLin } cleanup: - tscDebug("SML:0x%"PRIx64" taos_insert_lines finish inserting %d lines. code: %d", info->id, numLines, code); - points = TARRAY_GET_START(lpPoints); - numPoints = taosArrayGetSize(lpPoints); + tscDebug("SML:0x%"PRIx64" taos_insert_lines finish inserting %d lines. code: %d", info->id, *numLines, code); for (int i=0; iprotocol = protocol; if (data && !lines){ - numLines = 0; + *numLines = 0; for(int i = 0; i < len; i++){ if(data[i] == '\0'){ data[i] = '0'; } if(data[i] == '\n' || i == len - 1){ - numLines++; + (*numLines)++; } } } - if (numLines <= 0 || numLines > 65536) { - tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines); + if (*numLines <= 0 || *numLines > 65536) { + tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d", info->id, *numLines); tfree(info); code = TSDB_CODE_TSC_APP_ERROR; return code; } if(!data && lines){ - for (int i = 0; i < numLines; ++i) { + for (int i = 0; i < *numLines; ++i) { if (lines[i] == NULL) { tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines line %d is NULL", info->id, i); tfree(info); @@ -488,22 +488,22 @@ int taos_insert_telnet_lines(TAOS* taos, char* data, int32_t len, char* lines[], } } - SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT)); + SArray* lpPoints = taosArrayInit(*numLines, sizeof(TAOS_SML_DATA_POINT)); if (lpPoints == NULL) { tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines failed to allocate memory", info->id); tfree(info); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines begin inserting %d lines, first line: %s", info->id, numLines, lines[0]); - code = tscParseTelnetLines(data, len, lines, numLines, lpPoints, NULL, info); + tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines begin inserting %d lines, first line: %s", info->id, *numLines, lines[0]); + code = tscParseTelnetLines(data, len, lines, *numLines, lpPoints, NULL, info); size_t numPoints = taosArrayGetSize(lpPoints); + TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); if (code != 0) { goto cleanup; } - TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); code = tscSmlInsert(taos, points, (int)numPoints, info); if (code != 0) { tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines error: %s", info->id, tstrerror((code))); @@ -513,9 +513,7 @@ int taos_insert_telnet_lines(TAOS* taos, char* data, int32_t len, char* lines[], } cleanup: - tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines finish inserting %d lines. code: %d", info->id, numLines, code); - points = TARRAY_GET_START(lpPoints); - numPoints = taosArrayGetSize(lpPoints); + tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines finish inserting %d lines. code: %d", info->id, *numLines, code); for (int i = 0; i < numPoints; ++i) { destroySmlDataPoint(points+i); } @@ -1107,8 +1105,9 @@ PARSE_JSON_OVER: return ret; } -int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows) { +int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, int32_t *totalRows, SMLTimeStampType tsType, int* affectedRows) { int32_t code = 0; + *totalRows = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); info->id = genUID(); @@ -1132,12 +1131,12 @@ int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines begin inserting %d points", info->id, 1); code = tscParseMultiJSONPayload(payload, lpPoints, info); size_t numPoints = taosArrayGetSize(lpPoints); + TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); if (code != 0) { goto cleanup; } - TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); code = tscSmlInsert(taos, points, (int)numPoints, info); if (code != 0) { tscError("OTD:0x%"PRIx64" taos_insert_json_payload error: %s", info->id, tstrerror((code))); @@ -1145,11 +1144,10 @@ int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol if (affectedRows != NULL) { *affectedRows = info->affectedRows; } + *totalRows = numPoints; cleanup: tscDebug("OTD:0x%"PRIx64" taos_insert_json_payload finish inserting 1 Point. code: %d", info->id, code); - points = TARRAY_GET_START(lpPoints); - numPoints = taosArrayGetSize(lpPoints); for (int i = 0; i < numPoints; ++i) { destroySmlDataPoint(points+i); } -- GitLab