[td-225]update the taosdemo
This commit is contained in:
parent
fb0b115212
commit
ae325bddd5
|
@ -535,11 +535,11 @@ SArguments g_args = {
|
||||||
"127.0.0.1", // host
|
"127.0.0.1", // host
|
||||||
6030, // port
|
6030, // port
|
||||||
"root", // user
|
"root", // user
|
||||||
#ifdef _TD_POWER_
|
#ifdef _TD_POWER_
|
||||||
"powerdb", // password
|
"powerdb", // password
|
||||||
#else
|
#else
|
||||||
"taosdata", // password
|
"taosdata", // password
|
||||||
#endif
|
#endif
|
||||||
"test", // database
|
"test", // database
|
||||||
1, // replica
|
1, // replica
|
||||||
"t", // tb_prefix
|
"t", // tb_prefix
|
||||||
|
@ -554,19 +554,13 @@ SArguments g_args = {
|
||||||
"./output.txt", // output_file
|
"./output.txt", // output_file
|
||||||
0, // mode : sync or async
|
0, // mode : sync or async
|
||||||
{
|
{
|
||||||
"TINYINT", // datatype
|
"INT", // datatype
|
||||||
"SMALLINT",
|
"INT", // datatype
|
||||||
"INT",
|
"INT", // datatype
|
||||||
"BIGINT",
|
"INT", // datatype
|
||||||
"FLOAT",
|
|
||||||
"DOUBLE",
|
|
||||||
"BINARY",
|
|
||||||
"NCHAR",
|
|
||||||
"BOOL",
|
|
||||||
"TIMESTAMP"
|
|
||||||
},
|
},
|
||||||
16, // len_of_binary
|
16, // len_of_binary
|
||||||
10, // num_of_CPR
|
4, // num_of_CPR
|
||||||
10, // num_of_connections/thread
|
10, // num_of_connections/thread
|
||||||
0, // insert_interval
|
0, // insert_interval
|
||||||
1, // query_times
|
1, // query_times
|
||||||
|
@ -723,9 +717,19 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
if (strcmp(argv[i], "-f") == 0) {
|
if (strcmp(argv[i], "-f") == 0) {
|
||||||
arguments->metaFile = argv[++i];
|
arguments->metaFile = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-c") == 0) {
|
} else if (strcmp(argv[i], "-c") == 0) {
|
||||||
tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN);
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-c need a valid path following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
tstrncpy(configDir, argv[++i], MAX_FILE_NAME_LEN);
|
||||||
|
|
||||||
} else if (strcmp(argv[i], "-h") == 0) {
|
} else if (strcmp(argv[i], "-h") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-h need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->host = argv[++i];
|
arguments->host = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-p") == 0) {
|
} else if (strcmp(argv[i], "-p") == 0) {
|
||||||
if ((argc == i+1) ||
|
if ((argc == i+1) ||
|
||||||
|
@ -736,12 +740,32 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->port = atoi(argv[++i]);
|
arguments->port = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-u") == 0) {
|
} else if (strcmp(argv[i], "-u") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-u need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->user = argv[++i];
|
arguments->user = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-P") == 0) {
|
} else if (strcmp(argv[i], "-P") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-P need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->password = argv[++i];
|
arguments->password = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-o") == 0) {
|
} else if (strcmp(argv[i], "-o") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-o need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->output_file = argv[++i];
|
arguments->output_file = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-s") == 0) {
|
} else if (strcmp(argv[i], "-s") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-s need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->sqlFile = argv[++i];
|
arguments->sqlFile = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-q") == 0) {
|
} else if (strcmp(argv[i], "-q") == 0) {
|
||||||
if ((argc == i+1) ||
|
if ((argc == i+1) ||
|
||||||
|
@ -768,8 +792,20 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->insert_interval = atoi(argv[++i]);
|
arguments->insert_interval = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-qt") == 0) {
|
} else if (strcmp(argv[i], "-qt") == 0) {
|
||||||
|
if ((argc == i+1) ||
|
||||||
|
(!isStringNumber(argv[i+1]))) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-qt need a number following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->query_times = atoi(argv[++i]);
|
arguments->query_times = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-B") == 0) {
|
} else if (strcmp(argv[i], "-B") == 0) {
|
||||||
|
if ((argc == i+1) ||
|
||||||
|
(!isStringNumber(argv[i+1]))) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-B need a number following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->interlace_rows = atoi(argv[++i]);
|
arguments->interlace_rows = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-r") == 0) {
|
} else if (strcmp(argv[i], "-r") == 0) {
|
||||||
if ((argc == i+1) ||
|
if ((argc == i+1) ||
|
||||||
|
@ -796,6 +832,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->num_of_DPT = atoi(argv[++i]);
|
arguments->num_of_DPT = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-d") == 0) {
|
} else if (strcmp(argv[i], "-d") == 0) {
|
||||||
|
if (argc == i+1) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-d need a valid string following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->database = argv[++i];
|
arguments->database = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-l") == 0) {
|
} else if (strcmp(argv[i], "-l") == 0) {
|
||||||
if ((argc == i+1) ||
|
if ((argc == i+1) ||
|
||||||
|
@ -861,6 +902,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
||||||
}
|
}
|
||||||
arguments->len_of_binary = atoi(argv[++i]);
|
arguments->len_of_binary = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-m") == 0) {
|
} else if (strcmp(argv[i], "-m") == 0) {
|
||||||
|
if ((argc == i+1) ||
|
||||||
|
(!isStringNumber(argv[i+1]))) {
|
||||||
|
printHelp();
|
||||||
|
errorPrint("%s", "\n\t-m need a number following!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
arguments->tb_prefix = argv[++i];
|
arguments->tb_prefix = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-N") == 0) {
|
} else if (strcmp(argv[i], "-N") == 0) {
|
||||||
arguments->use_metric = false;
|
arguments->use_metric = false;
|
||||||
|
@ -2395,8 +2442,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int createSuperTable(TAOS * taos, char* dbName,
|
static int createSuperTable(
|
||||||
|
TAOS * taos, char* dbName,
|
||||||
SSuperTable* superTbl) {
|
SSuperTable* superTbl) {
|
||||||
|
|
||||||
char command[BUFFER_SIZE] = "\0";
|
char command[BUFFER_SIZE] = "\0";
|
||||||
|
|
||||||
char cols[STRING_LEN] = "\0";
|
char cols[STRING_LEN] = "\0";
|
||||||
|
@ -2885,19 +2934,17 @@ static void createChildTables() {
|
||||||
} else {
|
} else {
|
||||||
// normal table
|
// normal table
|
||||||
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP");
|
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP");
|
||||||
int j = 0;
|
for (int j = 0; j < g_args.num_of_CPR; j++) {
|
||||||
while(g_args.datatype[j]) {
|
|
||||||
if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
|
if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
|
||||||
|| (strncasecmp(g_args.datatype[j],
|
|| (strncasecmp(g_args.datatype[j],
|
||||||
"NCHAR", strlen("NCHAR")) == 0)) {
|
"NCHAR", strlen("NCHAR")) == 0)) {
|
||||||
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
|
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
|
||||||
", COL%d %s(60)", j, g_args.datatype[j]);
|
", COL%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary);
|
||||||
} else {
|
} else {
|
||||||
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
|
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
|
||||||
", COL%d %s", j, g_args.datatype[j]);
|
", COL%d %s", j, g_args.datatype[j]);
|
||||||
}
|
}
|
||||||
len = strlen(tblColsBuf);
|
len = strlen(tblColsBuf);
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
|
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
|
||||||
|
@ -3209,7 +3256,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3610,6 +3657,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
cJSON* batchCreateTbl = cJSON_GetObjectItem(stbInfo, "batch_create_tbl_num");
|
cJSON* batchCreateTbl = cJSON_GetObjectItem(stbInfo, "batch_create_tbl_num");
|
||||||
if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) {
|
if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) {
|
||||||
g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint;
|
g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint;
|
||||||
|
@ -3619,6 +3667,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
printf("ERROR: failed to read json, batch_create_tbl_num not found\n");
|
printf("ERROR: failed to read json, batch_create_tbl_num not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
cJSON *childTblExists = cJSON_GetObjectItem(stbInfo, "child_table_exists"); // yes, no
|
cJSON *childTblExists = cJSON_GetObjectItem(stbInfo, "child_table_exists"); // yes, no
|
||||||
if (childTblExists
|
if (childTblExists
|
||||||
|
@ -3877,7 +3926,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4261,7 +4310,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4322,7 +4371,7 @@ static bool getInfoFromJsonFile(char* file) {
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
free(content);
|
free(content);
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -4477,7 +4526,7 @@ static int32_t generateData(char *recBuf, char **data_type,
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < num_of_cols; i++) {
|
for (int i = 0; i < c; i++) {
|
||||||
if (strcasecmp(data_type[i % c], "tinyint") == 0) {
|
if (strcasecmp(data_type[i % c], "tinyint") == 0) {
|
||||||
pstr += sprintf(pstr, ", %d", rand_tinyint() );
|
pstr += sprintf(pstr, ", %d", rand_tinyint() );
|
||||||
} else if (strcasecmp(data_type[i % c], "smallint") == 0) {
|
} else if (strcasecmp(data_type[i % c], "smallint") == 0) {
|
||||||
|
@ -4499,7 +4548,7 @@ static int32_t generateData(char *recBuf, char **data_type,
|
||||||
rand_string(s, lenOfBinary);
|
rand_string(s, lenOfBinary);
|
||||||
pstr += sprintf(pstr, ", \"%s\"", s);
|
pstr += sprintf(pstr, ", \"%s\"", s);
|
||||||
free(s);
|
free(s);
|
||||||
}else if (strcasecmp(data_type[i % c], "nchar") == 0) {
|
} else if (strcasecmp(data_type[i % c], "nchar") == 0) {
|
||||||
char *s = malloc(lenOfBinary);
|
char *s = malloc(lenOfBinary);
|
||||||
rand_string(s, lenOfBinary);
|
rand_string(s, lenOfBinary);
|
||||||
pstr += sprintf(pstr, ", \"%s\"", s);
|
pstr += sprintf(pstr, ", \"%s\"", s);
|
||||||
|
@ -4683,7 +4732,7 @@ static int generateDataTail(
|
||||||
if (len > remainderBufLen)
|
if (len > remainderBufLen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pstr += sprintf(pstr, " %s", data);
|
pstr += sprintf(pstr, "%s", data);
|
||||||
k++;
|
k++;
|
||||||
len += retLen;
|
len += retLen;
|
||||||
remainderBufLen -= retLen;
|
remainderBufLen -= retLen;
|
||||||
|
@ -5084,7 +5133,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free_and_statistics_interlace:
|
free_and_statistics_interlace:
|
||||||
tmfree(buffer);
|
tmfree(buffer);
|
||||||
|
|
||||||
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
|
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
|
||||||
|
@ -5230,7 +5279,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
|
||||||
}
|
}
|
||||||
} // tableSeq
|
} // tableSeq
|
||||||
|
|
||||||
free_and_statistics_2:
|
free_and_statistics_2:
|
||||||
tmfree(buffer);
|
tmfree(buffer);
|
||||||
|
|
||||||
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
|
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
|
||||||
|
@ -5419,9 +5468,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
if (superTblInfo) {
|
if (superTblInfo) {
|
||||||
int limit, offset;
|
int limit, offset;
|
||||||
|
|
||||||
if ((superTblInfo->childTblExists == TBL_NO_EXISTS) &&
|
if ((NULL != g_args.sqlFile) && (superTblInfo->childTblExists == TBL_NO_EXISTS) &&
|
||||||
((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
|
((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
|
||||||
printf("WARNING: offset and limit will not be used since the child tables are not exists!\n");
|
printf("WARNING: offset and limit will not be used since the child tables not exists!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS)
|
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS)
|
||||||
|
|
Loading…
Reference in New Issue