未验证 提交 ad073f16 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

[TD-3636]<fix>: fix taosdemo outorder range algorithm. (#5736)

patch for master.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 590b9015
......@@ -4520,22 +4520,23 @@ static int generateDataTail(char *tableName, int32_t tableSeq,
pSamplePos);
} else if (0 == strncasecmp(superTblInfo->dataSource,
"rand", strlen("rand"))) {
int rand_num = taosRandom() % 100;
if (0 != superTblInfo->disorderRatio
int rand_num = taosRandom() % 100;
int randTail;
if (0 != superTblInfo->disorderRatio
&& rand_num < superTblInfo->disorderRatio) {
int64_t d = startTime
+ superTblInfo->timeStampStep * k
- taosRandom() % superTblInfo->disorderRange;
retLen = generateRowData(
randTail = (superTblInfo->timeStampStep * k
+ (taosRandom() % superTblInfo->disorderRange + 1)) * (-1);
debugPrint("rand data generated, back %d\n", randTail);
} else {
randTail = superTblInfo->timeStampStep * k;
}
uint64_t d = startTime
+ randTail;
retLen = generateRowData(
data,
d,
superTblInfo);
} else {
retLen = generateRowData(
data,
startTime + superTblInfo->timeStampStep * k,
superTblInfo);
}
}
if (retLen > remainderBufLen) {
......@@ -4551,20 +4552,21 @@ static int generateDataTail(char *tableName, int32_t tableSeq,
int lenOfBinary = g_args.len_of_binary;
int rand_num = taosRandom() % 100;
int randTail;
if ((g_args.disorderRatio != 0)
&& (rand_num < g_args.disorderRatio)) {
int64_t d = startTime + DEFAULT_TIMESTAMP_STEP * k
- taosRandom() % g_args.disorderRange;
retLen = generateData(data, data_type,
ncols_per_record, d, lenOfBinary);
randTail = (DEFAULT_TIMESTAMP_STEP * k
+ (taosRandom() % g_args.disorderRange + 1)) * (-1);
debugPrint("rand data generated, back %d\n", randTail);
} else {
retLen = generateData(data, data_type,
randTail = DEFAULT_TIMESTAMP_STEP * k;
}
retLen = generateData(data, data_type,
ncols_per_record,
startTime + DEFAULT_TIMESTAMP_STEP * k,
startTime + randTail,
lenOfBinary);
}
if (len > remainderBufLen)
break;
......@@ -5106,7 +5108,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
int rand_num = taosRandom() % 100;
if (0 != winfo->superTblInfo->disorderRatio
&& rand_num < winfo->superTblInfo->disorderRatio) {
int64_t d = winfo->lastTs - taosRandom() % winfo->superTblInfo->disorderRange;
int64_t d = winfo->lastTs - (taosRandom() % winfo->superTblInfo->disorderRange + 1);
generateRowData(data, d, winfo->superTblInfo);
} else {
generateRowData(data, winfo->lastTs += 1000, winfo->superTblInfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册