Merge pull request #7102 from taosdata/feature/TD-5559
[TD-5559]<enhance>:[schemaless]add unique id to sml parser logs
This commit is contained in:
commit
e45b047e5f
|
@ -1417,7 +1417,7 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str) {
|
static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str, SSmlLinesInfo* info) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
uint8_t type = pVal->type;
|
uint8_t type = pVal->type;
|
||||||
int16_t length = pVal->length;
|
int16_t length = pVal->length;
|
||||||
|
@ -1436,7 +1436,7 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
tscError("Converted number out of range");
|
tscError("SML:0x%"PRIx64" Convert number(%s) out of range", info->id, str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1518,7 +1518,7 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str) {
|
||||||
}
|
}
|
||||||
//len does not include '\0' from value.
|
//len does not include '\0' from value.
|
||||||
static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
uint16_t len) {
|
uint16_t len, SSmlLinesInfo* info) {
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1528,7 +1528,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_TINYINT;
|
pVal->type = TSDB_DATA_TYPE_TINYINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 2] = '\0';
|
value[len - 2] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1537,7 +1537,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_UTINYINT;
|
pVal->type = TSDB_DATA_TYPE_UTINYINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 2] = '\0';
|
value[len - 2] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1546,7 +1546,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_SMALLINT;
|
pVal->type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1555,7 +1555,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_USMALLINT;
|
pVal->type = TSDB_DATA_TYPE_USMALLINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1564,7 +1564,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_INT;
|
pVal->type = TSDB_DATA_TYPE_INT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1573,7 +1573,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_UINT;
|
pVal->type = TSDB_DATA_TYPE_UINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1582,7 +1582,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_BIGINT;
|
pVal->type = TSDB_DATA_TYPE_BIGINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1591,7 +1591,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_UBIGINT;
|
pVal->type = TSDB_DATA_TYPE_UBIGINT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidInteger(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidInteger(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1601,7 +1601,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_FLOAT;
|
pVal->type = TSDB_DATA_TYPE_FLOAT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidFloat(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidFloat(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1610,7 +1610,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
pVal->type = TSDB_DATA_TYPE_DOUBLE;
|
pVal->type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
value[len - 3] = '\0';
|
value[len - 3] = '\0';
|
||||||
if (!isValidFloat(value) || !convertStrToNumber(pVal, value)) {
|
if (!isValidFloat(value) || !convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1646,7 +1646,7 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
if (isValidInteger(value) || isValidFloat(value)) {
|
if (isValidInteger(value) || isValidFloat(value)) {
|
||||||
pVal->type = TSDB_DATA_TYPE_FLOAT;
|
pVal->type = TSDB_DATA_TYPE_FLOAT;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
if (!convertStrToNumber(pVal, value)) {
|
if (!convertStrToNumber(pVal, value, info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1702,7 +1702,7 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
||||||
uint16_t len) {
|
uint16_t len, SSmlLinesInfo* info) {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
SMLTimeStampType type;
|
SMLTimeStampType type;
|
||||||
int64_t tsVal;
|
int64_t tsVal;
|
||||||
|
@ -1715,7 +1715,7 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
tscDebug("Timestamp after conversion:%"PRId64, tsVal);
|
tscDebug("SML:0x%"PRIx64"Timestamp after conversion:%"PRId64, info->id, tsVal);
|
||||||
|
|
||||||
pVal->type = TSDB_DATA_TYPE_TIMESTAMP;
|
pVal->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
|
||||||
|
@ -1724,7 +1724,7 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index) {
|
static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index, SSmlLinesInfo* info) {
|
||||||
const char *start, *cur;
|
const char *start, *cur;
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
@ -1744,7 +1744,7 @@ static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index) {
|
||||||
memcpy(value, start, len);
|
memcpy(value, start, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = convertSmlTimeStamp(*pTS, value, len);
|
ret = convertSmlTimeStamp(*pTS, value, len, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
free(value);
|
free(value);
|
||||||
free(*pTS);
|
free(*pTS);
|
||||||
|
@ -1757,7 +1757,7 @@ static int32_t parseSmlTimeStamp(TAOS_SML_KV **pTS, const char **index) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkDuplicateKey(char *key, SHashObj *pHash) {
|
static bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) {
|
||||||
char *val = NULL;
|
char *val = NULL;
|
||||||
char *cur = key;
|
char *cur = key;
|
||||||
char keyLower[TSDB_COL_NAME_LEN];
|
char keyLower[TSDB_COL_NAME_LEN];
|
||||||
|
@ -1771,7 +1771,7 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash) {
|
||||||
|
|
||||||
val = taosHashGet(pHash, keyLower, keyLen);
|
val = taosHashGet(pHash, keyLower, keyLen);
|
||||||
if (val) {
|
if (val) {
|
||||||
tscError("Duplicate key:%s", keyLower);
|
tscError("SML:0x%"PRIx64" Duplicate key detected:%s", info->id, keyLower);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1781,19 +1781,19 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash) {
|
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash, SSmlLinesInfo* info) {
|
||||||
const char *cur = *index;
|
const char *cur = *index;
|
||||||
char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write
|
char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
|
|
||||||
//key field cannot start with digit
|
//key field cannot start with digit
|
||||||
if (isdigit(*cur)) {
|
if (isdigit(*cur)) {
|
||||||
tscError("Tag key cannnot start with digit\n");
|
tscError("SML:0x%"PRIx64" Tag key cannnot start with digit", info->id);
|
||||||
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
if (len > TSDB_COL_NAME_LEN) {
|
if (len > TSDB_COL_NAME_LEN) {
|
||||||
tscDebug("Key field cannot exceeds 65 characters");
|
tscError("SML:0x%"PRIx64" Key field cannot exceeds 65 characters", info->id);
|
||||||
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
//unescaped '=' identifies a tag key
|
//unescaped '=' identifies a tag key
|
||||||
|
@ -1810,20 +1810,20 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
|
||||||
}
|
}
|
||||||
key[len] = '\0';
|
key[len] = '\0';
|
||||||
|
|
||||||
if (checkDuplicateKey(key, pHash)) {
|
if (checkDuplicateKey(key, pHash, info)) {
|
||||||
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pKV->key = calloc(len + 1, 1);
|
pKV->key = calloc(len + 1, 1);
|
||||||
memcpy(pKV->key, key, len + 1);
|
memcpy(pKV->key, key, len + 1);
|
||||||
//tscDebug("Key:%s|len:%d", pKV->key, len);
|
//tscDebug("SML:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
|
||||||
*index = cur + 1;
|
*index = cur + 1;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
|
static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
|
||||||
bool *is_last_kv) {
|
bool *is_last_kv, SSmlLinesInfo* info) {
|
||||||
const char *start, *cur;
|
const char *start, *cur;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
|
@ -1847,7 +1847,9 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
|
||||||
value = calloc(len + 1, 1);
|
value = calloc(len + 1, 1);
|
||||||
memcpy(value, start, len);
|
memcpy(value, start, len);
|
||||||
value[len] = '\0';
|
value[len] = '\0';
|
||||||
if (!convertSmlValueType(pKV, value, len)) {
|
if (!convertSmlValueType(pKV, value, len, info)) {
|
||||||
|
tscError("SML:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
|
||||||
|
info->id, value);
|
||||||
//free previous alocated key field
|
//free previous alocated key field
|
||||||
free(pKV->key);
|
free(pKV->key);
|
||||||
pKV->key = NULL;
|
pKV->key = NULL;
|
||||||
|
@ -1861,7 +1863,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index,
|
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index,
|
||||||
uint8_t *has_tags) {
|
uint8_t *has_tags, SSmlLinesInfo* info) {
|
||||||
const char *cur = *index;
|
const char *cur = *index;
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
|
|
||||||
|
@ -1870,7 +1872,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (isdigit(*cur)) {
|
if (isdigit(*cur)) {
|
||||||
tscError("Measurement field cannnot start with digit");
|
tscError("SML:0x%"PRIx64" Measurement field cannnot start with digit", info->id);
|
||||||
free(pSml->stableName);
|
free(pSml->stableName);
|
||||||
pSml->stableName = NULL;
|
pSml->stableName = NULL;
|
||||||
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
||||||
|
@ -1878,7 +1880,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
|
||||||
|
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
if (len > TSDB_TABLE_NAME_LEN) {
|
if (len > TSDB_TABLE_NAME_LEN) {
|
||||||
tscError("Measurement field cannot exceeds 193 characters");
|
tscError("SML:0x%"PRIx64" Measurement field cannot exceeds 193 characters", info->id);
|
||||||
free(pSml->stableName);
|
free(pSml->stableName);
|
||||||
pSml->stableName = NULL;
|
pSml->stableName = NULL;
|
||||||
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
|
||||||
|
@ -1902,7 +1904,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
|
||||||
}
|
}
|
||||||
pSml->stableName[len] = '\0';
|
pSml->stableName[len] = '\0';
|
||||||
*index = cur + 1;
|
*index = cur + 1;
|
||||||
tscDebug("Stable name in measurement:%s|len:%d", pSml->stableName, len);
|
tscDebug("SML:0x%"PRIx64" Stable name in measurement:%s|len:%d", info->id, pSml->stableName, len);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1921,7 +1923,8 @@ static int32_t isValidChildTableName(const char *pTbName, int16_t len) {
|
||||||
|
|
||||||
static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
|
static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
|
||||||
const char **index, bool isField,
|
const char **index, bool isField,
|
||||||
TAOS_SML_DATA_POINT* smlData, SHashObj *pHash) {
|
TAOS_SML_DATA_POINT* smlData, SHashObj *pHash,
|
||||||
|
SSmlLinesInfo* info) {
|
||||||
const char *cur = *index;
|
const char *cur = *index;
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
TAOS_SML_KV *pkv;
|
TAOS_SML_KV *pkv;
|
||||||
|
@ -1941,14 +1944,14 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
ret = parseSmlKey(pkv, &cur, pHash);
|
ret = parseSmlKey(pkv, &cur, pHash, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse key field");
|
tscError("SML:0x%"PRIx64" Unable to parse key", info->id);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
ret = parseSmlValue(pkv, &cur, &is_last_kv);
|
ret = parseSmlValue(pkv, &cur, &is_last_kv, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse value field");
|
tscError("SML:0x%"PRIx64" Unable to parse value", info->id);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!isField &&
|
if (!isField &&
|
||||||
|
@ -1966,7 +1969,6 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
|
||||||
*num_kvs += 1;
|
*num_kvs += 1;
|
||||||
}
|
}
|
||||||
if (is_last_kv) {
|
if (is_last_kv) {
|
||||||
//tscDebug("last key-value field detected");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2024,50 +2026,50 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t
|
||||||
free(ts);
|
free(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData) {
|
int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInfo* info) {
|
||||||
const char* index = sql;
|
const char* index = sql;
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
uint8_t has_tags = 0;
|
uint8_t has_tags = 0;
|
||||||
TAOS_SML_KV *timestamp = NULL;
|
TAOS_SML_KV *timestamp = NULL;
|
||||||
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
||||||
|
|
||||||
ret = parseSmlMeasurement(smlData, &index, &has_tags);
|
ret = parseSmlMeasurement(smlData, &index, &has_tags, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse measurement");
|
tscError("SML:0x%"PRIx64" Unable to parse measurement", info->id);
|
||||||
taosHashCleanup(keyHashTable);
|
taosHashCleanup(keyHashTable);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
tscDebug("Parse measurement finished, has_tags:%d", has_tags);
|
tscDebug("SML:0x%"PRIx64" Parse measurement finished, has_tags:%d", info->id, has_tags);
|
||||||
|
|
||||||
//Parse Tags
|
//Parse Tags
|
||||||
if (has_tags) {
|
if (has_tags) {
|
||||||
ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &index, false, smlData, keyHashTable);
|
ret = parseSmlKvPairs(&smlData->tags, &smlData->tagNum, &index, false, smlData, keyHashTable, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse tag");
|
tscError("SML:0x%"PRIx64" Unable to parse tag", info->id);
|
||||||
taosHashCleanup(keyHashTable);
|
taosHashCleanup(keyHashTable);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tscDebug("Parse tags finished, num of tags:%d", smlData->tagNum);
|
tscDebug("SML:0x%"PRIx64" Parse tags finished, num of tags:%d", info->id, smlData->tagNum);
|
||||||
|
|
||||||
//Parse fields
|
//Parse fields
|
||||||
ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &index, true, smlData, keyHashTable);
|
ret = parseSmlKvPairs(&smlData->fields, &smlData->fieldNum, &index, true, smlData, keyHashTable, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse field");
|
tscError("SML:0x%"PRIx64" Unable to parse field", info->id);
|
||||||
taosHashCleanup(keyHashTable);
|
taosHashCleanup(keyHashTable);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
tscDebug("Parse fields finished, num of fields:%d", smlData->fieldNum);
|
tscDebug("SML:0x%"PRIx64" Parse fields finished, num of fields:%d", info->id, smlData->fieldNum);
|
||||||
taosHashCleanup(keyHashTable);
|
taosHashCleanup(keyHashTable);
|
||||||
|
|
||||||
//Parse timestamp
|
//Parse timestamp
|
||||||
ret = parseSmlTimeStamp(×tamp, &index);
|
ret = parseSmlTimeStamp(×tamp, &index, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("Unable to parse timestamp");
|
tscError("SML:0x%"PRIx64" Unable to parse timestamp", info->id);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
moveTimeStampToFirstKv(&smlData, timestamp);
|
moveTimeStampToFirstKv(&smlData, timestamp);
|
||||||
tscDebug("Parse timestamp finished");
|
tscDebug("SML:0x%"PRIx64" Parse timestamp finished", info->id);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2104,7 +2106,7 @@ void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) {
|
||||||
int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines, SSmlLinesInfo* info) {
|
int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines, SSmlLinesInfo* info) {
|
||||||
for (int32_t i = 0; i < numLines; ++i) {
|
for (int32_t i = 0; i < numLines; ++i) {
|
||||||
TAOS_SML_DATA_POINT point = {0};
|
TAOS_SML_DATA_POINT point = {0};
|
||||||
int32_t code = tscParseLine(lines[i], &point);
|
int32_t code = tscParseLine(lines[i], &point, info);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscError("SML:0x%"PRIx64" data point line parse failed. line %d : %s", info->id, i, lines[i]);
|
tscError("SML:0x%"PRIx64" data point line parse failed. line %d : %s", info->id, i, lines[i]);
|
||||||
destroySmlDataPoint(&point);
|
destroySmlDataPoint(&point);
|
||||||
|
|
Loading…
Reference in New Issue