Feature/sangshuduo/td 3317 taosdemo interlace (#5596)
* [TD-3316] <fix>: add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] <fix>: add testcase for taosdemo limit and offset. fix sample file import bug. * [TD-3316] <fix>: add test case for limit and offset. fix sample data issue. * [TD-3327] <fix>: fix taosdemo segfault when import data from sample data file. * [TD-3317] <feature>: make taosdemo support interlace mode. json parameter rows_per_tbl support. * [TD-3317] <feature>: support interlace mode. refactor * [TD-3317] <feature>: support interlace mode. refactor * [TD-3317] <feature>: support interlace mode insertion. refactor. * [TD-3317] <feature>: support interlace mode insertion. change json file. * [TD-3317] <feature>: support interlace mode insertion. fix multithread create table regression. * [TD-3317] <feature>: support interlace mode insertion. working but not perfect. * [TD-3317] <feature>: support interlace mode insertion. rename lowaTest with taosdemoTestWithJson * [TD-3317] <feature>: support interlace mode insertion. perfect * [TD-3317] <feature>: support interlace mode insertion. cleanup. * [TD-3317] <feature>: support interlace mode insertion. adjust algorithm of loop times. * [TD-3317] <feature>: support interlace mode insertion. fix delay time bug. * [TD-3317] <feature>: support interlace mode insertion. fix progressive timestamp bug. * [TD-3317] <feature>: support interlace mode insertion. add an option for performance print. * [TD-3317] <feature>: support interlace mode insertion. change json test case with less table for acceleration. * [TD-3317] <feature>: support interlace mode insertion. change progressive mode timestamp step and testcase. * [TD-3197] <fix>: fix taosdemo coverity scan issues. * [TD-3197] <fix>: fix taosdemo coverity scan issue. fix subscribeTest pids uninitialized. * [TD-3317] <feature>: support interlace mode insertion. add time shift for no sleep time. * [TD-3317] <feature>: support interlace insert. rework timestamp. * [TD-3317] <feature>: support interlace mode insertion. change rows_per_tbl to interlace_rows. * [TD-3317] <feature>: taosdemo suppoert interlace mode. remove trailing spaces. * [TD-3317] <feature>: taosdemo support interlace insertion. prompt if interlace > num_of_records_per_req Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
cb4ca3a563
commit
2c4bcbe306
|
@ -696,6 +696,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
}
|
||||
taos_options(TSDB_OPTION_CONFIGDIR, full_path.we_wordv[0]);
|
||||
wordfree(&full_path);
|
||||
|
||||
} else if (strcmp(argv[i], "-h") == 0) {
|
||||
arguments->host = argv[++i];
|
||||
} else if (strcmp(argv[i], "-p") == 0) {
|
||||
|
@ -940,13 +941,15 @@ static void getResult(TAOS_RES *res, char* resultFileName) {
|
|||
if (resultFileName[0] != 0) {
|
||||
fp = fopen(resultFileName, "at");
|
||||
if (fp == NULL) {
|
||||
errorPrint("%s() LN%d, failed to open result file: %s, result will not save to file\n", __func__, __LINE__, resultFileName);
|
||||
errorPrint("%s() LN%d, failed to open result file: %s, result will not save to file\n",
|
||||
__func__, __LINE__, resultFileName);
|
||||
}
|
||||
}
|
||||
|
||||
char* databuf = (char*) calloc(1, 100*1024*1024);
|
||||
if (databuf == NULL) {
|
||||
errorPrint("%s() LN%d, failed to malloc, warning: save result to file slowly!\n", __func__, __LINE__);
|
||||
errorPrint("%s() LN%d, failed to malloc, warning: save result to file slowly!\n",
|
||||
__func__, __LINE__);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
return ;
|
||||
|
@ -1030,7 +1033,6 @@ static int64_t rand_bigint(){
|
|||
cursor++;
|
||||
cursor = cursor % MAX_PREPARED_RAND;
|
||||
return randbigint[cursor];
|
||||
|
||||
}
|
||||
|
||||
static float rand_float(){
|
||||
|
@ -1111,7 +1113,7 @@ static int printfInsertMeta() {
|
|||
printf(" database[%d] name: \033[33m%s\033[0m\n", i, g_Dbs.db[i].dbName);
|
||||
if (0 == g_Dbs.db[i].drop) {
|
||||
printf(" drop: \033[33mno\033[0m\n");
|
||||
}else {
|
||||
} else {
|
||||
printf(" drop: \033[33myes\033[0m\n");
|
||||
}
|
||||
|
||||
|
@ -1739,7 +1741,6 @@ static void printfQuerySystemInfo(TAOS * taos) {
|
|||
}
|
||||
|
||||
free(dbInfos);
|
||||
|
||||
}
|
||||
|
||||
static int postProceSql(char* host, uint16_t port, char* sqlstr)
|
||||
|
@ -3088,6 +3089,17 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
|||
cJSON* interlaceRows = cJSON_GetObjectItem(root, "interlace_rows");
|
||||
if (interlaceRows && interlaceRows->type == cJSON_Number) {
|
||||
g_args.interlace_rows = interlaceRows->valueint;
|
||||
|
||||
// rows per table need be less than insert batch
|
||||
if (g_args.interlace_rows > g_args.num_of_RPR) {
|
||||
printf("NOTICE: interlace rows value %d > num_of_records_per_request %d\n\n",
|
||||
g_args.interlace_rows, g_args.num_of_RPR);
|
||||
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
|
||||
g_args.num_of_RPR);
|
||||
printf(" press Enter key to continue or Ctrl+C to stop.");
|
||||
(void)getchar();
|
||||
g_args.interlace_rows = g_args.num_of_RPR;
|
||||
}
|
||||
} else if (!interlaceRows) {
|
||||
g_args.interlace_rows = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
|
||||
} else {
|
||||
|
@ -3105,7 +3117,6 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
|||
goto PARSE_OVER;
|
||||
}
|
||||
|
||||
|
||||
cJSON* numRecPerReq = cJSON_GetObjectItem(root, "num_of_records_per_req");
|
||||
if (numRecPerReq && numRecPerReq->type == cJSON_Number) {
|
||||
g_args.num_of_RPR = numRecPerReq->valueint;
|
||||
|
@ -3412,13 +3423,15 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
|||
} else if (!childTblExists) {
|
||||
g_Dbs.db[i].superTbls[j].childTblExists = TBL_NO_EXISTS;
|
||||
} else {
|
||||
errorPrint("%s() LN%d, failed to read json, child_table_exists not found\n", __func__, __LINE__);
|
||||
errorPrint("%s() LN%d, failed to read json, child_table_exists not found\n",
|
||||
__func__, __LINE__);
|
||||
goto PARSE_OVER;
|
||||
}
|
||||
|
||||
cJSON* count = cJSON_GetObjectItem(stbInfo, "childtable_count");
|
||||
if (!count || count->type != cJSON_Number || 0 >= count->valueint) {
|
||||
errorPrint("%s() LN%d, failed to read json, childtable_count not found\n", __func__, __LINE__);
|
||||
errorPrint("%s() LN%d, failed to read json, childtable_count not found\n",
|
||||
__func__, __LINE__);
|
||||
goto PARSE_OVER;
|
||||
}
|
||||
g_Dbs.db[i].superTbls[j].childTblCount = count->valueint;
|
||||
|
@ -3505,7 +3518,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
|||
}
|
||||
|
||||
cJSON *sampleFormat = cJSON_GetObjectItem(stbInfo, "sample_format");
|
||||
if (sampleFormat && sampleFormat->type == cJSON_String && sampleFormat->valuestring != NULL) {
|
||||
if (sampleFormat && sampleFormat->type
|
||||
== cJSON_String && sampleFormat->valuestring != NULL) {
|
||||
tstrncpy(g_Dbs.db[i].superTbls[j].sampleFormat,
|
||||
sampleFormat->valuestring, MAX_DB_NAME_SIZE);
|
||||
} else if (!sampleFormat) {
|
||||
|
@ -3579,6 +3593,16 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
|||
cJSON* interlaceRows = cJSON_GetObjectItem(stbInfo, "interlace_rows");
|
||||
if (interlaceRows && interlaceRows->type == cJSON_Number) {
|
||||
g_Dbs.db[i].superTbls[j].interlaceRows = interlaceRows->valueint;
|
||||
// rows per table need be less than insert batch
|
||||
if (g_Dbs.db[i].superTbls[j].interlaceRows > g_args.num_of_RPR) {
|
||||
printf("NOTICE: db[%d].superTbl[%d]'s interlace rows value %d > num_of_records_per_request %d\n\n",
|
||||
i, j, g_Dbs.db[i].superTbls[j].interlaceRows, g_args.num_of_RPR);
|
||||
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
|
||||
g_args.num_of_RPR);
|
||||
printf(" press Enter key to continue or Ctrl+C to stop.");
|
||||
(void)getchar();
|
||||
g_Dbs.db[i].superTbls[j].interlaceRows = g_args.num_of_RPR;
|
||||
}
|
||||
} else if (!interlaceRows) {
|
||||
g_Dbs.db[i].superTbls[j].interlaceRows = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
|
||||
} else {
|
||||
|
@ -4489,6 +4513,18 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
|||
pThreadInfo->threadID, __func__, __LINE__);
|
||||
|
||||
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
|
||||
int interlaceRows = superTblInfo?superTblInfo->interlaceRows:g_args.interlace_rows;
|
||||
|
||||
int insertMode;
|
||||
|
||||
if (interlaceRows > 0) {
|
||||
insertMode = INTERLACE_INSERT_MODE;
|
||||
} else {
|
||||
insertMode = PROGRESSIVE_INSERT_MODE;
|
||||
}
|
||||
|
||||
// TODO: prompt tbl count multple interlace rows and batch
|
||||
//
|
||||
|
||||
char* buffer = calloc(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, 1);
|
||||
if (NULL == buffer) {
|
||||
|
@ -4498,21 +4534,9 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int insertMode;
|
||||
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
|
||||
int interlaceRows = superTblInfo?superTblInfo->interlaceRows:g_args.interlace_rows;
|
||||
|
||||
if (interlaceRows > 0) {
|
||||
insertMode = INTERLACE_INSERT_MODE;
|
||||
} else {
|
||||
insertMode = PROGRESSIVE_INSERT_MODE;
|
||||
}
|
||||
|
||||
// rows per table need be less than insert batch
|
||||
if (interlaceRows > g_args.num_of_RPR)
|
||||
interlaceRows = g_args.num_of_RPR;
|
||||
|
||||
pThreadInfo->totalInsertRows = 0;
|
||||
pThreadInfo->totalAffectedRows = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue