提交 3d110dd3 编写于 作者: G Ganlin Zhao

[TD-10532]<enhance>: schemaless add option to schemaless API to allow

user pass timestamp precision for line protocol, openTSDB related
timestamp accpet only 10 digits(second) or 13 digits(millisecond) by
default
上级 3e4b32bb
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
extern "C" { extern "C" {
#endif #endif
#define SML_TIMESTAMP_SECOND_DIGITS 10
#define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13
typedef struct { typedef struct {
char* key; char* key;
uint8_t type; uint8_t type;
...@@ -55,6 +58,8 @@ typedef enum { ...@@ -55,6 +58,8 @@ typedef enum {
typedef struct { typedef struct {
uint64_t id; uint64_t id;
SMLProtocolType protocol;
SMLTimeStampType tsType;
SHashObj* smlDataToSchema; SHashObj* smlDataToSchema;
} SSmlLinesInfo; } SSmlLinesInfo;
...@@ -72,9 +77,12 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -72,9 +77,12 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point); void destroySmlDataPoint(TAOS_SML_DATA_POINT* point);
int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines); int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines,
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines); SMLProtocolType protocol, SMLTimeStampType tsType);
int taos_insert_json_payload(TAOS* taos, char* payload); int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines,
SMLProtocolType protocol, SMLTimeStampType tsType);
int taos_insert_json_payload(TAOS* taos, char* payload,
SMLProtocolType protocol, SMLTimeStampType tsType);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -1071,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -1071,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0);
} }
int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL); int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms");
for (int i = 0; i < numLines; ++i) { for (int i = 0; i < numLines; ++i) {
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
......
...@@ -1397,22 +1397,28 @@ static bool isNchar(char *pVal, uint16_t len) { ...@@ -1397,22 +1397,28 @@ static bool isNchar(char *pVal, uint16_t len) {
return false; return false;
} }
static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) { static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType, SSmlLinesInfo* info) {
if (len == 0) { if (len == 0) {
return true; return true;
} }
if ((len == 1) && pVal[0] == '0') { if ((len == 1) && pVal[0] == '0') {
*tsType = SML_TIME_STAMP_NOW; *tsType = SML_TIME_STAMP_NOW;
//printf("Type is timestamp(%s)\n", pVal);
return true; return true;
} }
if (len < 2) {
return false; //Default no appendix
}
//No appendix use usec as default
if (isdigit(pVal[len - 1]) && isdigit(pVal[len - 2])) { if (isdigit(pVal[len - 1]) && isdigit(pVal[len - 2])) {
*tsType = SML_TIME_STAMP_MICRO_SECONDS; if (info->protocol == SML_LINE_PROTOCOL) {
//printf("Type is timestamp(%s)\n", pVal); *tsType = info->tsType;
} else if (info->protocol == SML_TELNET_PROTOCOL) {
if (len == SML_TIMESTAMP_SECOND_DIGITS) {
*tsType = SML_TIME_STAMP_SECONDS;
} else if (len == SML_TIMESTAMP_MILLI_SECOND_DIGITS) {
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
} else {
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
}
return true; return true;
} }
if (pVal[len - 1] == 's') { if (pVal[len - 1] == 's') {
...@@ -1699,7 +1705,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, ...@@ -1699,7 +1705,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
} }
static int32_t getTimeStampValue(char *value, uint16_t len, static int32_t getTimeStampValue(char *value, uint16_t len,
SMLTimeStampType type, int64_t *ts) { SMLTimeStampType type, int64_t *ts, SSmlLinesInfo* info) {
if (len >= 2) { if (len >= 2) {
for (int i = 0; i < len - 2; ++i) { for (int i = 0; i < len - 2; ++i) {
...@@ -1708,11 +1714,9 @@ static int32_t getTimeStampValue(char *value, uint16_t len, ...@@ -1708,11 +1714,9 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
} }
} }
} }
//No appendix or no timestamp given (len = 0) //No appendix or no timestamp given (len = 0)
if (len >= 1 && isdigit(value[len - 1]) && type != SML_TIME_STAMP_NOW) { if (len >= 1 && isdigit(value[len - 1]) && type != SML_TIME_STAMP_NOW) {
type = SML_TIME_STAMP_MICRO_SECONDS;
}
if (len != 0) {
*ts = (int64_t)strtoll(value, NULL, 10); *ts = (int64_t)strtoll(value, NULL, 10);
} else { } else {
type = SML_TIME_STAMP_NOW; type = SML_TIME_STAMP_NOW;
...@@ -1752,11 +1756,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -1752,11 +1756,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
int64_t tsVal; int64_t tsVal;
strntolower_s(value, value, len); strntolower_s(value, value, len);
if (!isTimeStamp(value, len, &type)) { if (!isTimeStamp(value, len, &type, info)) {
return TSDB_CODE_TSC_INVALID_TIME_STAMP; return TSDB_CODE_TSC_INVALID_TIME_STAMP;
} }
ret = getTimeStampValue(value, len, type, &tsVal); ret = getTimeStampValue(value, len, type, &tsVal, info);
if (ret) { if (ret) {
return ret; return ret;
} }
...@@ -2169,11 +2173,13 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile ...@@ -2169,11 +2173,13 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genLinesSmlId(); info->id = genLinesSmlId();
info->tsType = tsType;
info->protocol = protocol;
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);
...@@ -2226,6 +2232,31 @@ cleanup: ...@@ -2226,6 +2232,31 @@ cleanup:
return code; return code;
} }
int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) {
int32_t len = (int32_t)strlen(precision);
if (len == 1 && precision[0] == 's') {
*tsType = SML_TIME_STAMP_SECONDS;
} else if (len == 2 && precision[1] == 's') {
switch (precision[0]) {
case 'm':
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
break;
case 'u':
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
break;
case 'n':
*tsType = SML_TIME_STAMP_NANO_SECONDS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else {
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
return TSDB_CODE_SUCCESS;
}
/** /**
* taos_schemaless_insert() parse and insert data points into database according to * taos_schemaless_insert() parse and insert data points into database according to
* different protocol. * different protocol.
...@@ -2247,17 +2278,26 @@ cleanup: ...@@ -2247,17 +2278,26 @@ cleanup:
* *
*/ */
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol) { int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision) {
int code; int code;
SMLTimeStampType tsType;
if (protocol == SML_LINE_PROTOCOL) {
code = convertPrecisionStrType(precision, &tsType);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
switch (protocol) { switch (protocol) {
case SML_LINE_PROTOCOL: case SML_LINE_PROTOCOL:
code = taos_insert_lines(taos, lines, numLines); code = taos_insert_lines(taos, lines, numLines, protocol, tsType);
break; break;
case SML_TELNET_PROTOCOL: case SML_TELNET_PROTOCOL:
code = taos_insert_telnet_lines(taos, lines, numLines); code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType);
break; break;
case SML_JSON_PROTOCOL: case SML_JSON_PROTOCOL:
code = taos_insert_json_payload(taos, *lines); code = taos_insert_json_payload(taos, *lines, protocol, tsType);
break; break;
default: default:
code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE; code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE;
......
...@@ -394,11 +394,13 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, ...@@ -394,11 +394,13 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points,
return TSDB_CODE_SUCCESS; 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, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genUID(); info->id = genUID();
info->tsType = tsType;
info->protocol = protocol;
if (numLines <= 0 || numLines > 65536) { 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); tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d", info->id, numLines);
...@@ -563,7 +565,14 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k ...@@ -563,7 +565,14 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k
tsVal = taosGetTimestampNs(); tsVal = taosGetTimestampNs();
} else { } else {
tsVal = strtoll(timestamp->numberstring, NULL, 10); tsVal = strtoll(timestamp->numberstring, NULL, 10);
tsVal = convertTimePrecision(tsVal, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO); size_t tsLen = strlen(timestamp->numberstring);
if (tsLen == SML_TIMESTAMP_SECOND_DIGITS) {
tsVal = (int64_t)(tsVal * 1e9);
} else if (tsLen == SML_TIMESTAMP_MILLI_SECOND_DIGITS) {
tsVal = convertTimePrecision(tsVal, TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_NANO);
} else {
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
} }
} else if (cJSON_IsObject(timestamp)) { } else if (cJSON_IsObject(timestamp)) {
int32_t ret = parseTimestampFromJSONObj(timestamp, &tsVal, info); int32_t ret = parseTimestampFromJSONObj(timestamp, &tsVal, info);
...@@ -1017,11 +1026,13 @@ PARSE_JSON_OVER: ...@@ -1017,11 +1026,13 @@ PARSE_JSON_OVER:
return ret; return ret;
} }
int taos_insert_json_payload(TAOS* taos, char* payload) { int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
info->id = genUID(); info->id = genUID();
info->tsType = tsType;
info->protocol = protocol;
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);
......
...@@ -187,7 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); ...@@ -187,7 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol); DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -113,6 +113,7 @@ int32_t* taosGetErrno(); ...@@ -113,6 +113,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration") #define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration")
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range") #define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range")
#define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type") #define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type")
#define TSDB_CODE_TSC_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid timestamp precision type")
// 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")
......
...@@ -121,6 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data typ ...@@ -121,6 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data typ
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_VALUE_OUT_OF_RANGE, "Value out of range") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_VALUE_OUT_OF_RANGE, "Value out of range")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE, "Invalid line protocol type")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PRECISION_TYPE, "Invalid timestamp precision type")
// 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")
......
...@@ -969,51 +969,51 @@ int32_t verify_schema_less(TAOS* taos) { ...@@ -969,51 +969,51 @@ int32_t verify_schema_less(TAOS* taos) {
int code = 0; int code = 0;
char* lines[] = { char* lines[] = {
"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns", "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns", "ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns", "st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns", "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns", "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns" "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
}; };
code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0); code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0, "ns");
char* lines2[] = { char* lines2[] = {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns" "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"
}; };
code = taos_schemaless_insert(taos, &lines2[0], 1, 0); code = taos_schemaless_insert(taos, &lines2[0], 1, 0, "ns");
code = taos_schemaless_insert(taos, &lines2[1], 1, 0); code = taos_schemaless_insert(taos, &lines2[1], 1, 0, "ns");
char* lines3[] = { char* lines3[] = {
"sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms", "sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
}; };
code = taos_schemaless_insert(taos, lines3, 2, 0); code = taos_schemaless_insert(taos, lines3, 2, 0, "ms");
char* lines4[] = { char* lines4[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns" "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
}; };
code = taos_schemaless_insert(taos, lines4, 2, 0); code = taos_schemaless_insert(taos, lines4, 2, 0, "ns");
char* lines5[] = { char* lines5[] = {
"zqlbgs,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000ns", "zqlbgs,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"zqlbgs,t9=f,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000ns" "zqlbgs,t9=f,id=\"zqlbgs_39302_21680\",t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000"
}; };
code = taos_schemaless_insert(taos, &lines5[0], 1, 0); code = taos_schemaless_insert(taos, &lines5[0], 1, 0, "ns");
code = taos_schemaless_insert(taos, &lines5[1], 1, 0); code = taos_schemaless_insert(taos, &lines5[1], 1, 0, "ns");
char* lines6[] = { char* lines6[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns" "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
}; };
code = taos_schemaless_insert(taos, lines6, 2, 0); code = taos_schemaless_insert(taos, lines6, 2, 0, "ns");
return (code); return (code);
} }
......
...@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) { ...@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
printf("%s\n", "begin taos_schemaless_insert"); printf("%s\n", "begin taos_schemaless_insert");
int64_t begin = getTimeInUs(); int64_t begin = getTimeInUs();
int32_t code = taos_schemaless_insert(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable, 0); int32_t code = taos_schemaless_insert(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable, 0, "ms");
int64_t end = getTimeInUs(); int64_t end = getTimeInUs();
printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin); printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin);
......
...@@ -16,10 +16,10 @@ sql create database $db precision 'us' ...@@ -16,10 +16,10 @@ sql create database $db precision 'us'
sql use $db sql use $db
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint) sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000ns line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000
line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
sql select * from st sql select * from st
if $rows != 2 then if $rows != 2 then
return -1 return -1
......
...@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { ...@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest); simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true); simLogSql(buf, true);
char * lines[] = {rest}; char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0); int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns");
if (ret == TSDB_CODE_SUCCESS) { if (ret == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++; script->linePos++;
...@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { ...@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest); simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true); simLogSql(buf, true);
char * lines[] = {rest}; char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0); int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns");
if (ret == TSDB_CODE_SUCCESS) { if (ret == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++; script->linePos++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册