提交 7630c9ae 编写于 作者: G Ganlin Zhao

support default as float

上级 351757c7
...@@ -1185,13 +1185,13 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, ...@@ -1185,13 +1185,13 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
if (len <= 0) { if (len <= 0) {
return false; return false;
} }
//integer number //integer number
if (isTinyInt(value, len)) { if (isTinyInt(value, len)) {
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)) { if (!isValidInteger(value)) {
return false;
} }
pVal->value = calloc(pVal->length, 1); pVal->value = calloc(pVal->length, 1);
int8_t val = (int8_t)strtoll(value, NULL, 10); int8_t val = (int8_t)strtoll(value, NULL, 10);
...@@ -1335,7 +1335,17 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, ...@@ -1335,7 +1335,17 @@ static bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
memcpy(pVal->value, &bVal, pVal->length); memcpy(pVal->value, &bVal, pVal->length);
return true; return true;
} }
//TODO: handle default is float here //Handle default(no appendix) as float
if (isValidInteger(value) || isValidFloat(value)) {
printf("Gavin Default as float\n");
pVal->type = TSDB_DATA_TYPE_FLOAT;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
pVal->value = calloc(pVal->length, 1);
float val = (float)strtold(value, NULL);
memcpy(pVal->value, &val, pVal->length);
printf("value:%02x %02x %02x %02x\n", pVal->value[0]&0xff,pVal->value[1]&0xff,pVal->value[2]&0xff,pVal->value[3]&0xff);
return true;
}
return false; return false;
} }
...@@ -1464,9 +1474,9 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index) { ...@@ -1464,9 +1474,9 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index) {
char key[TSDB_COL_NAME_LEN]; char key[TSDB_COL_NAME_LEN];
uint16_t len = 0; uint16_t len = 0;
//key field cannot start with '_' //key field cannot start with digit
if (*cur == '_') { if (isdigit(*cur)) {
//printf("Tag key cannnot start with \'_\'\n"); tscError("Tag key cannnot start with digit\n");
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} }
while (*cur != '\0') { while (*cur != '\0') {
...@@ -1490,7 +1500,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index) { ...@@ -1490,7 +1500,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index) {
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("Key:%s|len:%d", pKV->key, len);
*index = cur + 1; *index = cur + 1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -1539,8 +1549,8 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index ...@@ -1539,8 +1549,8 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
uint16_t len = 0; uint16_t len = 0;
pSml->stableName = calloc(TSDB_TABLE_NAME_LEN, 1); pSml->stableName = calloc(TSDB_TABLE_NAME_LEN, 1);
if (*cur == '_') { if (isdigit(*cur)) {
tscError("Measurement field cannnot start with \'_\'"); tscError("Measurement field cannnot start with digit");
free(pSml->stableName); free(pSml->stableName);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} }
...@@ -1607,7 +1617,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -1607,7 +1617,7 @@ 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"); //tscDebug("last key-value field detected");
goto done; goto done;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册