Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b5a9cbf7
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看板
提交
b5a9cbf7
编写于
2月 08, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feat/vnode_compact
上级
0f70a612
b3bf43e2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
144 addition
and
122 deletion
+144
-122
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+4
-3
source/client/src/clientSml.c
source/client/src/clientSml.c
+60
-63
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+33
-21
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+22
-20
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+25
-15
未找到文件。
source/client/inc/clientSml.h
浏览文件 @
b5a9cbf7
...
...
@@ -99,6 +99,7 @@ typedef struct {
char
*
tags
;
char
*
cols
;
char
*
timestamp
;
char
*
measureTag
;
int32_t
measureLen
;
int32_t
measureTagsLen
;
...
...
@@ -114,7 +115,7 @@ typedef struct {
int32_t
sTableNameLen
;
char
childTableName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
void
*
key
;
// for openTsdb
//
void *key; // for openTsdb
SArray
*
tags
;
...
...
@@ -166,8 +167,8 @@ typedef struct {
int32_t
ttl
;
int32_t
uid
;
// used for automatic create child table
NodeList
*
childTables
;
NodeList
*
superTables
;
SHashObj
*
childTables
;
SHashObj
*
superTables
;
SHashObj
*
pVgHash
;
STscObj
*
taos
;
...
...
source/client/src/clientSml.c
浏览文件 @
b5a9cbf7
...
...
@@ -759,13 +759,13 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
conn
.
requestObjRefId
=
info
->
pRequest
->
self
;
conn
.
mgmtEps
=
getEpSet_s
(
&
info
->
taos
->
pAppInfo
->
mgmtEp
);
NodeList
*
tmp
=
info
->
superTables
;
SSmlSTableMeta
**
tmp
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
)
;
while
(
tmp
)
{
SSmlSTableMeta
*
sTableData
=
(
SSmlSTableMeta
*
)
tmp
->
data
.
value
;
SSmlSTableMeta
*
sTableData
=
*
tmp
;
bool
needCheckMeta
=
false
;
// for multi thread
size_t
superTableLen
=
(
size_t
)
tmp
->
data
.
keyLen
;
const
void
*
superTable
=
tmp
->
data
.
key
;
size_t
superTableLen
=
0
;
void
*
superTable
=
taosHashGetKey
(
tmp
,
&
superTableLen
)
;
memset
(
pName
.
tname
,
0
,
TSDB_TABLE_NAME_LEN
);
memcpy
(
pName
.
tname
,
superTable
,
superTableLen
);
...
...
@@ -914,7 +914,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
sTableData
->
tableMeta
=
pTableMeta
;
tmp
=
tmp
->
next
;
tmp
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
tmp
)
;
}
return
0
;
...
...
@@ -1017,11 +1017,11 @@ void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
taosHashCleanup
(
kvHash
);
}
if
(
info
->
parseJsonByLib
)
{
SSmlLineInfo
*
key
=
(
SSmlLineInfo
*
)(
tag
->
key
);
if
(
key
!=
NULL
)
taosMemoryFree
(
key
->
tags
);
}
taosMemoryFree
(
tag
->
key
);
//
if (info->parseJsonByLib) {
//
SSmlLineInfo *key = (SSmlLineInfo *)(tag->key);
//
if (key != NULL) taosMemoryFree(key->tags);
//
}
//
taosMemoryFree(tag->key);
taosArrayDestroy
(
tag
->
cols
);
taosArrayDestroy
(
tag
->
tags
);
taosMemoryFree
(
tag
);
...
...
@@ -1042,29 +1042,23 @@ void smlDestroyInfo(SSmlHandle *info) {
qDestroyQuery
(
info
->
pQuery
);
// destroy info->childTables
NodeList
*
tmp
=
info
->
childTables
;
while
(
tmp
)
{
if
(
tmp
->
data
.
used
)
{
smlDestroyTableInfo
(
info
,
(
SSmlTableInfo
*
)
tmp
->
data
.
value
);
}
NodeList
*
t
=
tmp
->
next
;
taosMemoryFree
(
tmp
);
tmp
=
t
;
SSmlTableInfo
**
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
NULL
);
while
(
oneTable
)
{
smlDestroyTableInfo
(
info
,
*
oneTable
);
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
);
}
// destroy info->superTables
tmp
=
info
->
superTables
;
while
(
tmp
)
{
if
(
tmp
->
data
.
used
)
{
smlDestroySTableMeta
((
SSmlSTableMeta
*
)
tmp
->
data
.
value
);
}
NodeList
*
t
=
tmp
->
next
;
taosMemoryFree
(
tmp
);
tmp
=
t
;
SSmlSTableMeta
**
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
while
(
oneSTable
)
{
smlDestroySTableMeta
(
*
oneSTable
);
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
oneSTable
);
}
// destroy info->pVgHash
taosHashCleanup
(
info
->
pVgHash
);
taosHashCleanup
(
info
->
childTables
);
taosHashCleanup
(
info
->
superTables
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
info
->
tagJsonArray
);
i
++
)
{
cJSON
*
tags
=
(
cJSON
*
)
taosArrayGetP
(
info
->
tagJsonArray
,
i
);
...
...
@@ -1088,6 +1082,8 @@ void smlDestroyInfo(SSmlHandle *info) {
if
(
info
->
parseJsonByLib
)
{
taosMemoryFree
(
info
->
lines
[
i
].
tags
);
}
if
(
info
->
lines
[
i
].
measureTagsLen
!=
0
)
taosMemoryFree
(
info
->
lines
[
i
].
measureTag
);
}
taosMemoryFree
(
info
->
lines
);
}
...
...
@@ -1112,6 +1108,9 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
}
info
->
pVgHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
info
->
childTables
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
info
->
superTables
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
info
->
id
=
smlGenId
();
info
->
pQuery
=
smlInitHandle
();
info
->
dataFormat
=
true
;
...
...
@@ -1122,7 +1121,7 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
info
->
maxTagKVs
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
info
->
preLineColKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
if
(
NULL
==
info
->
pVgHash
)
{
if
(
NULL
==
info
->
pVgHash
||
NULL
==
info
->
childTables
||
NULL
==
info
->
superTables
)
{
uError
(
"create SSmlHandle failed"
);
goto
cleanup
;
}
...
...
@@ -1156,11 +1155,11 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
SSmlLineInfo
*
elements
=
info
->
lines
+
i
;
SSmlTableInfo
*
tinfo
=
NULL
;
if
(
info
->
protocol
==
TSDB_SML_LINE_PROTOCOL
)
{
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
->
measure
,
elements
->
measureTagsLen
,
NULL
);
tinfo
=
*
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
elements
->
measure
,
elements
->
measureTagsLen
);
}
else
if
(
info
->
protocol
==
TSDB_SML_TELNET_PROTOCOL
)
{
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
tinfo
=
*
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
);
}
else
{
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
tinfo
=
*
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
);
}
if
(
tinfo
==
NULL
)
{
...
...
@@ -1184,12 +1183,12 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
return
ret
;
}
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
SSmlSTableMeta
*
*
tableMeta
=
(
SSmlSTableMeta
*
*
)
taosHashGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
);
if
(
tableMeta
)
{
// update meta
ret
=
smlUpdateMeta
(
tableMeta
->
colHash
,
tableMeta
->
cols
,
elements
->
colArray
,
false
,
&
info
->
msgBuf
);
ret
=
smlUpdateMeta
(
(
*
tableMeta
)
->
colHash
,
(
*
tableMeta
)
->
cols
,
elements
->
colArray
,
false
,
&
info
->
msgBuf
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
ret
=
smlUpdateMeta
(
tableMeta
->
tagHash
,
tableMeta
->
tags
,
tinfo
->
tags
,
true
,
&
info
->
msgBuf
);
ret
=
smlUpdateMeta
(
(
*
tableMeta
)
->
tagHash
,
(
*
tableMeta
)
->
tags
,
tinfo
->
tags
,
true
,
&
info
->
msgBuf
);
}
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlUpdateMeta failed"
,
info
->
id
);
...
...
@@ -1205,7 +1204,7 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
SSmlSTableMeta
*
meta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
smlInsertMeta
(
meta
->
tagHash
,
meta
->
tags
,
tinfo
->
tags
);
smlInsertMeta
(
meta
->
colHash
,
meta
->
cols
,
elements
->
colArray
);
nodeListSet
(
&
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
meta
,
NULL
);
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
meta
,
POINTER_BYTES
);
}
}
...
...
@@ -1215,9 +1214,9 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
static
int32_t
smlInsertData
(
SSmlHandle
*
info
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
NodeList
*
tmp
=
info
->
childTables
;
while
(
tmp
)
{
SSmlTableInfo
*
tableData
=
(
SSmlTableInfo
*
)
tmp
->
data
.
valu
e
;
SSmlTableInfo
**
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
NULL
)
;
while
(
oneTable
)
{
SSmlTableInfo
*
tableData
=
*
oneTabl
e
;
SName
pName
=
{
TSDB_TABLE_NAME_T
,
info
->
taos
->
acctId
,
{
0
},
{
0
}};
tstrncpy
(
pName
.
dbname
,
info
->
pRequest
->
pDb
,
sizeof
(
pName
.
dbname
));
...
...
@@ -1237,25 +1236,25 @@ static int32_t smlInsertData(SSmlHandle *info) {
}
taosHashPut
(
info
->
pVgHash
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
));
SSmlSTableMeta
*
pMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
tableData
->
sTableName
,
tableData
->
sTableNameLen
,
NULL
);
if
(
unlikely
(
NULL
==
pMeta
||
NULL
==
pMeta
->
tableMeta
))
{
SSmlSTableMeta
*
*
pMeta
=
(
SSmlSTableMeta
*
*
)
taosHashGet
(
info
->
superTables
,
tableData
->
sTableName
,
tableData
->
sTableNameLen
);
if
(
unlikely
(
NULL
==
pMeta
||
NULL
==
(
*
pMeta
)
->
tableMeta
))
{
uError
(
"SML:0x%"
PRIx64
" NULL == pMeta. table name: %s"
,
info
->
id
,
tableData
->
childTableName
);
return
TSDB_CODE_SML_INTERNAL_ERROR
;
}
// use tablemeta of stable to save vgid and uid of child table
pMeta
->
tableMeta
->
vgId
=
vg
.
vgId
;
pMeta
->
tableMeta
->
uid
=
tableData
->
uid
;
// one table merge data block together according uid
(
*
pMeta
)
->
tableMeta
->
vgId
=
vg
.
vgId
;
(
*
pMeta
)
->
tableMeta
->
uid
=
tableData
->
uid
;
// one table merge data block together according uid
code
=
smlBindData
(
info
->
pQuery
,
info
->
dataFormat
,
tableData
->
tags
,
pMeta
->
cols
,
tableData
->
cols
,
pMeta
->
tableMeta
,
code
=
smlBindData
(
info
->
pQuery
,
info
->
dataFormat
,
tableData
->
tags
,
(
*
pMeta
)
->
cols
,
tableData
->
cols
,
(
*
pMeta
)
->
tableMeta
,
tableData
->
childTableName
,
tableData
->
sTableName
,
tableData
->
sTableNameLen
,
info
->
ttl
,
info
->
msgBuf
.
buf
,
info
->
msgBuf
.
len
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlBindData failed"
,
info
->
id
);
return
code
;
}
tmp
=
tmp
->
next
;
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
)
;
}
code
=
smlBuildOutput
(
info
->
pQuery
,
info
->
pVgHash
);
...
...
@@ -1288,25 +1287,22 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
int32_t
smlClearForRerun
(
SSmlHandle
*
info
)
{
info
->
reRun
=
false
;
// clear info->childTables
NodeList
*
pList
=
info
->
childTables
;
while
(
pList
)
{
if
(
pList
->
data
.
used
)
{
smlDestroyTableInfo
(
info
,
(
SSmlTableInfo
*
)
pList
->
data
.
value
);
pList
->
data
.
used
=
false
;
}
pList
=
pList
->
next
;
SSmlTableInfo
**
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
NULL
);
while
(
oneTable
)
{
smlDestroyTableInfo
(
info
,
*
oneTable
);
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
);
}
// clear info->superTables
pList
=
info
->
superTables
;
while
(
pList
)
{
if
(
pList
->
data
.
used
)
{
smlDestroySTableMeta
((
SSmlSTableMeta
*
)
pList
->
data
.
value
);
pList
->
data
.
used
=
false
;
}
pList
=
pList
->
next
;
SSmlSTableMeta
**
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
while
(
oneSTable
)
{
smlDestroySTableMeta
(
*
oneSTable
);
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
oneSTable
);
}
taosHashClear
(
info
->
childTables
);
taosHashClear
(
info
->
superTables
);
if
(
!
info
->
dataFormat
)
{
if
(
unlikely
(
info
->
lines
!=
NULL
))
{
uError
(
"SML:0x%"
PRIx64
" info->lines != NULL"
,
info
->
id
);
...
...
@@ -1375,6 +1371,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
if
(
info
->
dataFormat
)
{
SSmlLineInfo
element
=
{
0
};
code
=
smlParseTelnetString
(
info
,
(
char
*
)
tmp
,
(
char
*
)
tmp
+
len
,
&
element
);
if
(
element
.
measureTagsLen
!=
0
)
taosMemoryFree
(
element
.
measureTag
);
}
else
{
code
=
smlParseTelnetString
(
info
,
(
char
*
)
tmp
,
(
char
*
)
tmp
+
len
,
info
->
lines
+
i
);
}
...
...
@@ -1418,15 +1415,15 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
}
info
->
cost
.
lineNum
=
info
->
lineNum
;
info
->
cost
.
numOfSTables
=
nodeLis
tSize
(
info
->
superTables
);
info
->
cost
.
numOfCTables
=
nodeLis
tSize
(
info
->
childTables
);
info
->
cost
.
numOfSTables
=
taosHashGe
tSize
(
info
->
superTables
);
info
->
cost
.
numOfCTables
=
taosHashGe
tSize
(
info
->
childTables
);
info
->
cost
.
schemaTime
=
taosGetTimestampUs
();
do
{
code
=
smlModifyDBSchemas
(
info
);
if
(
code
==
0
)
break
;
}
while
(
retryNum
++
<
nodeLis
tSize
(
info
->
superTables
)
*
MAX_RETRY_TIMES
);
}
while
(
retryNum
++
<
taosHashGe
tSize
(
info
->
superTables
)
*
MAX_RETRY_TIMES
);
if
(
code
!=
0
)
{
uError
(
"SML:0x%"
PRIx64
" smlModifyDBSchemas error : %s"
,
info
->
id
,
tstrerror
(
code
));
...
...
@@ -1504,7 +1501,7 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
request
->
code
=
code
;
info
->
cost
.
endTime
=
taosGetTimestampUs
();
info
->
cost
.
code
=
code
;
//
smlPrintStatisticInfo(info);
smlPrintStatisticInfo
(
info
);
end:
smlDestroyInfo
(
info
);
...
...
source/client/src/clientSmlJson.c
浏览文件 @
b5a9cbf7
...
...
@@ -694,9 +694,9 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
if
(
unlikely
(
!
isSameMeasure
)){
SSmlSTableMeta
*
sMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
if
(
unlikely
(
sMeta
==
NULL
)){
SSmlSTableMeta
*
*
tmp
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
);
SSmlSTableMeta
*
sMeta
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
)){
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
elements
->
measure
,
elements
->
measureLen
);
if
(
pTableMeta
==
NULL
){
info
->
dataFormat
=
false
;
...
...
@@ -705,10 +705,11 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
sMeta
->
tableMeta
=
pTableMeta
;
nodeListSet
(
&
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
sMeta
,
NULL
);
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
tmp
=
&
sMeta
;
}
info
->
currSTableMeta
=
sMeta
->
tableMeta
;
superKV
=
sMeta
->
tags
;
info
->
currSTableMeta
=
(
*
tmp
)
->
tableMeta
;
superKV
=
(
*
tmp
)
->
tags
;
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
...
...
@@ -761,13 +762,13 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
maxKVs
,
cnt
);
if
(
unlikely
(
kv
.
length
>
maxKV
->
length
)){
maxKV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
SSmlSTableMeta
*
*
tableMeta
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
);
if
(
unlikely
(
NULL
==
tableMeta
)){
uError
(
"SML:0x%"
PRIx64
" NULL == tableMeta"
,
info
->
id
);
return
TSDB_CODE_SML_INTERNAL_ERROR
;
}
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
tableMeta
->
tags
,
cnt
);
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
(
*
tableMeta
)
->
tags
,
cnt
);
oldKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
...
...
@@ -808,8 +809,14 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
cnt
++
;
}
SSmlTableInfo
*
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
if
(
unlikely
(
tinfo
==
NULL
))
{
elements
->
measureTag
=
(
char
*
)
taosMemoryMalloc
(
elements
->
measureLen
+
elements
->
tagsLen
);
memcpy
(
elements
->
measureTag
,
elements
->
measure
,
elements
->
measureLen
);
memcpy
(
elements
->
measureTag
+
elements
->
measureLen
,
elements
->
tags
,
elements
->
tagsLen
);
elements
->
measureTagsLen
=
elements
->
measureLen
+
elements
->
tagsLen
;
SSmlTableInfo
**
tmp
=
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
);
SSmlTableInfo
*
tinfo
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
))
{
tinfo
=
smlBuildTableInfo
(
1
,
elements
->
measure
,
elements
->
measureLen
);
if
(
unlikely
(
!
tinfo
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -828,17 +835,18 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
}
}
SSmlLineInfo
*
key
=
(
SSmlLineInfo
*
)
taosMemoryMalloc
(
sizeof
(
SSmlLineInfo
));
*
key
=
*
elements
;
if
(
info
->
parseJsonByLib
){
key
->
tags
=
taosMemoryMalloc
(
elements
->
tagsLen
+
1
);
memcpy
(
key
->
tags
,
elements
->
tags
,
elements
->
tagsLen
);
key
->
tags
[
elements
->
tagsLen
]
=
0
;
}
tinfo
->
key
=
key
;
nodeListSet
(
&
info
->
childTables
,
key
,
POINTER_BYTES
,
tinfo
,
is_same_child_table_telnet
);
// SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
// *key = *elements;
// if(info->parseJsonByLib){
// key->tags = taosMemoryMalloc(elements->tagsLen + 1);
// memcpy(key->tags, elements->tags, elements->tagsLen);
// key->tags[elements->tagsLen] = 0;
// }
// tinfo->key = key;
taosHashPut
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
,
&
tinfo
,
POINTER_BYTES
);
tmp
=
&
tinfo
;
}
if
(
info
->
dataFormat
)
info
->
currTableDataCtx
=
tinfo
->
tableDataCtx
;
if
(
info
->
dataFormat
)
info
->
currTableDataCtx
=
(
*
tmp
)
->
tableDataCtx
;
return
ret
;
}
...
...
@@ -1011,6 +1019,8 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
elements
->
tags
=
NULL
;
return
ret
;
}
}
else
{
elements
->
measureTag
=
info
->
preLine
.
measureTag
;
}
if
(
needFree
){
...
...
@@ -1189,6 +1199,8 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
uError
(
"OTD:0x%"
PRIx64
" Unable to parse tags from JSON payload"
,
info
->
id
);
return
ret
;
}
}
else
{
elements
->
measureTag
=
info
->
preLine
.
measureTag
;
}
if
(
unlikely
(
info
->
reRun
)){
...
...
@@ -1259,7 +1271,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
if
(
info
->
dataFormat
)
{
SSmlLineInfo
element
=
{
0
};
ret
=
smlParseJSONString
(
info
,
&
dataPointStart
,
&
element
);
if
(
element
.
measure
==
NULL
)
break
;
if
(
element
.
measure
TagsLen
!=
0
)
taosMemoryFree
(
element
.
measureTag
)
;
}
else
{
if
(
cnt
>=
payloadNum
){
payloadNum
=
payloadNum
<<
1
;
...
...
source/client/src/clientSmlLine.c
浏览文件 @
b5a9cbf7
...
...
@@ -148,9 +148,9 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
if
(
unlikely
(
!
isSameMeasure
)){
SSmlSTableMeta
*
sMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
if
(
unlikely
(
sMeta
==
NULL
)){
SSmlSTableMeta
*
*
tmp
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
);
SSmlSTableMeta
*
sMeta
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
)){
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
currElement
->
measure
,
currElement
->
measureLen
);
if
(
pTableMeta
==
NULL
){
info
->
dataFormat
=
false
;
...
...
@@ -159,10 +159,11 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
sMeta
->
tableMeta
=
pTableMeta
;
nodeListSet
(
&
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
sMeta
,
NULL
);
taosHashPut
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
tmp
=
&
sMeta
;
}
info
->
currSTableMeta
=
sMeta
->
tableMeta
;
superKV
=
sMeta
->
tags
;
info
->
currSTableMeta
=
(
*
tmp
)
->
tableMeta
;
superKV
=
(
*
tmp
)
->
tags
;
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
...
...
@@ -258,13 +259,13 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
maxKVs
,
cnt
);
if
(
unlikely
(
kv
.
length
>
maxKV
->
length
)){
maxKV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
SSmlSTableMeta
*
*
tableMeta
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
);
if
(
unlikely
(
NULL
==
tableMeta
)){
uError
(
"SML:0x%"
PRIx64
" NULL == tableMeta"
,
info
->
id
);
return
TSDB_CODE_SML_INTERNAL_ERROR
;
}
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
tableMeta
->
tags
,
cnt
);
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
(
*
tableMeta
)
->
tags
,
cnt
);
oldKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
...
...
@@ -310,7 +311,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
(
*
sql
)
++
;
}
void
*
oneTable
=
nodeListGet
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
NULL
);
void
*
oneTable
=
taosHashGet
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
);
if
((
oneTable
!=
NULL
))
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -332,7 +333,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
}
nodeListSet
(
&
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
tinfo
,
NULL
);
taosHashPut
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
&
tinfo
,
POINTER_BYTES
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -345,18 +346,18 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
if
(
unlikely
(
!
isSameCTable
)){
SSmlTableInfo
*
oneTable
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
,
NULL
);
SSmlTableInfo
*
*
oneTable
=
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
currElement
->
measure
,
currElement
->
measureTagsLen
);
if
(
unlikely
(
oneTable
==
NULL
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"child table should inside"
,
currElement
->
measure
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
info
->
currTableDataCtx
=
oneTable
->
tableDataCtx
;
info
->
currTableDataCtx
=
(
*
oneTable
)
->
tableDataCtx
;
}
if
(
unlikely
(
!
isSameMeasure
)){
SSmlSTableMeta
*
sMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
if
(
unlikely
(
sMeta
==
NULL
)){
SSmlSTableMeta
*
*
tmp
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
);
SSmlSTableMeta
*
sMeta
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
)){
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
currElement
->
measure
,
currElement
->
measureLen
);
if
(
pTableMeta
==
NULL
){
info
->
dataFormat
=
false
;
...
...
@@ -365,10 +366,11 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
sMeta
->
tableMeta
=
pTableMeta
;
nodeListSet
(
&
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
sMeta
,
NULL
);
taosHashPut
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
tmp
=
&
sMeta
;
}
info
->
currSTableMeta
=
sMeta
->
tableMeta
;
superKV
=
sMeta
->
cols
;
info
->
currSTableMeta
=
(
*
tmp
)
->
tableMeta
;
superKV
=
(
*
tmp
)
->
cols
;
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
}
...
...
@@ -487,13 +489,13 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
if
(
unlikely
(
IS_VAR_DATA_TYPE
(
kv
.
type
)
&&
kv
.
length
>
maxKV
->
length
)){
maxKV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
SSmlSTableMeta
*
*
tableMeta
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
);
if
(
unlikely
(
NULL
==
tableMeta
)){
uError
(
"SML:0x%"
PRIx64
" NULL == tableMeta"
,
info
->
id
);
return
TSDB_CODE_SML_INTERNAL_ERROR
;
}
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
tableMeta
->
cols
,
cnt
);
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
(
*
tableMeta
)
->
cols
,
cnt
);
oldKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
b5a9cbf7
...
...
@@ -71,6 +71,7 @@ static void smlParseTelnetElement(char **sql, char *sqlEnd, char **data, int32_t
static
int32_t
smlParseTelnetTags
(
SSmlHandle
*
info
,
char
*
data
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
,
SSmlMsgBuf
*
msg
)
{
if
(
is_same_child_table_telnet
(
elements
,
&
info
->
preLine
)
==
0
){
elements
->
measureTag
=
info
->
preLine
.
measureTag
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -83,9 +84,9 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
if
(
!
isSameMeasure
){
SSmlSTableMeta
*
sMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
if
(
unlikely
(
sMeta
==
NULL
)){
SSmlSTableMeta
*
*
tmp
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
);
SSmlSTableMeta
*
sMeta
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
)){
STableMeta
*
pTableMeta
=
smlGetMeta
(
info
,
elements
->
measure
,
elements
->
measureLen
);
if
(
pTableMeta
==
NULL
){
info
->
dataFormat
=
false
;
...
...
@@ -94,10 +95,11 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
sMeta
->
tableMeta
=
pTableMeta
;
nodeListSet
(
&
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
sMeta
,
NULL
);
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
tmp
=
&
sMeta
;
}
info
->
currSTableMeta
=
sMeta
->
tableMeta
;
superKV
=
sMeta
->
tags
;
info
->
currSTableMeta
=
(
*
tmp
)
->
tableMeta
;
superKV
=
(
*
tmp
)
->
tags
;
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
...
...
@@ -183,13 +185,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
maxKVs
,
cnt
);
if
(
unlikely
(
kv
.
length
>
maxKV
->
length
)){
maxKV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
SSmlSTableMeta
*
*
tableMeta
=
(
SSmlSTableMeta
**
)
taosHashGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
);
if
(
unlikely
(
NULL
==
tableMeta
)){
uError
(
"SML:0x%"
PRIx64
" NULL == tableMeta"
,
info
->
id
);
return
TSDB_CODE_SML_INTERNAL_ERROR
;
}
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
tableMeta
->
tags
,
cnt
);
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
(
*
tableMeta
)
->
tags
,
cnt
);
oldKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
...
...
@@ -229,8 +231,15 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
taosArrayPush
(
preLineKV
,
&
kv
);
cnt
++
;
}
SSmlTableInfo
*
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
if
(
unlikely
(
tinfo
==
NULL
))
{
elements
->
measureTag
=
(
char
*
)
taosMemoryMalloc
(
elements
->
measureLen
+
elements
->
tagsLen
);
memcpy
(
elements
->
measureTag
,
elements
->
measure
,
elements
->
measureLen
);
memcpy
(
elements
->
measureTag
+
elements
->
measureLen
,
elements
->
tags
,
elements
->
tagsLen
);
elements
->
measureTagsLen
=
elements
->
measureLen
+
elements
->
tagsLen
;
SSmlTableInfo
**
tmp
=
(
SSmlTableInfo
**
)
taosHashGet
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
);
SSmlTableInfo
*
tinfo
=
NULL
;
if
(
unlikely
(
tmp
==
NULL
))
{
tinfo
=
smlBuildTableInfo
(
1
,
elements
->
measure
,
elements
->
measureLen
);
if
(
!
tinfo
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -249,12 +258,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
}
SSmlLineInfo
*
key
=
(
SSmlLineInfo
*
)
taosMemoryMalloc
(
sizeof
(
SSmlLineInfo
));
*
key
=
*
elements
;
tinfo
->
key
=
key
;
nodeListSet
(
&
info
->
childTables
,
key
,
POINTER_BYTES
,
tinfo
,
is_same_child_table_telnet
);
// SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
// *key = *elements;
// tinfo->key = key;
taosHashPut
(
info
->
childTables
,
elements
->
measureTag
,
elements
->
measureLen
+
elements
->
tagsLen
,
&
tinfo
,
POINTER_BYTES
);
tmp
=
&
tinfo
;
}
if
(
info
->
dataFormat
)
info
->
currTableDataCtx
=
tinfo
->
tableDataCtx
;
if
(
info
->
dataFormat
)
info
->
currTableDataCtx
=
(
*
tmp
)
->
tableDataCtx
;
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录