Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
7f2116fb
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7f2116fb
编写于
3月 12, 2021
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3192] <feature>: support stb limit and offset. refactor.
上级
405814f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
57 deletion
+62
-57
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+62
-57
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
7f2116fb
...
...
@@ -262,7 +262,7 @@ typedef struct SSuperTable_S {
int
tagUsePos
;
// statistics
int64_t
total
RowsInserted
;
int64_t
total
InsertRows
;
int64_t
totalAffectedRows
;
}
SSuperTable
;
...
...
@@ -332,7 +332,7 @@ typedef struct SDbs_S {
SDataBase
db
[
MAX_DB_COUNT
];
// statistics
int64_t
total
RowsInserted
;
int64_t
total
InsertRows
;
int64_t
totalAffectedRows
;
}
SDbs
;
...
...
@@ -403,7 +403,7 @@ typedef struct SThreadInfo_S {
int64_t
lastTs
;
// statistics
int64_t
total
RowsInserted
;
int64_t
total
InsertRows
;
int64_t
totalAffectedRows
;
// insert delay statistics
...
...
@@ -3986,8 +3986,6 @@ static void syncWriteForNumberOfTblInOneSql(
int
samplePos
=
0
;
//printf("========threadID[%d], table rang: %d - %d \n", winfo->threadID, winfo->start_table_id, winfo->end_table_id);
int64_t
totalRowsInserted
=
0
;
int64_t
totalAffectedRows
=
0
;
int64_t
lastPrintTime
=
taosGetTimestampMs
();
char
*
buffer
=
calloc
(
superTblInfo
->
maxSqlLen
+
1
,
1
);
...
...
@@ -4128,7 +4126,7 @@ static void syncWriteForNumberOfTblInOneSql(
len
+=
retLen
;
//inserted++;
j
++
;
totalRowsInserted
++
;
winfo
->
totalInsertRows
++
;
if
(
inserted
>=
superTblInfo
->
insertRows
||
(
superTblInfo
->
maxSqlLen
-
len
)
<
(
superTblInfo
->
lenOfOneRow
+
128
))
{
...
...
@@ -4185,7 +4183,7 @@ send_to_server:
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently inserted rows: %"
PRId64
", affected rows: %"
PRId64
"
\n
"
,
winfo
->
threadID
,
winfo
->
total
RowsInserted
,
winfo
->
total
InsertRows
,
winfo
->
totalAffectedRows
);
lastPrintTime
=
currentPrintTime
;
}
...
...
@@ -4223,9 +4221,7 @@ send_to_server:
free_and_statistics:
tmfree
(
buffer
);
winfo
->
totalRowsInserted
=
totalRowsInserted
;
winfo
->
totalAffectedRows
=
totalAffectedRows
;
printf
(
"====thread[%d] completed total inserted rows: %"
PRId64
", affected rows: %"
PRId64
"====
\n
"
,
winfo
->
threadID
,
totalRowsInserted
,
totalAffectedRows
);
printf
(
"====thread[%d] completed total inserted rows: %"
PRId64
", affected rows: %"
PRId64
"====
\n
"
,
winfo
->
threadID
,
winfo
->
totalInsertRows
,
winfo
->
totalAffectedRows
);
return
;
}
...
...
@@ -4315,6 +4311,39 @@ static int prepareSampleData(SSuperTable *superTblInfo) {
return
0
;
}
static
int
execInsert
(
threadInfo
*
winfo
,
char
*
buffer
,
int
k
)
{
int
affectedRows
;
SSuperTable
*
superTblInfo
=
winfo
->
superTblInfo
;
if
(
superTblInfo
)
{
if
(
0
==
strncasecmp
(
superTblInfo
->
insertMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
}
else
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
retCode
=
postProceSql
(
g_Dbs
.
host
,
g_Dbs
.
port
,
buffer
);
if
(
0
!=
retCode
)
{
affectedRows
=
-
1
;
printf
(
"========restful return fail, threadID[%d]
\n
"
,
winfo
->
threadID
);
}
else
{
affectedRows
=
k
;
}
}
}
else
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
}
if
(
0
>
affectedRows
){
return
affectedRows
;
}
return
affectedRows
;
}
// sync insertion
/*
1 thread: 100 tables * 2000 rows/s
...
...
@@ -4324,7 +4353,6 @@ static int prepareSampleData(SSuperTable *superTblInfo) {
2 taosinsertdata , 1 thread: 10 tables * 20000 rows/s
*/
static
void
*
syncWrite
(
void
*
sarg
)
{
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
threadInfo
*
winfo
=
(
threadInfo
*
)
sarg
;
SSuperTable
*
superTblInfo
=
winfo
->
superTblInfo
;
...
...
@@ -4360,11 +4388,15 @@ static void* syncWrite(void *sarg) {
return
NULL
;
}
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
startTs
=
taosGetTimestampUs
();
int64_t
endTs
;
int
insert_interval
=
superTblInfo
?
superTblInfo
->
insertInterval
:
g_args
.
insert_interval
;
uint64_t
st
=
0
;
uint64_t
et
=
0xffffffff
;
winfo
->
total
RowsInserted
=
0
;
winfo
->
total
InsertRows
=
0
;
winfo
->
totalAffectedRows
=
0
;
int
sampleUsePos
;
...
...
@@ -4383,12 +4415,12 @@ static void* syncWrite(void *sarg) {
for
(
int64_t
i
=
0
;
i
<
insertRows
;)
{
int64_t
prepared
=
i
;
sampleUsePos
=
samplePos
;
if
(
insert_interval
)
{
st
=
taosGetTimestampUs
();
st
=
taosGetTimestampUs
();
}
sampleUsePos
=
samplePos
;
memset
(
buffer
,
0
,
superTblInfo
?
superTblInfo
->
maxSqlLen
:
g_args
.
max_sql_len
);
char
*
pstr
=
buffer
;
...
...
@@ -4518,35 +4550,12 @@ static void* syncWrite(void *sarg) {
break
;
}
winfo
->
totalRowsInserted
+=
k
;
int64_t
startTs
=
taosGetTimestampUs
();
int64_t
endTs
;
int
affectedRows
;
if
(
superTblInfo
)
{
if
(
0
==
strncasecmp
(
superTblInfo
->
insertMode
,
"taosc"
,
strlen
(
"taosc"
)))
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
if
(
0
>
affectedRows
){
goto
free_and_statistics_2
;
}
}
else
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
retCode
=
postProceSql
(
g_Dbs
.
host
,
g_Dbs
.
port
,
buffer
);
int
affectedRows
=
execInsert
(
winfo
,
buffer
,
k
);
if
(
affectedRows
<
0
)
goto
free_and_statistics_2
;
if
(
0
!=
retCode
)
{
printf
(
"========restful return fail, threadID[%d]
\n
"
,
winfo
->
threadID
);
goto
free_and_statistics_2
;
}
affectedRows
=
k
;
}
}
else
{
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
}
winfo
->
totalInsertRows
+=
k
;
winfo
->
totalAffectedRows
+=
affectedRows
;
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
...
...
@@ -4555,13 +4564,11 @@ static void* syncWrite(void *sarg) {
winfo
->
cntDelay
++
;
winfo
->
totalDelay
+=
delay
;
winfo
->
totalAffectedRows
+=
affectedRows
;
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently inserted rows: %"
PRId64
", affected rows: %"
PRId64
"
\n
"
,
winfo
->
threadID
,
winfo
->
total
RowsInserted
,
winfo
->
total
InsertRows
,
winfo
->
totalAffectedRows
);
lastPrintTime
=
currentPrintTime
;
}
...
...
@@ -4572,14 +4579,12 @@ static void* syncWrite(void *sarg) {
if
(
insert_interval
)
{
et
=
taosGetTimestampUs
();
printf
(
"et: %ld ms st: %ld
\n
"
,
et
,
st
);
if
(
insert_interval
>
((
et
-
st
)
/
1000
)
)
{
int
sleep_time
=
insert_interval
-
(
et
-
st
)
/
1000
;
printf
(
"sleep: %d ms for insert interval
\n
"
,
sleep_time
);
taosMsleep
(
sleep_time
);
// ms
}
}
}
// num_of_DPT
if
((
tID
==
winfo
->
end_table_id
)
&&
superTblInfo
&&
...
...
@@ -4596,7 +4601,7 @@ free_and_statistics_2:
printf
(
"====thread[%d] completed total inserted rows: %"
PRId64
", total affected rows: %"
PRId64
"====
\n
"
,
winfo
->
threadID
,
winfo
->
total
RowsInserted
,
winfo
->
total
InsertRows
,
winfo
->
totalAffectedRows
);
return
NULL
;
}
...
...
@@ -4806,7 +4811,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if
(
superTblInfo
)
{
superTblInfo
->
totalAffectedRows
+=
t_info
->
totalAffectedRows
;
superTblInfo
->
total
RowsInserted
+=
t_info
->
totalRowsInserted
;
superTblInfo
->
total
InsertRows
+=
t_info
->
totalInsertRows
;
}
totalDelay
+=
t_info
->
totalDelay
;
...
...
@@ -4824,16 +4829,16 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if
(
superTblInfo
)
{
printf
(
"Spent %.4f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
t
,
superTblInfo
->
total
RowsInserted
,
t
,
superTblInfo
->
total
InsertRows
,
superTblInfo
->
totalAffectedRows
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
superTblInfo
->
total
RowsInserted
/
t
);
superTblInfo
->
total
InsertRows
/
t
);
fprintf
(
g_fpOfInsertResult
,
"Spent %.4f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
t
,
superTblInfo
->
total
RowsInserted
,
t
,
superTblInfo
->
total
InsertRows
,
superTblInfo
->
totalAffectedRows
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
superTblInfo
->
total
RowsInserted
/
t
);
superTblInfo
->
total
InsertRows
/
t
);
}
printf
(
"insert delay, avg: %10.6fms, max: %10.6fms, min: %10.6fms
\n\n
"
,
...
...
@@ -5067,14 +5072,14 @@ static int insertTestProcess() {
}
//end = getCurrentTime();
//int64_t total
RowsInserted
= 0;
//int64_t total
InsertRows
= 0;
//int64_t totalAffectedRows = 0;
//for (int i = 0; i < g_Dbs.dbCount; i++) {
// for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) {
// total
RowsInserted += g_Dbs.db[i].superTbls[j].totalRowsInserted
;
// total
InsertRows+= g_Dbs.db[i].superTbls[j].totalInsertRows
;
// totalAffectedRows += g_Dbs.db[i].superTbls[j].totalAffectedRows;
//}
//printf("Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s)\n\n", end - start, total
RowsInserted
, totalAffectedRows, g_Dbs.threadCount);
//printf("Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s)\n\n", end - start, total
InsertRows
, totalAffectedRows, g_Dbs.threadCount);
postFreeResource
();
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录