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