Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
86f48515
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看板
提交
86f48515
编写于
3月 15, 2021
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3192] <feature>: support child table limit and offset.
resolve memory alloc issue.
上级
86105e72
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
33 deletion
+37
-33
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+37
-33
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
86f48515
...
...
@@ -1997,7 +1997,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
int
childTblCount
=
(
limit
<
0
)
?
10000
:
limit
;
int
count
=
0
;
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
//
childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN);
char
*
pTblName
=
childTblName
;
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
int32_t
*
len
=
taos_fetch_lengths
(
res
);
...
...
@@ -3955,7 +3955,7 @@ static int getRowDataFromSample(char* dataBuf, int maxLen, int64_t timestamp,
return
dataLen
;
}
int
generateRowData
(
char
*
dataBuf
,
int
maxLen
,
int64_t
timestamp
,
SSuperTable
*
stbInfo
)
{
static
int
generateRowData
(
char
*
dataBuf
,
int
maxLen
,
int64_t
timestamp
,
SSuperTable
*
stbInfo
)
{
int
dataLen
=
0
;
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
"(%"
PRId64
", "
,
timestamp
);
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
...
...
@@ -4343,26 +4343,22 @@ static int execInsert(threadInfo *winfo, char *buffer, int k)
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
);
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
);
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
;
}
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
;
verbosePrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
}
return
affectedRows
;
...
...
@@ -4390,6 +4386,12 @@ static int generateDataBuffer(int32_t tableSeq,
char
*
pChildTblName
;
int
childTblCount
;
pChildTblName
=
calloc
(
TSDB_TABLE_NAME_LEN
,
1
);
if
(
NULL
==
pChildTblName
)
{
fprintf
(
stderr
,
"failed to alloc memory %d
\n
"
,
TSDB_TABLE_NAME_LEN
);
return
-
1
;
}
if
(
superTblInfo
&&
(
superTblInfo
->
childTblOffset
>
0
))
{
// select tbname from stb limit 1 offset tableSeq
getChildNameOfSuperTableWithLimitAndOffset
(
pThreadInfo
->
taos
,
...
...
@@ -4397,11 +4399,6 @@ static int generateDataBuffer(int32_t tableSeq,
&
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
);
}
...
...
@@ -4421,9 +4418,9 @@ static int generateDataBuffer(int32_t tableSeq,
tableSeq
%
superTblInfo
->
tagSampleCount
);
}
if
(
NULL
==
tagsValBuf
)
{
fprintf
(
stderr
,
"tag buf failed to allocate memory
\n
"
);
free
(
pChildTblName
);
return
-
1
;
free
(
pChildTblName
);
fprintf
(
stderr
,
"tag buf failed to allocate memory
\n
"
);
return
-
1
;
}
pstr
+=
snprintf
(
pstr
,
...
...
@@ -4498,6 +4495,11 @@ static int generateDataBuffer(int32_t tableSeq,
}
len
+=
retLen
;
if
(
len
>=
(
superTblInfo
->
maxSqlLen
-
256
))
{
// reserve for overwrite
k
++
;
break
;
}
}
}
else
{
int
rand_num
=
taosRandom
()
%
100
;
...
...
@@ -4518,15 +4520,15 @@ static int generateDataBuffer(int32_t tableSeq,
lenOfBinary
);
}
pstr
+=
sprintf
(
pstr
,
" %s"
,
data
);
//assert(len + pstr - buffer < BUFFER_SIZE);
if
(
len
+
pstr
-
buffer
>=
g_args
.
max_sql_len
)
{
// too long
break
;
if
(
len
+
pstr
-
buffer
>=
(
g_args
.
max_sql_len
-
256
))
{
// too long
k
++
;
break
;
}
pstr
+=
sprintf
(
pstr
,
" %s"
,
data
);
}
verbosePrint
(
"%s() LN%d len=%d k=%d
\n
buffer=%
s
\n
"
,
__func__
,
__LINE__
,
len
,
k
,
buffer
);
verbosePrint
(
"%s() LN%d len=%d k=%d
\n
buffer=%
p
\n
"
,
__func__
,
__LINE__
,
len
,
k
,
buffer
);
k
++
;
startFrom
++
;
...
...
@@ -4535,7 +4537,8 @@ static int generateDataBuffer(int32_t tableSeq,
break
;
}
free
(
pChildTblName
);
if
(
pChildTblName
)
free
(
pChildTblName
);
return
k
;
}
...
...
@@ -4613,6 +4616,7 @@ static void* syncWrite(void *sarg) {
if
(
affectedRows
<
0
)
goto
free_and_statistics_2
;
winfo
->
totalInsertRows
+=
generated
;
winfo
->
totalAffectedRows
+=
affectedRows
;
...
...
@@ -4712,7 +4716,7 @@ void callBack(void *param, TAOS_RES *res, int code) {
break
;
}
}
if
(
insert_interval
)
{
winfo
->
st
=
taosGetTimestampUs
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录