提交 14bb977f 编写于 作者: S shenglian zhou

refactor into function for one datapoint sml insert

上级 ac45017a
......@@ -184,7 +184,7 @@ static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableNa
uint64_t digest1 = *(uint64_t*)(context.digest);
uint64_t digest2 = *(uint64_t*)(context.digest + 8);
*tableNameLen = snprintf(tableName, *tableNameLen,
"t_%16lx%16lx", digest1, digest2);
"t_%16" PRIx64 "%16" PRIx64, digest1, digest2);
taosStringBuilderDestroy(&sb);
tscDebug("SML:0x%"PRIx64" child table name: %s", info->id, tableName);
return 0;
......@@ -1202,24 +1202,21 @@ cleanup:
return code;
}
int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info) {
tscDebug("SML:0x%"PRIx64" taos_sml_insert. number of points: %d", info->id, numPoint);
static int doSmlInsertOneDataPoint(TAOS* taos, TAOS_SML_DATA_POINT* point, SSmlLinesInfo* info) {
int32_t code = TSDB_CODE_SUCCESS;
info->affectedRows = 0;
if (numPoint == 1) {
TAOS_SML_DATA_POINT* point = points + 0;
if (!point->childTableName) {
int tableNameLen = TSDB_TABLE_NAME_LEN;
point->childTableName = calloc(1, tableNameLen + 1);
getSmlMd5ChildTableName(point, point->childTableName, &tableNameLen, info);
point->childTableName[tableNameLen] = '\0';
}
STableMeta* tableMeta;
STableMeta* tableMeta = NULL;
int32_t ret = getSuperTableMetaFromLocalCache(taos, point->stableName, &tableMeta, info);
if (ret == TSDB_CODE_SUCCESS) {
if (ret != TSDB_CODE_SUCCESS) {
return ret;
}
uint8_t precision = tableMeta->tableInfo.precision;
free(tableMeta);
......@@ -1247,6 +1244,7 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
--sqlLen;
sqlLen += snprintf(sql + sqlLen, freeBytes - sqlLen, ")");
sql[sqlLen] = 0;
tscDebug("SML:0x%" PRIx64 " insert child table table %s of super table %s sql: %s", info->id,
point->childTableName, point->stableName, sql);
TAOS_RES* res = taos_query(taos, sql);
......@@ -1254,11 +1252,24 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
code = taos_errno(res);
info->affectedRows = taos_affected_rows(res);
taos_free_result(res);
return code;
}
int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info) {
tscDebug("SML:0x%"PRIx64" taos_sml_insert. number of points: %d", info->id, numPoint);
int32_t code = TSDB_CODE_SUCCESS;
info->affectedRows = 0;
if (numPoint == 1) {
TAOS_SML_DATA_POINT* point = points + 0;
code = doSmlInsertOneDataPoint(taos, point, info);
if (code == TSDB_CODE_SUCCESS) {
return code;
}
}
}
tscDebug("SML:0x%"PRIx64" build data point schemas", info->id);
SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray<STableColumnsSchema>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册