Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
443aa2ee
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看板
提交
443aa2ee
编写于
12月 07, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:modify influxdb parse logic for sml
上级
2c4b6ece
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
77 addition
and
52 deletion
+77
-52
source/client/src/clientSml.c
source/client/src/clientSml.c
+63
-31
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+3
-13
source/common/src/tname.c
source/common/src/tname.c
+3
-3
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+1
-1
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+5
-2
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+2
-2
未找到文件。
source/client/src/clientSml.c
浏览文件 @
443aa2ee
...
...
@@ -1056,21 +1056,15 @@ static SSmlSTableMeta *smlBuildSTableMeta(bool isDataFormat) {
static
void
smlInsertMeta
(
SHashObj
*
metaHash
,
SArray
*
metaArray
,
SArray
*
cols
){
for
(
int16_t
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
i
);
taosArrayPush
(
metaArray
,
&
kv
);
taosArrayPush
(
metaArray
,
kv
);
if
(
unlikely
(
metaHash
!=
NULL
))
{
taosHashPut
(
metaHash
,
kv
->
key
,
kv
->
keyLen
,
&
i
,
SHORT_BYTES
);
}
}
}
bool
smlFormatJudge
(
SHashObj
*
superTableKeyStr
,
void
*
*
preLineKeys
,
void
*
currentLineKeys
,
bool
smlFormatJudge
(
SHashObj
*
superTableKeyStr
,
void
*
preLineKeys
,
void
*
currentLineKeys
,
SSmlLineInfo
*
currElements
,
SSmlLineInfo
*
preElements
,
int32_t
len
){
if
(
*
preLineKeys
==
NULL
){
*
preLineKeys
=
taosMemoryMalloc
(
len
);
varDataCopy
(
*
preLineKeys
,
currentLineKeys
);
return
true
;
}
// same measure
if
(
preElements
->
measureLen
==
currElements
->
measureLen
&&
memcmp
(
preElements
->
measure
,
currElements
->
measure
,
currElements
->
measureLen
)
==
0
){
...
...
@@ -1091,6 +1085,7 @@ bool smlFormatJudge(SHashObj* superTableKeyStr, void** preLineKeys, void* curren
}
}
}
varDataCopy
(
preLineKeys
,
currentLineKeys
);
return
true
;
}
...
...
@@ -1166,7 +1161,7 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
bool
isSameCTable
=
false
;
int
cnt
=
0
;
void
*
keyStr
=
NULL
;
bool
isPreLineKVNULL
=
false
;
//
bool isPreLineKVNULL = false;
SArray
*
preLineKV
=
NULL
;
bool
isSuperKVInit
=
false
;
SArray
*
superKV
=
NULL
;
...
...
@@ -1223,22 +1218,29 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
if
(
unlikely
(
info
->
currentLineTagKeys
==
NULL
)){
// sml todo size need remalloc
info
->
currentLineTagKeys
=
taosMemoryMalloc
(
sqlEnd
-
*
sql
);
}
keyStr
=
info
->
preLineTagKeys
;
if
(
info
->
preLineTagKeys
==
NULL
){
info
->
preLineTagKeys
=
taosMemoryMalloc
(
sqlEnd
-
*
sql
);
}
keyStr
=
info
->
currentLineTagKeys
;
if
(
info
->
preLineTagKV
==
NULL
){
info
->
preLineTagKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
isPreLineKVNULL
=
true
;
//
isPreLineKVNULL = true;
}
preLineKV
=
info
->
preLineTagKV
;
}
else
{
if
(
unlikely
(
info
->
currentLineColKeys
==
NULL
)){
// sml todo size need remalloc
info
->
currentLineColKeys
=
taosMemoryMalloc
(
sqlEnd
-
*
sql
);
}
keyStr
=
info
->
preLineColKeys
;
if
(
info
->
preLineColKeys
==
NULL
){
info
->
preLineColKeys
=
taosMemoryMalloc
(
sqlEnd
-
*
sql
);
}
keyStr
=
info
->
currentLineColKeys
;
if
(
info
->
preLineColKV
==
NULL
){
info
->
preLineColKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
isPreLineKVNULL
=
true
;
//
isPreLineKVNULL = true;
}
preLineKV
=
info
->
preLineColKV
;
}
...
...
@@ -1247,6 +1249,8 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
taosArraySetSize
(
preLineKV
,
0
);
}
varDataLen
(
keyStr
)
=
0
;
// clear keys
}
else
{
preLineKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
}
while
(
*
sql
<
sqlEnd
)
{
...
...
@@ -1276,8 +1280,10 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
memcpy
(
keyStr
+
varDataTLen
(
keyStr
),
key
,
keyLen
+
1
);
// use = symbol
varDataLen
(
keyStr
)
+=
keyLen
+
1
;
if
(
info
->
dataFormat
){
memcpy
(
keyStr
+
varDataTLen
(
keyStr
),
key
,
keyLen
+
1
);
// use = symbol
varDataLen
(
keyStr
)
+=
keyLen
+
1
;
}
// parse value
const
char
*
value
=
*
sql
;
...
...
@@ -1290,6 +1296,9 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
(
*
sql
)
++
;
continue
;
}
if
(
!
isInQuote
&&
IS_SPACE
(
*
sql
))
{
break
;
}
if
(
!
isInQuote
&&
IS_COMMA
(
*
sql
))
{
break
;
}
...
...
@@ -1312,8 +1321,6 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
PROCESS_SLASH
(
key
,
keyLen
)
PROCESS_SLASH
(
value
,
valueLen
)
(
*
sql
)
++
;
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
value
=
value
,
.
length
=
valueLen
};
if
(
!
isTag
)
{
int32_t
ret
=
smlParseValue
(
&
kv
,
&
info
->
msgBuf
);
...
...
@@ -1337,18 +1344,15 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
return
TSDB_CODE_PAR_TOO_MANY_COLUMNS
;
}
// bind data
int
ret
=
smlBuildCol
(
info
->
currTableDataCtx
,
info
->
currSTableMeta
->
schema
,
&
kv
,
cnt
+
1
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlBuildCol error"
,
NULL
);
return
ret
;
if
(
!
isTag
){
int
ret
=
smlBuildCol
(
info
->
currTableDataCtx
,
info
->
currSTableMeta
->
schema
,
&
kv
,
cnt
+
1
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlBuildCol error"
,
NULL
);
return
ret
;
}
}
do
{
if
(
isPreLineKVNULL
){
taosArrayPush
(
preLineKV
,
&
kv
);
break
;
}
if
(
isSameMeasure
){
if
(
cnt
>=
taosArrayGetSize
(
preLineKV
))
{
info
->
dataFormat
=
false
;
...
...
@@ -1404,9 +1408,10 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
}
taosArrayPush
(
preLineKV
,
&
kv
);
}
cnt
++
;
break
;
}
while
(
0
);
}
else
{
taosArrayPush
(
preLineKV
,
&
kv
);
}
if
(
!
info
->
dataFormat
&&
!
isTag
){
...
...
@@ -1416,16 +1421,21 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
}
taosArrayPush
(
currElement
->
colArray
,
&
kv
);
//reserve for timestamp
}
cnt
++
;
if
(
IS_SPACE
(
*
sql
)){
break
;
}
(
*
sql
)
++
;
}
if
(
isTag
&&
taosArrayGetSize
(
preLineKV
)
>
TSDB_MAX_TAGS
){
if
(
isTag
&&
cnt
>
TSDB_MAX_TAGS
){
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"too many tags than 128"
,
NULL
);
return
TSDB_CODE_PAR_INVALID_TAGS_NUM
;
}
if
(
info
->
dataFormat
){
if
(
isTag
){
info
->
dataFormat
=
smlFormatJudge
(
info
->
superTableTagKeyStr
,
&
info
->
preLineTagKeys
,
info
->
dataFormat
=
smlFormatJudge
(
info
->
superTableTagKeyStr
,
info
->
preLineTagKeys
,
info
->
currentLineTagKeys
,
currElement
,
&
info
->
preLine
,
sqlEnd
-
currElement
->
tags
);
if
(
!
info
->
dataFormat
)
{
info
->
reRun
=
true
;
...
...
@@ -1449,11 +1459,15 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
smlSetCTableName
(
tinfo
);
info
->
currSTableMeta
->
uid
=
tinfo
->
uid
;
tinfo
->
tableDataCtx
=
smlInitTableDataCtx
(
info
->
pQuery
,
info
->
currSTableMeta
);
if
(
tinfo
->
tableDataCtx
==
NULL
){
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlInitTableDataCtx error"
,
NULL
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
taosHashPut
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
&
tinfo
,
POINTER_BYTES
);
}
}
}
else
{
info
->
dataFormat
=
smlFormatJudge
(
info
->
superTableColKeyStr
,
&
info
->
preLineColKeys
,
info
->
dataFormat
=
smlFormatJudge
(
info
->
superTableColKeyStr
,
info
->
preLineColKeys
,
info
->
currentLineColKeys
,
currElement
,
&
info
->
preLine
,
sqlEnd
-
currElement
->
cols
);
if
(
!
info
->
dataFormat
)
{
info
->
reRun
=
true
;
...
...
@@ -1473,6 +1487,7 @@ static int32_t smlParseKv(SSmlHandle *info, const char **sql, const char *sqlEnd
smlSetCTableName
(
tinfo
);
taosHashPut
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
&
tinfo
,
POINTER_BYTES
);
}
taosArrayDestroy
(
preLineKV
);
// smltodo
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1815,8 +1830,20 @@ static void smlDestroyInfo(SSmlHandle *info) {
taosHashCleanup
(
info
->
pVgHash
);
destroyRequest
(
info
->
pRequest
);
p1
=
(
void
**
)
taosHashIterate
(
info
->
superTableTagKeyStr
,
NULL
);
while
(
p1
)
{
taosMemoryFree
(
*
p1
);
p1
=
(
void
**
)
taosHashIterate
(
info
->
superTableTagKeyStr
,
p1
);
}
taosHashCleanup
(
info
->
superTableTagKeyStr
);
p1
=
(
void
**
)
taosHashIterate
(
info
->
superTableColKeyStr
,
NULL
);
while
(
p1
)
{
taosMemoryFree
(
*
p1
);
p1
=
(
void
**
)
taosHashIterate
(
info
->
superTableColKeyStr
,
p1
);
}
taosHashCleanup
(
info
->
superTableColKeyStr
);
taosMemoryFree
(
info
->
currentLineTagKeys
);
taosMemoryFree
(
info
->
preLineTagKeys
);
taosMemoryFree
(
info
->
currentLineColKeys
);
...
...
@@ -1863,6 +1890,7 @@ static SSmlHandle *smlBuildSmlInfo(STscObj *pTscObj, SRequestObj *request, SMLPr
}
info
->
lines
=
taosArrayInit
(
perBatch
,
sizeof
(
SSmlLineInfo
));
taosArraySetSize
(
info
->
lines
,
perBatch
);
info
->
superTableTagKeyStr
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
info
->
superTableColKeyStr
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
...
...
@@ -2612,7 +2640,8 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
return
code
;
}
for
(
int32_t
i
=
0
;
i
<
numLines
;
++
i
)
{
int32_t
i
=
0
;
while
(
i
<
numLines
)
{
char
*
tmp
=
NULL
;
int
len
=
0
;
if
(
lines
)
{
...
...
@@ -2627,6 +2656,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
len
++
;
}
if
(
info
->
protocol
==
TSDB_SML_LINE_PROTOCOL
&&
tmp
[
0
]
==
'#'
)
{
// this line is comment
i
++
;
continue
;
}
}
...
...
@@ -2662,7 +2692,9 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
p1
=
(
void
**
)
taosHashIterate
(
info
->
superTables
,
p1
);
}
taosHashClear
(
info
->
superTables
);
continue
;
}
i
++
;
}
return
code
;
...
...
source/common/src/tdatablock.c
浏览文件 @
443aa2ee
...
...
@@ -2387,24 +2387,15 @@ char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) {
return
NULL
;
}
SSmlKv
*
pTag
=
taosMemoryCalloc
(
1
,
sizeof
(
SSmlKv
));
if
(
pTag
==
NULL
)
{
taosArrayDestroy
(
tags
);
return
NULL
;
}
void
*
cname
=
taosMemoryCalloc
(
1
,
TSDB_TABLE_NAME_LEN
+
1
);
if
(
cname
==
NULL
)
{
taosArrayDestroy
(
tags
);
taosMemoryFree
(
pTag
);
return
NULL
;
}
pTag
->
key
=
"group_id"
;
pTag
->
keyLen
=
strlen
(
pTag
->
key
);
pTag
->
type
=
TSDB_DATA_TYPE_UBIGINT
;
pTag
->
u
=
groupId
;
pTag
->
length
=
sizeof
(
uint64_t
);
SSmlKv
pTag
=
{.
key
=
"group_id"
,
.
keyLen
=
sizeof
(
"group_id"
)
-
1
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
,
.
u
=
groupId
,
.
length
=
sizeof
(
uint64_t
)};
taosArrayPush
(
tags
,
&
pTag
);
RandTableName
rname
=
{
...
...
@@ -2416,7 +2407,6 @@ char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) {
buildChildTableName
(
&
rname
);
taosMemoryFree
(
pTag
);
taosArrayDestroy
(
tags
);
ASSERT
(
rname
.
ctbShortName
&&
rname
.
ctbShortName
[
0
]);
...
...
source/common/src/tname.c
浏览文件 @
443aa2ee
...
...
@@ -298,8 +298,8 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
}
static
int
compareKv
(
const
void
*
p1
,
const
void
*
p2
)
{
SSmlKv
*
kv1
=
*
(
SSmlKv
*
*
)
p1
;
SSmlKv
*
kv2
=
*
(
SSmlKv
*
*
)
p2
;
SSmlKv
*
kv1
=
(
SSmlKv
*
)
p1
;
SSmlKv
*
kv2
=
(
SSmlKv
*
)
p2
;
int32_t
kvLen1
=
kv1
->
keyLen
;
int32_t
kvLen2
=
kv2
->
keyLen
;
int32_t
res
=
strncasecmp
(
kv1
->
key
,
kv2
->
key
,
TMIN
(
kvLen1
,
kvLen2
));
...
...
@@ -320,7 +320,7 @@ void buildChildTableName(RandTableName* rName) {
taosArraySort
(
rName
->
tags
,
compareKv
);
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
rName
->
tags
);
++
j
)
{
taosStringBuilderAppendChar
(
&
sb
,
','
);
SSmlKv
*
tagKv
=
taosArrayGet
P
(
rName
->
tags
,
j
);
SSmlKv
*
tagKv
=
taosArrayGet
(
rName
->
tags
,
j
);
taosStringBuilderAppendStringLen
(
&
sb
,
tagKv
->
key
,
tagKv
->
keyLen
);
taosStringBuilderAppendChar
(
&
sb
,
'='
);
if
(
IS_VAR_DATA_TYPE
(
tagKv
->
type
))
{
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
443aa2ee
...
...
@@ -618,7 +618,7 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq2 *pMsg, STbUidStore *pStore) {
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSubmitTbData
*
pData
=
TARRAY_GET_ELEM
(
pSubmitTbData
,
i
);
if
(
terrno
=
tdUidStorePut
(
pStore
,
pData
->
suid
,
NULL
)
<
0
)
{
if
(
(
terrno
=
tdUidStorePut
(
pStore
,
pData
->
suid
,
NULL
)
)
<
0
)
{
return
-
1
;
}
}
...
...
source/libs/parser/src/parInsertSml.c
浏览文件 @
443aa2ee
...
...
@@ -160,8 +160,9 @@ end:
STableDataCxt
*
smlInitTableDataCtx
(
SQuery
*
query
,
STableMeta
*
pTableMeta
){
STableDataCxt
*
pTableCxt
=
NULL
;
SVCreateTbReq
*
pCreateTbReq
=
NULL
;
int
ret
=
insGetTableDataCxt
(((
SVnodeModifOpStmt
*
)(
query
->
pRoot
))
->
pTableBlockHashObj
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
pTableMeta
,
NULL
,
&
pTableCxt
,
false
);
pTableMeta
,
&
pCreateTbReq
,
&
pTableCxt
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
...
...
@@ -259,6 +260,8 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
}
(
*
pTableCxt
)
->
pData
->
flags
|=
SUBMIT_REQ_AUTO_CREATE_TABLE
;
(
*
pTableCxt
)
->
pData
->
pCreateTbReq
=
pCreateTblReq
;
(
*
pTableCxt
)
->
pMeta
->
uid
=
pTableMeta
->
uid
;
(
*
pTableCxt
)
->
pMeta
->
vgId
=
pTableMeta
->
vgId
;
pCreateTblReq
=
NULL
;
goto
end
;
}
...
...
@@ -298,7 +301,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
SSchema
*
pColSchema
=
&
pSchema
[
pTableCxt
->
boundColsInfo
.
pColIndex
[
c
]];
SColVal
*
pVal
=
taosArrayGet
(
pTableCxt
->
pValues
,
pTableCxt
->
boundColsInfo
.
pColIndex
[
c
]);
void
**
p
=
taosHashGet
(
rowData
,
pColSchema
->
name
,
strlen
(
pColSchema
->
name
));
ASSERT
(
p
=!
NULL
);
ASSERT
(
p
!=
NULL
);
SSmlKv
*
kv
=
*
(
SSmlKv
**
)
p
;
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
...
...
utils/test/c/sml_test.c
浏览文件 @
443aa2ee
...
...
@@ -1142,8 +1142,8 @@ int sml_ttl_Test() {
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
=
0
;
ret
=
sml_ttl_Test
();
ASSERT
(
!
ret
);
//
ret = sml_ttl_Test();
//
ASSERT(!ret);
ret
=
sml_ts2164_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_influx_Test
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录