Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4fba1c7
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看板
提交
a4fba1c7
编写于
6月 10, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add async logic for schemaless
上级
1d147258
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
19 deletion
+17
-19
source/client/src/clientSml.c
source/client/src/clientSml.c
+16
-18
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+1
-1
未找到文件。
source/client/src/clientSml.c
浏览文件 @
a4fba1c7
...
...
@@ -69,6 +69,7 @@ for (int i = 1; i < keyLen; ++i) { \
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
#define MAX_RETRY_TIMES 5
#define LINE_BATCH 20
//=================================================================================================
typedef
TSDB_SML_PROTOCOL_TYPE
SMLProtocolType
;
...
...
@@ -164,7 +165,7 @@ typedef struct{
typedef
struct
{
int64_t
id
;
Params
params
;
Params
*
params
;
bool
isLast
;
SMLProtocolType
protocol
;
...
...
@@ -2311,29 +2312,24 @@ static int32_t isSchemalessDb(STscObj *taos, SCatalog *catalog){
}
static
void
smlInsertCallback
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"failed to execute, reason:%s
\n
"
,
taos_errstr
(
res
));
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
int32_t
rows
=
taos_affected_rows
(
pRequest
);
SSmlHandle
*
info
=
(
SSmlHandle
*
)
param
;
// lock
taosThreadSpinLock
(
&
info
->
params
.
lock
);
info
->
params
.
request
->
body
.
resInfo
.
numOfRows
+=
rows
;
if
(
code
!=
TSDB_CODE_SUCCESS
){
info
->
params
.
request
->
code
=
code
;
taosThreadSpinLock
(
&
info
->
params
->
lock
);
info
->
params
->
request
->
code
=
code
;
taosThreadSpinUnlock
(
&
info
->
params
->
lock
);
}
taosThreadSpinUnlock
(
&
info
->
params
.
lock
);
// unlock
printf
(
"SML:0x%"
PRIx64
" insert finished, code: %d, total: %d
, insert: %d
\n
"
,
info
->
id
,
code
,
info
->
affectedRows
,
r
ows
);
Params
pParam
=
info
->
params
;
printf
(
"SML:0x%"
PRIx64
" insert finished, code: %d, total: %d
\n
"
,
info
->
id
,
code
,
info
->
affectedR
ows
);
Params
*
pParam
=
info
->
params
;
bool
isLast
=
info
->
isLast
;
smlDestroyInfo
(
info
);
if
(
isLast
){
tsem_post
(
&
pParam
.
sem
);
tsem_post
(
&
pParam
->
sem
);
}
}
...
...
@@ -2366,8 +2362,9 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
}
((
STscObj
*
)
taos
)
->
schemalessType
=
1
;
SSmlMsgBuf
msg
=
{.
buf
=
request
->
msgBuf
,
.
len
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
SSmlMsgBuf
msg
=
{.
len
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
buf
=
request
->
msgBuf
};
int
cnt
=
ceil
(((
double
)
numLines
)
/
LINE_BATCH
);
Params
params
=
{.
request
=
request
};
tsem_init
(
&
params
.
sem
,
0
,
0
);
taosThreadSpinInit
(
&
(
params
.
lock
),
0
);
...
...
@@ -2385,7 +2382,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
goto
end
;
}
if
(
isSchemalessDb
(
taos
,
params
.
catalog
)
!=
TSDB_CODE_SUCCESS
){
if
(
isSchemalessDb
(
((
STscObj
*
)
taos
)
,
params
.
catalog
)
!=
TSDB_CODE_SUCCESS
){
request
->
code
=
TSDB_CODE_SML_INVALID_DB_CONF
;
smlBuildInvalidDataMsg
(
&
msg
,
"Cannot write data to a non schemaless database"
,
NULL
);
goto
end
;
...
...
@@ -2409,8 +2406,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
goto
end
;
}
int32_t
perBatch
=
20000
;
for
(
int
i
=
0
;
i
<
ceil
(((
double
)
numLines
)
/
perBatch
);
++
i
)
{
for
(
int
i
=
0
;
i
<
cnt
;
++
i
)
{
SRequestObj
*
req
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
if
(
!
req
){
request
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -2424,7 +2420,9 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
goto
end
;
}
if
(
numLines
>=
perBatch
){
int32_t
perBatch
=
LINE_BATCH
;
if
(
numLines
>
perBatch
){
numLines
-=
perBatch
;
info
->
isLast
=
false
;
}
else
{
...
...
@@ -2433,7 +2431,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
info
->
isLast
=
true
;
}
info
->
params
=
params
;
info
->
params
=
&
params
;
info
->
pCatalog
=
params
.
catalog
;
info
->
affectedRows
=
perBatch
;
info
->
pRequest
->
body
.
queryFp
=
smlInsertCallback
;
...
...
source/client/test/smlTest.cpp
浏览文件 @
a4fba1c7
...
...
@@ -1325,7 +1325,7 @@ TEST(testCase, sml_oom_Test) {
pRes
=
taos_query
(
taos
,
"use oom"
);
taos_free_result
(
pRes
);
TAOS_RES
*
res
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
100
,
TSDB_SML_LINE_PROTOCOL
,
0
);
TAOS_RES
*
res
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
])
,
TSDB_SML_LINE_PROTOCOL
,
0
);
ASSERT_EQ
(
taos_errno
(
res
),
0
);
taos_free_result
(
pRes
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录