Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e45b047e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e45b047e
编写于
8月 04, 2021
作者:
H
Haojun Liao
提交者:
GitHub
8月 04, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7102 from taosdata/feature/TD-5559
[TD-5559]<enhance>:[schemaless]add unique id to sml parser logs
上级
7a384aa4
385c4bd1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
51 deletion
+53
-51
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+53
-51
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
e45b047e
...
@@ -1417,7 +1417,7 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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,
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
)
{
tsc
Debug
(
"Key field cannot exceeds 65 characters"
);
tsc
Error
(
"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
...
@@ -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,
...
@@ -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,
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
(
"S
table name in measurement:%s|len:%d"
,
pSml
->
stableName
,
len
);
tscDebug
(
"S
ML: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) {
...
@@ -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,
...
@@ -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,
...
@@ -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
...
@@ -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
(
&
timestamp
,
&
index
);
ret
=
parseSmlTimeStamp
(
&
timestamp
,
&
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) {
...
@@ -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
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录