Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
483574a0
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看板
未验证
提交
483574a0
编写于
4月 10, 2021
作者:
sangshuduo
提交者:
GitHub
4月 10, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3733]<fix>: taosdemo buffer processing refactor. (#5766)
Co-authored-by:
N
Shuduo Sang
<
sdsang@taosdata.com
>
上级
ef2246da
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
46 deletion
+77
-46
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+77
-46
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
483574a0
...
...
@@ -2949,9 +2949,6 @@ static int readSampleFromCsvFileToMem(
continue
;
}
verbosePrint
(
"readLen=%ld stb->lenOfOneRow=%d getRows=%d
\n
"
,
(
long
)
readLen
,
superTblInfo
->
lenOfOneRow
,
getRows
);
memcpy
(
superTblInfo
->
sampleDataBuf
+
getRows
*
superTblInfo
->
lenOfOneRow
,
line
,
readLen
);
getRows
++
;
...
...
@@ -3527,6 +3524,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
goto
PARSE_OVER
;
}
/*
cJSON* batchCreateTbl = cJSON_GetObjectItem(stbInfo, "batch_create_tbl_num");
if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) {
g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint;
...
...
@@ -3536,6 +3534,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
printf("ERROR: failed to read json, batch_create_tbl_num not found\n");
goto PARSE_OVER;
}
*/
cJSON
*
childTblExists
=
cJSON_GetObjectItem
(
stbInfo
,
"child_table_exists"
);
// yes, no
if
(
childTblExists
...
...
@@ -4619,7 +4618,8 @@ static int generateDataTail(char *tableName, int32_t tableSeq,
}
static
int
generateSQLHead
(
char
*
tableName
,
int32_t
tableSeq
,
threadInfo
*
pThreadInfo
,
SSuperTable
*
superTblInfo
,
char
*
buffer
)
threadInfo
*
pThreadInfo
,
SSuperTable
*
superTblInfo
,
char
*
buffer
,
int
remainderBufLen
)
{
int
len
;
if
(
superTblInfo
)
{
...
...
@@ -4671,7 +4671,62 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
return
len
;
}
static
int
generateProgressiveDataBuffer
(
char
*
pTblName
,
static
int
generateInterlaceDataBuffer
(
char
*
tableName
,
int
batchPerTbl
,
int
i
,
int
batchPerTblTimes
,
int32_t
tableSeq
,
threadInfo
*
pThreadInfo
,
char
*
buffer
,
int64_t
insertRows
,
int64_t
startTime
,
int
*
pRemainderBufLen
)
{
char
*
pstr
=
buffer
;
SSuperTable
*
superTblInfo
=
pThreadInfo
->
superTblInfo
;
int
headLen
=
generateSQLHead
(
tableName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
pstr
,
*
pRemainderBufLen
);
if
(
headLen
<=
0
)
{
return
0
;
}
// generate data buffer
verbosePrint
(
"[%d] %s() LN%d i=%d buffer:
\n
%s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
i
,
buffer
);
pstr
+=
headLen
;
*
pRemainderBufLen
-=
headLen
;
int
dataLen
=
0
;
verbosePrint
(
"[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
i
,
batchPerTblTimes
,
batchPerTbl
);
if
(
superTblInfo
)
{
if
(
0
==
strncasecmp
(
superTblInfo
->
startTimestamp
,
"now"
,
3
))
{
startTime
=
taosGetTimestamp
(
pThreadInfo
->
time_precision
);
}
}
else
{
startTime
=
1500000000000
;
}
int
k
=
generateDataTail
(
tableName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
batchPerTbl
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
0
,
startTime
,
&
(
pThreadInfo
->
samplePos
),
&
dataLen
);
if
(
k
>
0
)
{
pstr
+=
dataLen
;
*
pRemainderBufLen
-=
dataLen
;
}
else
{
pstr
-=
headLen
;
pstr
[
0
]
=
'\0'
;
}
return
k
;
}
static
int
generateProgressiveDataBuffer
(
char
*
tableName
,
int32_t
tableSeq
,
threadInfo
*
pThreadInfo
,
char
*
buffer
,
int64_t
insertRows
,
...
...
@@ -4691,6 +4746,7 @@ static int generateProgressiveDataBuffer(char *pTblName,
assert
(
buffer
!=
NULL
);
int
k
=
0
;
int
maxSqlLen
=
superTblInfo
?
superTblInfo
->
maxSqlLen
:
g_args
.
max_sql_len
;
int
remainderBufLen
=
maxSqlLen
;
...
...
@@ -4698,14 +4754,17 @@ static int generateProgressiveDataBuffer(char *pTblName,
char
*
pstr
=
buffer
;
int
headLen
=
generateSQLHead
(
pTblName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
buffer
);
int
headLen
=
generateSQLHead
(
tableName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
buffer
,
remainderBufLen
);
if
(
headLen
<=
0
)
{
return
0
;
}
pstr
+=
headLen
;
remainderBufLen
-=
headLen
;
int
k
;
int
dataLen
;
k
=
generateDataTail
(
pTbl
Name
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
k
=
generateDataTail
(
table
Name
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
g_args
.
num_of_RPR
,
pstr
,
remainderBufLen
,
insertRows
,
startFrom
,
startTime
,
pSamplePos
,
&
dataLen
);
...
...
@@ -4811,50 +4870,23 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
return
NULL
;
}
int
headLen
;
if
(
i
==
0
)
{
headLen
=
generateSQLHead
(
tableName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
pstr
);
}
else
{
headLen
=
snprintf
(
pstr
,
TSDB_TABLE_NAME_LEN
,
"%s.%s values"
,
pThreadInfo
->
db_name
,
tableName
);
}
// generate data buffer
verbosePrint
(
"[%d] %s() LN%d i=%d buffer:
\n
%s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
i
,
buffer
);
pstr
+=
headLen
;
remainderBufLen
-=
headLen
;
int
dataLen
=
0
;
verbosePrint
(
"[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
i
,
batchPerTblTimes
,
batchPerTbl
);
if
(
superTblInfo
)
{
if
(
0
==
strncasecmp
(
superTblInfo
->
startTimestamp
,
"now"
,
3
))
{
startTime
=
taosGetTimestamp
(
pThreadInfo
->
time_precision
);
}
}
else
{
startTime
=
1500000000000
;
}
int
generated
=
generateDataTail
(
tableName
,
tableSeq
,
pThreadInfo
,
superTblInfo
,
batchPerTbl
,
pstr
,
remainderBufLen
,
insertRows
,
0
,
int
generated
=
generateInterlaceDataBuffer
(
tableName
,
batchPerTbl
,
i
,
batchPerTblTimes
,
tableSeq
,
pThreadInfo
,
pstr
,
insertRows
,
startTime
,
&
(
pThreadInfo
->
samplePos
),
&
data
Len
);
&
remainderBuf
Len
);
if
(
generated
<
0
)
{
debugPrint
(
"[%d] %s() LN%d, generated data is %d
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
generated
);
goto
free_and_statistics_interlace
;
}
else
if
(
generated
==
0
)
{
break
;
}
pstr
+=
dataLen
;
remainderBufLen
-=
dataLen
;
tableSeq
++
;
recOfBatch
+=
batchPerTbl
;
// startTime += batchPerTbl * superTblInfo->timeStampStep;
pThreadInfo
->
totalInsertRows
+=
batchPerTbl
;
...
...
@@ -4862,7 +4894,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
batchPerTbl
,
recOfBatch
);
tableSeq
++
;
if
(
insertMode
==
INTERLACE_INSERT_MODE
)
{
if
(
tableSeq
==
pThreadInfo
->
start_table_from
+
pThreadInfo
->
ntables
)
{
// turn to first table
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录