Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e4d61953
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看板
提交
e4d61953
编写于
3月 12, 2021
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3192] <feature>: support stb limit and offset. verified.
上级
57c1f20f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
84 addition
and
71 deletion
+84
-71
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+84
-71
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
e4d61953
...
...
@@ -1982,7 +1982,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
exit
(
-
1
);
}
int
childTblCount
=
10000
;
int
childTblCount
=
(
limit
<
0
)
?
10000
:
limit
;
int
count
=
0
;
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
char
*
pTblName
=
childTblName
;
...
...
@@ -2525,14 +2525,8 @@ static void createChildTables() {
verbosePrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
int
startFrom
;
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
)
{
startFrom
=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblOffset
;
g_totalChildTables
+=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblLimit
;
}
else
{
startFrom
=
0
;
int
startFrom
=
0
;
g_totalChildTables
+=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
;
}
verbosePrint
(
"%s() LN%d: create %d child tables from %d
\n
"
,
__func__
,
__LINE__
,
g_totalChildTables
,
startFrom
);
...
...
@@ -3882,7 +3876,7 @@ PARSE_OVER:
return
ret
;
}
void
pre
P
areSampleData
()
{
void
pre
p
areSampleData
()
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
//if (0 == strncasecmp(g_Dbs.db[i].superTbls[j].dataSource, "sample", 6)) {
...
...
@@ -4018,7 +4012,7 @@ static void syncWriteForNumberOfTblInOneSql(
int64_t
et
=
0xffffffff
;
for
(
int
i
=
0
;
i
<
superTblInfo
->
insertRows
;)
{
int32_t
tbl_id
=
0
;
for
(
int
table
ID
=
winfo
->
start_table_id
;
tableID
<=
winfo
->
end_table_id
;
)
{
for
(
int
table
Seq
=
winfo
->
start_table_id
;
tableSeq
<=
winfo
->
end_table_id
;
)
{
int64_t
start_time
=
0
;
int
inserted
=
i
;
...
...
@@ -4027,12 +4021,12 @@ static void syncWriteForNumberOfTblInOneSql(
memset
(
buffer
,
0
,
superTblInfo
->
maxSqlLen
);
char
*
pstr
=
buffer
;
int32_t
end_tbl_id
=
table
ID
+
numberOfTblInOneSql
;
int32_t
end_tbl_id
=
table
Seq
+
numberOfTblInOneSql
;
if
(
end_tbl_id
>
winfo
->
end_table_id
)
{
end_tbl_id
=
winfo
->
end_table_id
+
1
;
}
for
(
tbl_id
=
table
ID
;
tbl_id
<
end_tbl_id
;
tbl_id
++
)
{
for
(
tbl_id
=
table
Seq
;
tbl_id
<
end_tbl_id
;
tbl_id
++
)
{
sampleUsePos
=
samplePos
;
if
(
AUTO_CREATE_SUBTBL
==
superTblInfo
->
autoCreateTable
)
{
char
*
tagsValBuf
=
NULL
;
...
...
@@ -4140,7 +4134,7 @@ static void syncWriteForNumberOfTblInOneSql(
if
(
inserted
>=
superTblInfo
->
insertRows
||
(
superTblInfo
->
maxSqlLen
-
len
)
<
(
superTblInfo
->
lenOfOneRow
+
128
))
{
table
ID
=
tbl_id
+
1
;
table
Seq
=
tbl_id
+
1
;
printf
(
"config rowsPerTbl and numberOfTblInOneSql not match with max_sql_lenth, please reconfig![lenOfOneRow:%d]
\n
"
,
superTblInfo
->
lenOfOneRow
);
goto
send_to_server
;
...
...
@@ -4148,7 +4142,7 @@ static void syncWriteForNumberOfTblInOneSql(
}
}
table
ID
=
tbl_id
;
table
Seq
=
tbl_id
;
inserted
+=
superTblInfo
->
rowsPerTbl
;
send_to_server:
...
...
@@ -4217,7 +4211,7 @@ send_to_server:
break
;
}
if
(
table
ID
>
winfo
->
end_table_id
)
{
if
(
table
Seq
>
winfo
->
end_table_id
)
{
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
)))
{
samplePos
=
sampleUsePos
;
}
...
...
@@ -4231,7 +4225,8 @@ send_to_server:
free_and_statistics:
tmfree
(
buffer
);
printf
(
"====thread[%d] completed total inserted rows: %"
PRId64
", affected rows: %"
PRId64
"====
\n
"
,
winfo
->
threadID
,
winfo
->
totalInsertRows
,
winfo
->
totalAffectedRows
);
printf
(
"====thread[%d] completed total inserted rows: %"
PRId64
", affected rows: %"
PRId64
"====
\n
"
,
winfo
->
threadID
,
winfo
->
totalInsertRows
,
winfo
->
totalAffectedRows
);
return
;
}
...
...
@@ -4293,7 +4288,7 @@ int32_t generateData(char *res, char **data_type,
return
(
int32_t
)(
pstr
-
res
);
}
static
int
prepareSampleData
(
SSuperTable
*
superTblInfo
)
{
static
int
prepareSampleData
ForSTable
(
SSuperTable
*
superTblInfo
)
{
char
*
sampleDataBuf
=
NULL
;
// each thread read sample data from csv file
...
...
@@ -4330,7 +4325,6 @@ static int execInsert(threadInfo *winfo, char *buffer, int k)
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
);
...
...
@@ -4354,7 +4348,8 @@ static int execInsert(threadInfo *winfo, char *buffer, int k)
return
affectedRows
;
}
static
int
generateDataBuffer
(
int32_t
tableID
,
threadInfo
*
pThreadInfo
,
char
*
buffer
,
static
int
generateDataBuffer
(
int32_t
tableSeq
,
threadInfo
*
pThreadInfo
,
char
*
buffer
,
int64_t
insertRows
,
int64_t
startFrom
,
int64_t
startTime
,
int
*
pSampleUsePos
)
{
...
...
@@ -4372,6 +4367,26 @@ static int generateDataBuffer(int32_t tableID, threadInfo *pThreadInfo, char *bu
assert
(
buffer
!=
NULL
);
char
*
pChildTblName
;
int
childTblCount
;
if
(
superTblInfo
&&
(
superTblInfo
->
childTblOffset
>
0
))
{
// TODO
// select tbname from stb limit 1 offset tableSeq
getChildNameOfSuperTableWithLimitAndOffset
(
pThreadInfo
->
taos
,
pThreadInfo
->
db_name
,
superTblInfo
->
sTblName
,
&
pChildTblName
,
&
childTblCount
,
1
,
tableSeq
);
}
else
{
pChildTblName
=
calloc
(
TSDB_TABLE_NAME_LEN
,
1
);
if
(
NULL
==
pChildTblName
)
{
fprintf
(
stderr
,
"failed to alloc memory %d
\n
"
,
TSDB_TABLE_NAME_LEN
);
return
-
1
;
}
snprintf
(
pChildTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%d"
,
superTblInfo
?
superTblInfo
->
childTblPrefix
:
g_args
.
tb_prefix
,
tableSeq
);
}
memset
(
buffer
,
0
,
superTblInfo
?
superTblInfo
->
maxSqlLen
:
g_args
.
max_sql_len
);
char
*
pstr
=
buffer
;
...
...
@@ -4384,19 +4399,19 @@ static int generateDataBuffer(int32_t tableID, threadInfo *pThreadInfo, char *bu
}
else
{
tagsValBuf
=
getTagValueFromTagSample
(
superTblInfo
,
table
ID
%
superTblInfo
->
tagSampleCount
);
table
Seq
%
superTblInfo
->
tagSampleCount
);
}
if
(
NULL
==
tagsValBuf
)
{
fprintf
(
stderr
,
"tag buf failed to allocate memory
\n
"
);
free
(
pChildTblName
);
return
-
1
;
}
pstr
+=
snprintf
(
pstr
,
superTblInfo
->
maxSqlLen
,
"insert into %s.%s
%d
using %s.%s tags %s values"
,
"insert into %s.%s using %s.%s tags %s values"
,
pThreadInfo
->
db_name
,
superTblInfo
->
childTblPrefix
,
tableID
,
pChildTblName
,
pThreadInfo
->
db_name
,
superTblInfo
->
sTblName
,
tagsValBuf
);
...
...
@@ -4406,22 +4421,20 @@ static int generateDataBuffer(int32_t tableID, threadInfo *pThreadInfo, char *bu
superTblInfo
->
maxSqlLen
,
"insert into %s.%s values"
,
pThreadInfo
->
db_name
,
superTblInfo
->
childTblName
+
table
ID
*
TSDB_TABLE_NAME_LEN
);
superTblInfo
->
childTblName
+
table
Seq
*
TSDB_TABLE_NAME_LEN
);
}
else
{
pstr
+=
snprintf
(
pstr
,
(
superTblInfo
?
superTblInfo
->
maxSqlLen
:
g_args
.
max_sql_len
),
"insert into %s.%s
%d
values"
,
"insert into %s.%s values"
,
pThreadInfo
->
db_name
,
superTblInfo
?
superTblInfo
->
childTblPrefix
:
g_args
.
tb_prefix
,
tableID
);
pChildTblName
);
}
}
else
{
pstr
+=
snprintf
(
pstr
,
(
superTblInfo
?
superTblInfo
->
maxSqlLen
:
g_args
.
max_sql_len
),
"insert into %s.%s
%d
values"
,
"insert into %s.%s values"
,
pThreadInfo
->
db_name
,
superTblInfo
?
superTblInfo
->
childTblPrefix
:
g_args
.
tb_prefix
,
tableID
);
pChildTblName
);
}
int
k
;
...
...
@@ -4432,14 +4445,16 @@ static int generateDataBuffer(int32_t tableID, threadInfo *pThreadInfo, char *bu
if
(
superTblInfo
)
{
int
retLen
=
0
;
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
)))
{
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
)))
{
retLen
=
getRowDataFromSample
(
pstr
+
len
,
superTblInfo
->
maxSqlLen
-
len
,
startTime
+
superTblInfo
->
timeStampStep
*
startFrom
,
superTblInfo
,
pSampleUsePos
);
}
else
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
}
else
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
int
rand_num
=
rand_tinyint
()
%
100
;
if
(
0
!=
superTblInfo
->
disorderRatio
&&
rand_num
<
superTblInfo
->
disorderRatio
)
{
...
...
@@ -4459,6 +4474,7 @@ static int generateDataBuffer(int32_t tableID, threadInfo *pThreadInfo, char *bu
}
if
(
retLen
<
0
)
{
free
(
pChildTblName
);
return
-
1
;
}
...
...
@@ -4518,7 +4534,7 @@ static void* syncWrite(void *sarg) {
if
(
superTblInfo
)
{
if
(
0
!=
prepareSampleData
(
superTblInfo
))
if
(
0
!=
prepareSampleData
ForSTable
(
superTblInfo
))
return
NULL
;
if
(
superTblInfo
->
numberOfTblInOneSql
>
0
)
{
...
...
@@ -4553,12 +4569,8 @@ static void* syncWrite(void *sarg) {
int
sampleUsePos
;
if
(
superTblInfo
&&
superTblInfo
->
childTblOffset
)
{
// TODO
}
for
(
uint32_t
tableID
=
winfo
->
start_table_id
;
tableID
<=
winfo
->
end_table_id
;
tableID
++
)
{
for
(
uint32_t
tableSeq
=
winfo
->
start_table_id
;
tableSeq
<=
winfo
->
end_table_id
;
tableSeq
++
)
{
int64_t
start_time
=
winfo
->
start_time
;
int64_t
insertRows
=
(
superTblInfo
)
?
superTblInfo
->
insertRows
:
g_args
.
num_of_DPT
;
...
...
@@ -4571,7 +4583,7 @@ static void* syncWrite(void *sarg) {
sampleUsePos
=
samplePos
;
int
generated
=
generateDataBuffer
(
table
ID
,
winfo
,
buffer
,
insertRows
,
int
generated
=
generateDataBuffer
(
table
Seq
,
winfo
,
buffer
,
insertRows
,
i
,
start_time
,
&
sampleUsePos
);
if
(
generated
>
0
)
i
+=
generated
;
...
...
@@ -4615,12 +4627,12 @@ static void* syncWrite(void *sarg) {
}
}
// num_of_DPT
if
((
table
ID
==
winfo
->
end_table_id
)
&&
superTblInfo
&&
if
((
table
Seq
==
winfo
->
end_table_id
)
&&
superTblInfo
&&
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
))))
{
samplePos
=
sampleUsePos
;
}
}
// table
ID
}
// table
Seq
free_and_statistics_2:
tmfree
(
buffer
);
...
...
@@ -5069,7 +5081,7 @@ static int insertTestProcess() {
}
// pretreatement
pre
P
areSampleData
();
pre
p
areSampleData
();
double
start
;
double
end
;
...
...
@@ -5297,7 +5309,8 @@ static int queryTestProcess() {
pthread_t
*
pidsOfSub
=
NULL
;
threadInfo
*
infosOfSub
=
NULL
;
//==== create sub threads for query from all sub table of the super table
if
((
g_queryInfo
.
subQueryInfo
.
sqlCount
>
0
)
&&
(
g_queryInfo
.
subQueryInfo
.
threadCnt
>
0
))
{
if
((
g_queryInfo
.
subQueryInfo
.
sqlCount
>
0
)
&&
(
g_queryInfo
.
subQueryInfo
.
threadCnt
>
0
))
{
pidsOfSub
=
malloc
(
g_queryInfo
.
subQueryInfo
.
threadCnt
*
sizeof
(
pthread_t
));
infosOfSub
=
malloc
(
g_queryInfo
.
subQueryInfo
.
threadCnt
*
sizeof
(
threadInfo
));
if
((
NULL
==
pidsOfSub
)
||
(
NULL
==
infosOfSub
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录