Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
153b5d71
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
153b5d71
编写于
7月 13, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pass pr build check
上级
66e8c5fd
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
36 addition
and
26 deletion
+36
-26
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+36
-26
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
153b5d71
...
...
@@ -324,7 +324,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) {
case
SCHEMA_ACTION_CREATE_STABLE
:
{
int
n
=
sprintf
(
result
,
"create stable %s ("
,
action
->
createSTable
.
sTableName
);
char
*
pos
=
result
+
n
;
int
freeBytes
=
capacity
-
n
;
in
t
numCols
=
taosArrayGetSize
(
action
->
createSTable
.
fields
);
size_
t
numCols
=
taosArrayGetSize
(
action
->
createSTable
.
fields
);
for
(
int32_t
i
=
0
;
i
<
numCols
;
++
i
)
{
SSchema
*
field
=
taosArrayGet
(
action
->
createSTable
.
fields
,
i
);
buildColumnDescription
(
field
,
pos
,
freeBytes
,
&
outBytes
);
...
...
@@ -336,7 +336,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) {
outBytes
=
snprintf
(
pos
,
freeBytes
,
") tags ("
);
pos
+=
outBytes
;
freeBytes
-=
outBytes
;
in
t
numTags
=
taosArrayGetSize
(
action
->
createSTable
.
tags
);
size_
t
numTags
=
taosArrayGetSize
(
action
->
createSTable
.
tags
);
for
(
int32_t
i
=
0
;
i
<
numTags
;
++
i
)
{
SSchema
*
field
=
taosArrayGet
(
action
->
createSTable
.
tags
,
i
);
buildColumnDescription
(
field
,
pos
,
freeBytes
,
&
outBytes
);
...
...
@@ -397,7 +397,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) {
pSql
->
signature
=
pSql
;
pSql
->
fp
=
NULL
;
SStrToken
tableToken
=
{.
z
=
tableName
,
.
n
=
strlen
(
tableName
),
.
type
=
TK_ID
};
SStrToken
tableToken
=
{.
z
=
tableName
,
.
n
=
(
uint32_t
)
strlen
(
tableName
),
.
type
=
TK_ID
};
tGetToken
(
tableName
,
&
tableToken
.
type
);
// Check if the table name available or not
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -459,7 +459,8 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) {
size_t
numStable
=
taosArrayGetSize
(
stableSchemas
);
for
(
int
i
=
0
;
i
<
numStable
;
++
i
)
{
SSmlSTableSchema
*
pointSchema
=
taosArrayGet
(
stableSchemas
,
i
);
SSmlSTableSchema
dbSchema
=
{
0
};
SSmlSTableSchema
dbSchema
;
memset
(
&
dbSchema
,
0
,
sizeof
(
SSmlSTableSchema
));
code
=
loadTableMeta
(
taos
,
pointSchema
->
sTableName
,
&
dbSchema
);
if
(
code
==
TSDB_CODE_MND_INVALID_TABLE_NAME
)
{
...
...
@@ -571,7 +572,7 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
int32_t
code
;
code
=
taos_stmt_prepare
(
stmt
,
sql
,
strlen
(
sql
));
code
=
taos_stmt_prepare
(
stmt
,
sql
,
(
unsigned
long
)
strlen
(
sql
));
if
(
code
!=
0
)
{
tscError
(
"%s"
,
taos_stmt_errstr
(
stmt
));
return
code
;
...
...
@@ -617,7 +618,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
code
=
taos_stmt_prepare
(
stmt
,
sql
,
strlen
(
sql
));
code
=
taos_stmt_prepare
(
stmt
,
sql
,
(
unsigned
long
)
strlen
(
sql
));
if
(
code
!=
0
)
{
tscError
(
"%s"
,
taos_stmt_errstr
(
stmt
));
return
code
;
...
...
@@ -717,8 +718,8 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num
SArray
*
cTablePoints
=
*
pCTablePoints
;
TAOS_SML_DATA_POINT
*
point
=
taosArrayGetP
(
cTablePoints
,
0
);
int32
_t
numTags
=
taosArrayGetSize
(
point
->
schema
->
tags
);
int32
_t
numCols
=
taosArrayGetSize
(
point
->
schema
->
fields
);
size
_t
numTags
=
taosArrayGetSize
(
point
->
schema
->
tags
);
size
_t
numCols
=
taosArrayGetSize
(
point
->
schema
->
fields
);
SArray
*
tagBinds
=
taosArrayInit
(
numTags
,
sizeof
(
TAOS_BIND
));
taosArraySetSize
(
tagBinds
,
numTags
);
...
...
@@ -728,7 +729,7 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num
}
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
tags
+
j
;
int32
_t
idx
=
TARRAY_ELEM_IDX
(
point
->
schema
->
tags
,
kv
->
schema
);
size
_t
idx
=
TARRAY_ELEM_IDX
(
point
->
schema
->
tags
,
kv
->
schema
);
TAOS_BIND
*
bind
=
taosArrayGet
(
tagBinds
,
idx
);
bind
->
buffer_type
=
kv
->
type
;
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
...
...
@@ -750,7 +751,7 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num
}
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
fields
+
j
;
int32
_t
idx
=
TARRAY_ELEM_IDX
(
point
->
schema
->
fields
,
kv
->
schema
);
size
_t
idx
=
TARRAY_ELEM_IDX
(
point
->
schema
->
fields
,
kv
->
schema
);
TAOS_BIND
*
bind
=
colBinds
+
idx
;
bind
->
buffer_type
=
kv
->
type
;
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
...
...
@@ -793,10 +794,24 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
);
reconcileDBSchemas
(
taos
,
stableSchemas
);
insertPoints
(
taos
,
points
,
numPoint
);
code
=
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
);
if
(
code
!=
0
)
{
tscError
(
"error building data point schemas : %s"
,
tstrerror
(
code
));
goto
clean_up
;
}
code
=
reconcileDBSchemas
(
taos
,
stableSchemas
);
if
(
code
!=
0
)
{
tscError
(
"error change db schema : %s"
,
tstrerror
(
code
));
goto
clean_up
;
}
code
=
insertPoints
(
taos
,
points
,
numPoint
);
if
(
code
!=
0
)
{
tscError
(
"error insert points : %s"
,
tstrerror
(
code
));
}
clean_up:
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
stableSchemas
);
++
i
)
{
SSmlSTableSchema
*
schema
=
taosArrayGet
(
stableSchemas
,
i
);
taosArrayDestroy
(
schema
->
fields
);
...
...
@@ -806,11 +821,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
return
code
;
}
//todo: table/column length check
//todo: type check
//todo: taosmbs2ucs4 check
//=========================================================================
typedef
enum
{
...
...
@@ -907,25 +917,25 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) {
item
->
length
=
(
int16_t
)
tDataTypes
[
item
->
type
].
bytes
;
item
->
value
=
malloc
(
item
->
length
);
char
*
endptr
=
NULL
;
*
(
int8_t
*
)(
item
->
value
)
=
strtoll
(
sv
,
&
endptr
,
10
);
*
(
int8_t
*
)(
item
->
value
)
=
(
int8_t
)
strtoll
(
sv
,
&
endptr
,
10
);
}
else
if
(
*
last
==
's'
)
{
item
->
type
=
TSDB_DATA_TYPE_SMALLINT
;
item
->
length
=
(
int16_t
)
tDataTypes
[
item
->
type
].
bytes
;
item
->
value
=
malloc
(
item
->
length
);
char
*
endptr
=
NULL
;
*
(
int16_t
*
)(
item
->
value
)
=
strtoll
(
sv
,
&
endptr
,
10
);
*
(
int16_t
*
)(
item
->
value
)
=
(
int16_t
)
strtoll
(
sv
,
&
endptr
,
10
);
}
else
if
(
*
last
==
'w'
)
{
item
->
type
=
TSDB_DATA_TYPE_INT
;
item
->
length
=
(
int16_t
)
tDataTypes
[
item
->
type
].
bytes
;
item
->
value
=
malloc
(
item
->
length
);
char
*
endptr
=
NULL
;
*
(
int32_t
*
)(
item
->
value
)
=
strtoll
(
sv
,
&
endptr
,
10
);
*
(
int32_t
*
)(
item
->
value
)
=
(
int32_t
)
strtoll
(
sv
,
&
endptr
,
10
);
}
else
if
(
*
last
==
'f'
)
{
item
->
type
=
TSDB_DATA_TYPE_FLOAT
;
item
->
length
=
(
int16_t
)
tDataTypes
[
item
->
type
].
bytes
;
item
->
value
=
malloc
(
item
->
length
);
char
*
endptr
=
NULL
;
*
(
float
*
)(
item
->
value
)
=
strtold
(
sv
,
&
endptr
);
*
(
float
*
)(
item
->
value
)
=
(
float
)
strtold
(
sv
,
&
endptr
);
}
else
{
item
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
item
->
length
=
(
int16_t
)
tDataTypes
[
item
->
type
].
bytes
;
...
...
@@ -1073,7 +1083,7 @@ int32_t tscParseLine(SStrToken line, SLPPoint* point) {
int32_t
tscParseLines
(
char
*
lines
[],
int
numLines
,
SArray
*
points
,
SArray
*
failedLines
)
{
for
(
int32_t
i
=
0
;
i
<
numLines
;
++
i
)
{
SStrToken
tkLine
=
{.
z
=
lines
[
i
],
.
n
=
strlen
(
lines
[
i
])
+
1
};
SStrToken
tkLine
=
{.
z
=
lines
[
i
],
.
n
=
(
uint32_t
)
strlen
(
lines
[
i
])
+
1
};
SLPPoint
point
;
tscParseLine
(
tkLine
,
&
point
);
taosArrayPush
(
points
,
&
point
);
...
...
@@ -1126,7 +1136,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) {
size_t
lpTagSize
=
taosArrayGetSize
(
lpPoint
->
tags
);
point
->
tags
=
calloc
(
lpTagSize
,
sizeof
(
TAOS_SML_KV
));
point
->
tagNum
=
lpTagSize
;
point
->
tagNum
=
(
int
)
lpTagSize
;
for
(
int
j
=
0
;
j
<
lpTagSize
;
++
j
)
{
SLPItem
*
lpTag
=
taosArrayGet
(
lpPoint
->
tags
,
j
);
TAOS_SML_KV
*
tagKv
=
point
->
tags
+
j
;
...
...
@@ -1144,7 +1154,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) {
size_t
lpFieldsSize
=
taosArrayGetSize
(
lpPoint
->
fields
);
point
->
fields
=
calloc
(
lpFieldsSize
+
1
,
sizeof
(
TAOS_SML_KV
));
point
->
fieldNum
=
lpFieldsSize
+
1
;
point
->
fieldNum
=
(
int
)(
lpFieldsSize
+
1
)
;
TAOS_SML_KV
*
tsField
=
point
->
fields
+
0
;
char
tsKey
[
256
];
...
...
@@ -1174,7 +1184,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) {
}
}
taos_sml_insert
(
taos
,
points
,
numPoints
);
taos_sml_insert
(
taos
,
points
,
(
int
)
numPoints
);
for
(
int
i
=
0
;
i
<
numPoints
;
++
i
)
{
destroySmlDataPoint
(
points
+
i
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录