Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
4ad67dbf
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看板
提交
4ad67dbf
编写于
9月 09, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename MAX_SAMPLES_ONCE_FROM_FILE to reflect reality.
上级
6c72fc31
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
26 deletion
+26
-26
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+26
-26
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
4ad67dbf
...
@@ -88,7 +88,7 @@ extern char configDir[];
...
@@ -88,7 +88,7 @@ extern char configDir[];
#define DOUBLE_BUFF_LEN 42
#define DOUBLE_BUFF_LEN 42
#define TIMESTAMP_BUFF_LEN 21
#define TIMESTAMP_BUFF_LEN 21
#define MAX_SAMPLES
_ONCE_FROM_FILE
10000
#define MAX_SAMPLES
10000
#define MAX_NUM_COLUMNS (TSDB_MAX_COLUMNS - 1) // exclude first column timestamp
#define MAX_NUM_COLUMNS (TSDB_MAX_COLUMNS - 1) // exclude first column timestamp
#define MAX_DB_COUNT 8
#define MAX_DB_COUNT 8
...
@@ -4500,7 +4500,7 @@ static int generateSampleFromCsvForStb(
...
@@ -4500,7 +4500,7 @@ static int generateSampleFromCsvForStb(
assert
(
stbInfo
->
sampleDataBuf
);
assert
(
stbInfo
->
sampleDataBuf
);
memset
(
stbInfo
->
sampleDataBuf
,
0
,
memset
(
stbInfo
->
sampleDataBuf
,
0
,
MAX_SAMPLES
_ONCE_FROM_FILE
*
stbInfo
->
lenOfOneRow
);
MAX_SAMPLES
*
stbInfo
->
lenOfOneRow
);
while
(
1
)
{
while
(
1
)
{
readLen
=
tgetline
(
&
line
,
&
n
,
fp
);
readLen
=
tgetline
(
&
line
,
&
n
,
fp
);
if
(
-
1
==
readLen
)
{
if
(
-
1
==
readLen
)
{
...
@@ -4531,7 +4531,7 @@ static int generateSampleFromCsvForStb(
...
@@ -4531,7 +4531,7 @@ static int generateSampleFromCsvForStb(
line
,
readLen
);
line
,
readLen
);
getRows
++
;
getRows
++
;
if
(
getRows
==
MAX_SAMPLES
_ONCE_FROM_FILE
)
{
if
(
getRows
==
MAX_SAMPLES
)
{
break
;
break
;
}
}
}
}
...
@@ -6105,7 +6105,7 @@ static int getRowDataFromSample(
...
@@ -6105,7 +6105,7 @@ static int getRowDataFromSample(
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
SSuperTable
*
stbInfo
,
int64_t
*
sampleUsePos
)
SSuperTable
*
stbInfo
,
int64_t
*
sampleUsePos
)
{
{
if
((
*
sampleUsePos
)
==
MAX_SAMPLES
_ONCE_FROM_FILE
)
{
if
((
*
sampleUsePos
)
==
MAX_SAMPLES
)
{
*
sampleUsePos
=
0
;
*
sampleUsePos
=
0
;
}
}
...
@@ -6361,7 +6361,7 @@ static int generateSampleFromRand(
...
@@ -6361,7 +6361,7 @@ static int generateSampleFromRand(
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
_ONCE_FROM_FILE
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
;
i
++
)
{
uint64_t
pos
=
0
;
uint64_t
pos
=
0
;
memset
(
buff
,
0
,
lenOfOneRow
);
memset
(
buff
,
0
,
lenOfOneRow
);
...
@@ -6468,11 +6468,11 @@ static int generateSampleFromRandForStb(SSuperTable *stbInfo)
...
@@ -6468,11 +6468,11 @@ static int generateSampleFromRandForStb(SSuperTable *stbInfo)
}
}
static
int
prepareSampleForNtb
()
{
static
int
prepareSampleForNtb
()
{
g_sampleDataBuf
=
calloc
(
g_args
.
lenOfOneRow
*
MAX_SAMPLES
_ONCE_FROM_FILE
,
1
);
g_sampleDataBuf
=
calloc
(
g_args
.
lenOfOneRow
*
MAX_SAMPLES
,
1
);
if
(
NULL
==
g_sampleDataBuf
)
{
if
(
NULL
==
g_sampleDataBuf
)
{
errorPrint2
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
errorPrint2
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
g_args
.
lenOfOneRow
*
MAX_SAMPLES
_ONCE_FROM_FILE
,
g_args
.
lenOfOneRow
*
MAX_SAMPLES
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -6483,11 +6483,11 @@ static int prepareSampleForNtb() {
...
@@ -6483,11 +6483,11 @@ static int prepareSampleForNtb() {
static
int
prepareSampleForStb
(
SSuperTable
*
stbInfo
)
{
static
int
prepareSampleForStb
(
SSuperTable
*
stbInfo
)
{
stbInfo
->
sampleDataBuf
=
calloc
(
stbInfo
->
sampleDataBuf
=
calloc
(
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
_ONCE_FROM_FILE
,
1
);
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
,
1
);
if
(
NULL
==
stbInfo
->
sampleDataBuf
)
{
if
(
NULL
==
stbInfo
->
sampleDataBuf
)
{
errorPrint2
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
errorPrint2
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
_ONCE_FROM_FILE
,
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -7675,7 +7675,7 @@ static int execBindParamBatch(
...
@@ -7675,7 +7675,7 @@ static int execBindParamBatch(
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
uint32_t
columnCount
=
(
stbInfo
)
?
pThreadInfo
->
stbInfo
->
columnCount
:
g_args
.
columnCount
;
uint32_t
columnCount
=
(
stbInfo
)
?
pThreadInfo
->
stbInfo
->
columnCount
:
g_args
.
columnCount
;
uint32_t
thisBatch
=
MAX_SAMPLES
_ONCE_FROM_FILE
-
(
*
pSamplePos
);
uint32_t
thisBatch
=
MAX_SAMPLES
-
(
*
pSamplePos
);
if
(
thisBatch
>
batch
)
{
if
(
thisBatch
>
batch
)
{
thisBatch
=
batch
;
thisBatch
=
batch
;
...
@@ -7845,7 +7845,7 @@ static int execBindParamBatch(
...
@@ -7845,7 +7845,7 @@ static int execBindParamBatch(
recordFrom
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES
_ONCE_FROM_FILE
)
{
if
((
*
pSamplePos
)
==
MAX_SAMPLES
)
{
*
pSamplePos
=
0
;
*
pSamplePos
=
0
;
}
}
...
@@ -7900,57 +7900,57 @@ static int parseSamplefileToStmtBatch(
...
@@ -7900,57 +7900,57 @@ static int parseSamplefileToStmtBatch(
switch
(
data_type
)
{
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
tmpP
=
calloc
(
1
,
sizeof
(
int
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int16_t
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int16_t
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
tmpP
=
calloc
(
1
,
sizeof
(
float
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
float
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
tmpP
=
calloc
(
1
,
sizeof
(
double
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
double
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
tmpP
=
calloc
(
1
,
MAX_SAMPLES
_ONCE_FROM_FILE
*
tmpP
=
calloc
(
1
,
MAX_SAMPLES
*
(((
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataLen
:
g_args
.
binwidth
)));
(((
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataLen
:
g_args
.
binwidth
)));
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES
);
assert
(
tmpP
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
break
;
...
@@ -7965,7 +7965,7 @@ static int parseSamplefileToStmtBatch(
...
@@ -7965,7 +7965,7 @@ static int parseSamplefileToStmtBatch(
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
_ONCE_FROM_FILE
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
;
i
++
)
{
int
cursor
=
0
;
int
cursor
=
0
;
for
(
int
c
=
0
;
c
<
columnCount
;
c
++
)
{
for
(
int
c
=
0
;
c
<
columnCount
;
c
++
)
{
...
@@ -8105,11 +8105,11 @@ static int parseSampleToStmt(
...
@@ -8105,11 +8105,11 @@ static int parseSampleToStmt(
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
{
{
pThreadInfo
->
sampleBindArray
=
pThreadInfo
->
sampleBindArray
=
calloc
(
1
,
sizeof
(
char
*
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
calloc
(
1
,
sizeof
(
char
*
)
*
MAX_SAMPLES
);
if
(
pThreadInfo
->
sampleBindArray
==
NULL
)
{
if
(
pThreadInfo
->
sampleBindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %"
PRIu64
" bind array buffer
\n
"
,
errorPrint2
(
"%s() LN%d, Failed to allocate %"
PRIu64
" bind array buffer
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
(
uint64_t
)
sizeof
(
char
*
)
*
MAX_SAMPLES
_ONCE_FROM_FILE
);
(
uint64_t
)
sizeof
(
char
*
)
*
MAX_SAMPLES
);
return
-
1
;
return
-
1
;
}
}
...
@@ -8117,7 +8117,7 @@ static int parseSampleToStmt(
...
@@ -8117,7 +8117,7 @@ static int parseSampleToStmt(
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
_ONCE_FROM_FILE
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SAMPLES
;
i
++
)
{
char
*
bindArray
=
char
*
bindArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
columnCount
+
1
));
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
if
(
bindArray
==
NULL
)
{
...
@@ -8282,7 +8282,7 @@ static uint32_t execBindParam(
...
@@ -8282,7 +8282,7 @@ static uint32_t execBindParam(
recordFrom
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES
_ONCE_FROM_FILE
)
{
if
((
*
pSamplePos
)
==
MAX_SAMPLES
)
{
*
pSamplePos
=
0
;
*
pSamplePos
=
0
;
}
}
...
@@ -9416,7 +9416,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -9416,7 +9416,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
#else
#else
tmfree
((
char
*
)
pThreadInfo
->
bind_ts
);
tmfree
((
char
*
)
pThreadInfo
->
bind_ts
);
if
(
pThreadInfo
->
sampleBindArray
)
{
if
(
pThreadInfo
->
sampleBindArray
)
{
for
(
int
k
=
0
;
k
<
MAX_SAMPLES
_ONCE_FROM_FILE
;
k
++
)
{
for
(
int
k
=
0
;
k
<
MAX_SAMPLES
;
k
++
)
{
uintptr_t
*
tmp
=
(
uintptr_t
*
)(
*
(
uintptr_t
*
)(
uintptr_t
*
tmp
=
(
uintptr_t
*
)(
*
(
uintptr_t
*
)(
pThreadInfo
->
sampleBindArray
pThreadInfo
->
sampleBindArray
+
sizeof
(
uintptr_t
*
)
*
k
));
+
sizeof
(
uintptr_t
*
)
*
k
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录