[TD-6443]<feature>: Support OpenTSDB HTTP JSON data import format
This commit is contained in:
parent
5b90d7d2a5
commit
65013096a3
|
@ -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) {
|
int taos_insert_lines(TAOS* taos, char* lines[], int numLines) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SSmlLinesInfo* info = calloc(1, sizeof(SSmlLinesInfo));
|
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
|
||||||
info->id = genLinesSmlId();
|
info->id = genLinesSmlId();
|
||||||
|
|
||||||
if (numLines <= 0 || numLines > 65536) {
|
if (numLines <= 0 || numLines > 65536) {
|
||||||
tscError("SML:0x%"PRIx64" taos_insert_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines);
|
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;
|
code = TSDB_CODE_TSC_APP_ERROR;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2140,7 +2141,7 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines) {
|
||||||
for (int i = 0; i < numLines; ++i) {
|
for (int i = 0; i < numLines; ++i) {
|
||||||
if (lines[i] == NULL) {
|
if (lines[i] == NULL) {
|
||||||
tscError("SML:0x%"PRIx64" taos_insert_lines line %d is NULL", info->id, i);
|
tscError("SML:0x%"PRIx64" taos_insert_lines line %d is NULL", info->id, i);
|
||||||
free(info);
|
tfree(info);
|
||||||
code = TSDB_CODE_TSC_APP_ERROR;
|
code = TSDB_CODE_TSC_APP_ERROR;
|
||||||
return code;
|
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));
|
SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT));
|
||||||
if (lpPoints == NULL) {
|
if (lpPoints == NULL) {
|
||||||
tscError("SML:0x%"PRIx64" taos_insert_lines failed to allocate memory", info->id);
|
tscError("SML:0x%"PRIx64" taos_insert_lines failed to allocate memory", info->id);
|
||||||
free(info);
|
tfree(info);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2177,7 +2178,7 @@ cleanup:
|
||||||
|
|
||||||
taosArrayDestroy(lpPoints);
|
taosArrayDestroy(lpPoints);
|
||||||
|
|
||||||
free(info);
|
tfree(info);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -893,11 +893,11 @@ int32_t tscParseMultiJSONPayload(char* payload, SArray* points, SSmlLinesInfo* i
|
||||||
|
|
||||||
ret = tscParseJSONPayload(dataPoint, &point, info);
|
ret = tscParseJSONPayload(dataPoint, &point, info);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
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);
|
destroySmlDataPoint(&point);
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} 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);
|
taosArrayPush(points, &point);
|
||||||
}
|
}
|
||||||
|
@ -913,6 +913,7 @@ int taos_insert_json_payload(TAOS* taos, char* payload) {
|
||||||
|
|
||||||
if (payload == NULL) {
|
if (payload == NULL) {
|
||||||
tscError("OTD:0x%"PRIx64" taos_insert_json_payload payload is NULL", info->id);
|
tscError("OTD:0x%"PRIx64" taos_insert_json_payload payload is NULL", info->id);
|
||||||
|
tfree(info);
|
||||||
code = TSDB_CODE_TSC_APP_ERROR;
|
code = TSDB_CODE_TSC_APP_ERROR;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue