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

Hotfix/sangshuduo/td 6294 taosdemo long arg for master (#7609)

* [TD-6294]<fix>: taosdemo support long arg

fix conflict with develop branch.

* fix few words.

* declare default child tables number.
上级 86b93ad1
...@@ -75,6 +75,8 @@ extern char configDir[]; ...@@ -75,6 +75,8 @@ extern char configDir[];
#define OPT_ABORT 1 /* –abort */ #define OPT_ABORT 1 /* –abort */
#define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255. #define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255.
#define DEFAULT_START_TIME 1500000000000
#define MAX_PREPARED_RAND 1000000 #define MAX_PREPARED_RAND 1000000
#define INT_BUFF_LEN 11 #define INT_BUFF_LEN 11
#define BIGINT_BUFF_LEN 21 #define BIGINT_BUFF_LEN 21
...@@ -102,8 +104,11 @@ extern char configDir[]; ...@@ -102,8 +104,11 @@ extern char configDir[];
#define NOTE_BUFF_LEN (SMALL_BUFF_LEN*16) #define NOTE_BUFF_LEN (SMALL_BUFF_LEN*16)
#define DEFAULT_TIMESTAMP_STEP 1 #define DEFAULT_TIMESTAMP_STEP 1
#define DEFAULT_INTERLACE_ROWS 0
#define DEFAULT_DATATYPE_NUM 3
#define DEFAULT_CHILDTABLES 10000 #define DEFAULT_CHILDTABLES 10000
enum TEST_MODE { enum TEST_MODE {
INSERT_TEST, // 0 INSERT_TEST, // 0
QUERY_TEST, // 1 QUERY_TEST, // 1
...@@ -201,9 +206,9 @@ enum _describe_table_index { ...@@ -201,9 +206,9 @@ enum _describe_table_index {
static char *g_dupstr = NULL; static char *g_dupstr = NULL;
typedef struct SArguments_S { typedef struct SArguments_S {
char * metaFile; char *metaFile;
uint32_t test_mode; uint32_t test_mode;
char * host; char *host;
uint16_t port; uint16_t port;
uint16_t iface; uint16_t iface;
char * user; char * user;
...@@ -222,7 +227,7 @@ typedef struct SArguments_S { ...@@ -222,7 +227,7 @@ typedef struct SArguments_S {
char * output_file; char * output_file;
bool async_mode; bool async_mode;
char * datatype[MAX_NUM_COLUMNS + 1]; char * datatype[MAX_NUM_COLUMNS + 1];
uint32_t len_of_binary; uint32_t binwidth;
uint32_t num_of_CPR; uint32_t num_of_CPR;
uint32_t num_of_threads; uint32_t num_of_threads;
uint64_t insert_interval; uint64_t insert_interval;
...@@ -363,7 +368,7 @@ typedef struct SDbs_S { ...@@ -363,7 +368,7 @@ typedef struct SDbs_S {
bool asyncMode; bool asyncMode;
uint32_t threadCount; uint32_t threadCount;
uint32_t threadCountByCreateTbl; uint32_t threadCountForCreateTbl;
uint32_t dbCount; uint32_t dbCount;
SDataBase db[MAX_DB_COUNT]; SDataBase db[MAX_DB_COUNT];
...@@ -582,12 +587,10 @@ char *g_randdouble_buff = NULL; ...@@ -582,12 +587,10 @@ char *g_randdouble_buff = NULL;
char *g_aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)", char *g_aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)",
"max(col0)", "min(col0)", "first(col0)", "last(col0)"}; "max(col0)", "min(col0)", "first(col0)", "last(col0)"};
#define DEFAULT_DATATYPE_NUM 3
SArguments g_args = { SArguments g_args = {
NULL, // metaFile NULL, // metaFile
0, // test_mode 0, // test_mode
"127.0.0.1", // host "localhost", // host
6030, // port 6030, // port
INTERFACE_BUT, // iface INTERFACE_BUT, // iface
"root", // user "root", // user
...@@ -616,13 +619,13 @@ SArguments g_args = { ...@@ -616,13 +619,13 @@ SArguments g_args = {
"INT", // datatype "INT", // datatype
"FLOAT", // datatype. DEFAULT_DATATYPE_NUM is 3 "FLOAT", // datatype. DEFAULT_DATATYPE_NUM is 3
}, },
64, // len_of_binary 64, // binwidth
4, // num_of_CPR 4, // num_of_CPR
10, // num_of_connections/thread 10, // num_of_connections/thread
0, // insert_interval 0, // insert_interval
DEFAULT_TIMESTAMP_STEP, // timestamp_step DEFAULT_TIMESTAMP_STEP, // timestamp_step
1, // query_times 1, // query_times
0, // interlace_rows; DEFAULT_INTERLACE_ROWS, // interlace_rows;
30000, // num_of_RPR 30000, // num_of_RPR
(1024*1024), // max_sql_len (1024*1024), // max_sql_len
DEFAULT_CHILDTABLES, // num_of_tables DEFAULT_CHILDTABLES, // num_of_tables
...@@ -636,8 +639,6 @@ SArguments g_args = { ...@@ -636,8 +639,6 @@ SArguments g_args = {
true, // demo_mode; true, // demo_mode;
}; };
static SDbs g_Dbs; static SDbs g_Dbs;
static int64_t g_totalChildTables = DEFAULT_CHILDTABLES; static int64_t g_totalChildTables = DEFAULT_CHILDTABLES;
static int64_t g_actualChildTables = 0; static int64_t g_actualChildTables = 0;
...@@ -720,85 +721,92 @@ static void printVersion() { ...@@ -720,85 +721,92 @@ static void printVersion() {
static void printHelp() { static void printHelp() {
char indent[10] = " "; char indent[10] = " ";
printf("%s%s%s%s\n", indent, "-f", indent, printf("%s\n\n", "Usage: taosdemo [OPTION...]");
printf("%s%s%s%s\n", indent, "-f, --file=FILE", "\t\t",
"The meta file to the execution procedure. Default is './meta.json'."); "The meta file to the execution procedure. Default is './meta.json'.");
printf("%s%s%s%s\n", indent, "-u", indent, printf("%s%s%s%s\n", indent, "-u, --user=USER", "\t\t",
"The TDengine user name to use when connecting to the server. Default is 'root'."); "The user name to use when connecting to the server.");
#ifdef _TD_POWER_ #ifdef _TD_POWER_
printf("%s%s%s%s\n", indent, "-p", indent, printf("%s%s%s%s\n", indent, "-p, --password", "\t\t",
"The password to use when connecting to the server. Default is 'powerdb'."); "The password to use when connecting to the server. Default is 'powerdb'");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t",
"Configuration directory. Default is '/etc/power/'."); "Configuration directory. Default is '/etc/power/'.");
#elif (_TD_TQ_ == true) #elif (_TD_TQ_ == true)
printf("%s%s%s%s\n", indent, "-p", indent, printf("%s%s%s%s\n", indent, "-p, --password", "\t\t",
"The password to use when connecting to the server. Default is 'tqueue'."); "The password to use when connecting to the server. Default is 'tqueue'");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t",
"Configuration directory. Default is '/etc/tq/'."); "Configuration directory. Default is '/etc/tq/'.");
#else #else
printf("%s%s%s%s\n", indent, "-p", indent, printf("%s%s%s%s\n", indent, "-p, --password", "\t\t",
"The password to use when connecting to the server. Default is 'taosdata'."); "The password to use when connecting to the server.");
printf("%s%s%s%s\n", indent, "-c", indent, printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t",
"Configuration directory. Default is '/etc/taos/'."); "Configuration directory.");
#endif #endif
printf("%s%s%s%s\n", indent, "-h", indent, printf("%s%s%s%s\n", indent, "-h, --host=HOST", "\t\t",
"The host to connect to TDengine. Default is localhost."); "TDengine server FQDN to connect. The default host is localhost.");
printf("%s%s%s%s\n", indent, "-P", indent, printf("%s%s%s%s\n", indent, "-P, --port=PORT", "\t\t",
"The TCP/IP port number to use for the connection. Default is 0."); "The TCP/IP port number to use for the connection.");
printf("%s%s%s%s\n", indent, "-I", indent, printf("%s%s%s%s\n", indent, "-I, --interface=INTERFACE", "\t",
"The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."); "The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'.");
printf("%s%s%s%s\n", indent, "-d", indent, printf("%s%s%s%s\n", indent, "-d, --database=DATABASE", "\t",
"Destination database. Default is 'test'."); "Destination database. Default is 'test'.");
printf("%s%s%s%s\n", indent, "-a", indent, printf("%s%s%s%s\n", indent, "-a, --replica=REPLICA", "\t\t",
"Set the replica parameters of the database, Default 1, min: 1, max: 3."); "Set the replica parameters of the database, Default 1, min: 1, max: 3.");
printf("%s%s%s%s\n", indent, "-m", indent, printf("%s%s%s%s\n", indent, "-m, --table-prefix=TABLEPREFIX", "\t",
"Table prefix name. Default is 'd'."); "Table prefix name. Default is 'd'.");
printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file."); printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t", "The select sql file.");
printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag."); printf("%s%s%s%s\n", indent, "-N, --normal-table", "\t\t", "Use normal table flag.");
printf("%s%s%s%s\n", indent, "-o", indent, printf("%s%s%s%s\n", indent, "-o, --output=FILE", "\t\t",
"Direct output to the named file. Default is './output.txt'."); "Direct output to the named file. Default is './output.txt'.");
printf("%s%s%s%s\n", indent, "-q", indent, printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t",
"The select sql file.");
printf("%s%s%s%s\n", indent, "-q, --query-mode=MODE", "\t\t",
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."); "Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
printf("%s%s%s%s\n", indent, "-b", indent, printf("%s%s%s%s\n", indent, "-b, --data-type=DATATYPE", "\t",
"The data_type of columns, default: FLOAT, INT, FLOAT."); "The data_type of columns, default: FLOAT, INT, FLOAT.");
printf("%s%s%s%s%d\n", indent, "-w", indent, printf("%s%s%s%s%d\n", indent, "-w, --binwidth=WIDTH", "\t\t",
"The length of data_type 'BINARY' or 'NCHAR'. Default is ", "The width of data_type 'BINARY' or 'NCHAR'. Default is ",
g_args.len_of_binary); g_args.binwidth);
printf("%s%s%s%s%d%s%d\n", indent, "-l", indent, printf("%s%s%s%s%d%s%d\n", indent, "-l, --columns=COLUMNS", "\t\t",
"The number of columns per record. Demo mode by default is ", "The number of columns per record. Demo mode by default is ",
DEFAULT_DATATYPE_NUM, DEFAULT_DATATYPE_NUM,
" (float, int, float). Max values is ", " (float, int, float). Max values is ",
MAX_NUM_COLUMNS); MAX_NUM_COLUMNS);
printf("%s%s%s%s\n", indent, indent, indent, printf("%s%s%s%s\n", indent, indent, indent,
"All of the new column(s) type is INT. If use -b to specify column type, -l will be ignored."); "\t\t\t\tAll of the new column(s) type is INT. If use -b to specify column type, -l will be ignored.");
printf("%s%s%s%s\n", indent, "-T", indent, printf("%s%s%s%s\n", indent, "-T, --threads=NUMBER", "\t\t",
"The number of threads. Default is 10."); "The number of threads. Default is 10.");
printf("%s%s%s%s\n", indent, "-i", indent, printf("%s%s%s%s\n", indent, "-i, --insert-interval=NUMBER", "\t",
"The sleep time (ms) between insertion. Default is 0."); "The sleep time (ms) between insertion. Default is 0.");
printf("%s%s%s%s%d.\n", indent, "-S", indent, printf("%s%s%s%s%d.\n", indent, "-S, --time-step=TIME_STEP", "\t",
"The timestamp step between insertion. Default is ", "The timestamp step between insertion. Default is ",
DEFAULT_TIMESTAMP_STEP); DEFAULT_TIMESTAMP_STEP);
printf("%s%s%s%s\n", indent, "-r", indent, printf("%s%s%s%s%d.\n", indent, "-B, --interlace-rows=NUMBER", "\t",
"The interlace rows of insertion. Default is ",
DEFAULT_INTERLACE_ROWS);
printf("%s%s%s%s\n", indent, "-r, --rec-per-req=NUMBER", "\t",
"The number of records per request. Default is 30000."); "The number of records per request. Default is 30000.");
printf("%s%s%s%s\n", indent, "-t", indent, printf("%s%s%s%s\n", indent, "-t, --tables=NUMBER", "\t\t",
"The number of tables. Default is 10000."); "The number of tables. Default is 10000.");
printf("%s%s%s%s\n", indent, "-n", indent, printf("%s%s%s%s\n", indent, "-n, --records=NUMBER", "\t\t",
"The number of records per table. Default is 10000."); "The number of records per table. Default is 10000.");
printf("%s%s%s%s\n", indent, "-M", indent, printf("%s%s%s%s\n", indent, "-M, --random", "\t\t\t",
"The value of records generated are totally random."); "The value of records generated are totally random.");
printf("%s%s%s%s\n", indent, indent, indent, printf("%s\n", "\t\t\t\tThe default is to simulate power equipment senario.");
" The default is to simulate power equipment senario."); printf("%s%s%s%s\n", indent, "-x, --no-insert", "\t\t",
printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag."); "No-insert flag.");
printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt."); printf("%s%s%s%s\n", indent, "-y, --answer-yes", "\t\t", "Default input yes for prompt.");
printf("%s%s%s%s\n", indent, "-O", indent, printf("%s%s%s%s\n", indent, "-O, --disorder=NUMBER", "\t\t",
"Insert mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."); "Insert order mode--0: In order, 1 ~ 50: disorder ratio. Default is in order.");
printf("%s%s%s%s\n", indent, "-R", indent, printf("%s%s%s%s\n", indent, "-R, --disorder-range=NUMBER", "\t",
"Out of order data's range, ms, default is 1000."); "Out of order data's range, ms, default is 1000.");
printf("%s%s%s%s\n", indent, "-g", indent, printf("%s%s%s%s\n", indent, "-g, --debug", "\t\t\t",
"Print debug info."); "Print debug info.");
printf("%s%s%s\n", indent, "-V, --version\t", printf("%s%s%s%s\n", indent, "-?, --help\t", "\t\t",
"Print version info."); "Give this help list");
printf("%s%s%s%s\n", indent, "--help\t", indent, printf("%s%s%s%s\n", indent, " --usage\t", "\t\t",
"Print command line arguments list info."); "Give a short usage message");
printf("%s%s\n", indent, "-V, --version\t\t\tPrint version info.");
/* printf("%s%s%s%s\n", indent, "-D", indent, /* printf("%s%s%s%s\n", indent, "-D", indent,
"Delete database if exists. 0: no, 1: yes, default is 1"); "Delete database if exists. 0: no, 1: yes, default is 1");
*/ */
...@@ -819,66 +827,149 @@ static bool isStringNumber(char *input) ...@@ -819,66 +827,149 @@ static bool isStringNumber(char *input)
return true; return true;
} }
static void errorPrintReqArg(char *program, char *wrong_arg)
{
fprintf(stderr,
"%s: option requires an argument -- '%s'\n",
program, wrong_arg);
fprintf(stderr,
"Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void errorPrintReqArg2(char *program, char *wrong_arg)
{
fprintf(stderr,
"%s: option requires a number argument '-%s'\n",
program, wrong_arg);
fprintf(stderr,
"Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void errorPrintReqArg3(char *program, char *wrong_arg)
{
fprintf(stderr,
"%s: option '%s' requires an argument\n",
program, wrong_arg);
fprintf(stderr,
"Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void parse_args(int argc, char *argv[], SArguments *arguments) { static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-f") == 0) { if ((strcmp(argv[i], "-f") == 0)
|| (0 == strncmp(argv[i], "--file", strlen("--file")))) {
if (2 == strlen(argv[i])) {
arguments->demo_mode = false; arguments->demo_mode = false;
if (NULL == argv[i+1]) { if (NULL == argv[i+1]) {
printHelp(); errorPrintReqArg3(argv[0], "f");
errorPrint("%s", "\n\t-f need a valid json file following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->metaFile = argv[++i]; arguments->metaFile = argv[++i];
} else if (strcmp(argv[i], "-c") == 0) { } else if (strlen("--file") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--file");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--file=", strlen("--file="))) {
arguments->metaFile = (char *)(argv[i] + strlen("--file="));
}
} else if ((strcmp(argv[i], "-c") == 0)
|| (0 == strncmp(argv[i], "--config-dir", strlen("--config-dir")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "c");
errorPrint("%s", "\n\t-c need a valid path following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN); tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN);
} else if (strcmp(argv[i], "-h") == 0) { } else if (strlen("--config-dir") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--config-dir");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--config-dir=", strlen("--config-dir="))) {
tstrncpy(configDir, (char *)(argv[i] + strlen("--config-dir=")), TSDB_FILENAME_LEN);
}
} else if ((strcmp(argv[i], "-h") == 0)
|| (0 == strncmp(argv[i], "--host", strlen("--host")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "h");
errorPrint("%s", "\n\t-h need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->host = argv[++i]; arguments->host = argv[++i];
} else if (strcmp(argv[i], "-P") == 0) { } else if (strlen("--host") == strlen(argv[i])) {
if ((argc == i+1) || errorPrintReqArg3(argv[0], "--host");
(!isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--host=", strlen("--host="))) {
errorPrint("%s", "\n\t-P need a number following!\n"); arguments->host = (char *)(argv[i] + strlen("--host="));
}
} else if ((strcmp(argv[i], "-P") == 0)
|| (0 == strncmp(argv[i], "--port", strlen("--port")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "P");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "P");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->port = atoi(argv[++i]); arguments->port = atoi(argv[++i]);
} else if (strcmp(argv[i], "-I") == 0) { } else if (strlen("--port") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--port");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--port=", strlen("--port="))) {
if (isStringNumber((char *)(argv[i] + strlen("--port=")))) {
arguments->port = atoi((char *)(argv[i]+strlen("--port=")));
}
}
} else if ((strcmp(argv[i], "-I") == 0)
|| (0 == strncmp(argv[i], "--interface", strlen("--interface")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "I");
errorPrint("%s", "\n\t-I need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
++i; if (0 == strcasecmp(argv[i+1], "taosc")) {
if (0 == strcasecmp(argv[i], "taosc")) {
arguments->iface = TAOSC_IFACE; arguments->iface = TAOSC_IFACE;
} else if (0 == strcasecmp(argv[i], "rest")) { } else if (0 == strcasecmp(argv[i+1], "rest")) {
arguments->iface = REST_IFACE; arguments->iface = REST_IFACE;
} else if (0 == strcasecmp(argv[i], "stmt")) { } else if (0 == strcasecmp(argv[i+1], "stmt")) {
arguments->iface = STMT_IFACE; arguments->iface = STMT_IFACE;
} else { } else {
errorPrint("%s", "\n\t-I need a valid string following!\n"); errorPrintReqArg(argv[0], "I");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if (strcmp(argv[i], "-u") == 0) { i++;
} else if (strlen("--interface") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--interface");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--interface=", strlen("--interface="))) {
if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "taosc")) {
arguments->iface = TAOSC_IFACE;
} else if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "rest")) {
arguments->iface = REST_IFACE;
} else if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "stmt")) {
arguments->iface = STMT_IFACE;
} else {
errorPrintReqArg3(argv[0], "--interface");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-u") == 0)
|| (0 == strncmp(argv[i], "--user", strlen("--user")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "u");
errorPrint("%s", "\n\t-u need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->user = argv[++i]; arguments->user = argv[++i];
} else if (strncmp(argv[i], "-p", 2) == 0) { } else if (strlen("--user") == strlen(argv[i])) {
if (strlen(argv[i]) == 2) { errorPrintReqArg3(argv[0], "--user");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--user=", strlen("--user="))) {
arguments->user = (char *)(argv[i++] + strlen("--user="));
}
} else if ((strncmp(argv[i], "-p", 2) == 0)
|| (0 == strcmp(argv[i], "--password"))) {
if ((strlen(argv[i]) == 2) || (0 == strcmp(argv[i], "--password"))) {
printf("Enter password: "); printf("Enter password: ");
taosSetConsoleEcho(false); taosSetConsoleEcho(false);
if (scanf("%s", arguments->password) > 1) { if (scanf("%s", arguments->password) > 1) {
...@@ -888,37 +979,100 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -888,37 +979,100 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN); tstrncpy(arguments->password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
} }
} else if (strcmp(argv[i], "-o") == 0) { } else if ((strcmp(argv[i], "-o") == 0)
|| (0 == strncmp(argv[i], "--output", strlen("--output")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg3(argv[0], "o");
errorPrint("%s", "\n\t-o need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->output_file = argv[++i]; arguments->output_file = argv[++i];
} else if (strcmp(argv[i], "-s") == 0) { } else if (strlen("--output") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--output");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--output=", strlen("--output="))) {
arguments->output_file = (char *)(argv[i++] + strlen("--output="));
}
} else if ((strcmp(argv[i], "-s") == 0)
|| (0 == strncmp(argv[i], "--sql-file", strlen("--sql-file")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "s");
errorPrint("%s", "\n\t-s need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->sqlFile = argv[++i]; arguments->sqlFile = argv[++i];
} else if (strcmp(argv[i], "-q") == 0) { } else if (strlen("--sql-file") == strlen(argv[i])) {
if ((argc == i+1) errorPrintReqArg3(argv[0], "--sql-file");
|| (!isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--sql-file=", strlen("--sql-file="))) {
errorPrint("%s", "\n\t-q need a number following!\nQuery mode -- 0: SYNC, not-0: ASYNC. Default is SYNC.\n"); arguments->host = (char *)(argv[i++] + strlen("--sql-file="));
}
} else if ((strcmp(argv[i], "-q") == 0)
|| (0 == strncmp(argv[i], "--query-mode", strlen("--query-mode")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "q");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "q");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->async_mode = atoi(argv[++i]); arguments->async_mode = atoi(argv[++i]);
} else if (strcmp(argv[i], "-T") == 0) { } else if (strlen("--query-mode") == strlen(argv[i])) {
if ((argc == i+1) errorPrintReqArg3(argv[0], "--query-mode");
|| (!isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--query-mode=", strlen("--query-mode="))) {
errorPrint("%s", "\n\t-T need a number following!\n"); if (isStringNumber((char *)(argv[i] + strlen("--query-mode=")))) {
arguments->async_mode = atoi((char *)(argv[i]+strlen("--query-mode=")));
} else {
errorPrintReqArg2(argv[0], "--query-mode");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-T") == 0)
|| (0 == strncmp(argv[i], "--threads", strlen("--threads")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "T");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "T");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->num_of_threads = atoi(argv[++i]); arguments->num_of_threads = atoi(argv[++i]);
} else if (strcmp(argv[i], "-i") == 0) { } else if (strlen("--threads") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--threads");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--threads=", strlen("--threads="))) {
if (isStringNumber((char *)(argv[i] + strlen("--threads=")))) {
arguments->num_of_threads = atoi((char *)(argv[i]+strlen("--threads=")));
} else {
errorPrintReqArg2(argv[0], "--threads");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-i") == 0)
|| (0 == strncmp(argv[i], "--insert-interval", strlen("--insert-interval")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "i");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "i");
exit(EXIT_FAILURE);
}
arguments->insert_interval = atoi(argv[++i]);
} else if (strlen("--insert-interval")== strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--insert-interval");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--insert-interval=", strlen("--insert-interval="))) {
if (isStringNumber((char *)(argv[i] + 18))) {
arguments->insert_interval = atoi((char *)(argv[i]+strlen("--insert-interval=")));
} else {
errorPrintReqArg3(argv[0], "--insert-innterval");
exit(EXIT_FAILURE);
}
}
if ((argc == i+1) || if ((argc == i+1) ||
(!isStringNumber(argv[i+1]))) { (!isStringNumber(argv[i+1]))) {
printHelp(); printHelp();
...@@ -926,14 +1080,28 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -926,14 +1080,28 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->insert_interval = atoi(argv[++i]); arguments->insert_interval = atoi(argv[++i]);
} else if (strcmp(argv[i], "-S") == 0) { } else if ((strcmp(argv[i], "-S") == 0)
if ((argc == i+1) || || (0 == strncmp(argv[i], "--time-step", strlen("--time-step")))) {
(!isStringNumber(argv[i+1]))) { if (2 == strlen(argv[i])) {
printHelp(); if (argc == i+1) {
errorPrint("\n\t%s%s", argv[i], " need a number following!\n"); errorPrintReqArg(argv[0], "S");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "S");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->timestamp_step = atoi(argv[++i]); arguments->async_mode = atoi(argv[++i]);
} else if (strlen("--time-step") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--time-step");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--time-step=", strlen("--time-step="))) {
if (isStringNumber((char *)(argv[i] + strlen("--time-step=")))) {
arguments->async_mode = atoi((char *)(argv[i]+strlen("--time-step=")));
} else {
errorPrintReqArg2(argv[0], "--time-step");
exit(EXIT_FAILURE);
}
}
} else if (strcmp(argv[i], "-qt") == 0) { } else if (strcmp(argv[i], "-qt") == 0) {
if ((argc == i+1) if ((argc == i+1)
|| (!isStringNumber(argv[i+1]))) { || (!isStringNumber(argv[i+1]))) {
...@@ -942,56 +1110,134 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -942,56 +1110,134 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(EXIT_FAILURE); 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) || (0 == strncmp(argv[i], "--interlace-rows", strlen("--interlace-rows")))) {
|| (!isStringNumber(argv[i+1]))) { if (2 == strlen(argv[i])) {
printHelp(); if (argc == i+1) {
errorPrint("%s", "\n\t-B need a number following!\n"); errorPrintReqArg(argv[0], "B");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "B");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->interlace_rows = atoi(argv[++i]); arguments->interlace_rows = atoi(argv[++i]);
} else if (strcmp(argv[i], "-r") == 0) { } else if (strlen("--interlace-rows")== strlen(argv[i])) {
if ((argc == i+1) errorPrintReqArg3(argv[0], "--interlace-rows");
|| (!isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--interlace-rows=", strlen("--interlace-rows="))) {
errorPrint("%s", "\n\t-r need a number following!\n"); if (isStringNumber((char *)(argv[i] + strlen("--interlace-rows=")))) {
arguments->interlace_rows = atoi((char *)(argv[i]+strlen("--interlace-rows=")));
} else {
errorPrintReqArg2(argv[0], "--interlace-rows");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-r") == 0)
|| (0 == strncmp(argv[i], "--rec-per-req", 13))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "r");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "r");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->num_of_RPR = atoi(argv[++i]); arguments->num_of_RPR = atoi(argv[++i]);
} else if (strcmp(argv[i], "-t") == 0) { } else if (strlen("--rec-per-req")== strlen(argv[i])) {
if ((argc == i+1) || errorPrintReqArg3(argv[0], "--rec-per-req");
(!isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--rec-per-req=", strlen("--rec-per-req="))) {
errorPrint("%s", "\n\t-t need a number following!\n"); if (isStringNumber((char *)(argv[i] + strlen("--rec-per-req=")))) {
arguments->num_of_RPR = atoi((char *)(argv[i]+strlen("--rec-per-req=")));
} else {
errorPrintReqArg2(argv[0], "--rec-per-req");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-t") == 0)
|| (0 == strncmp(argv[i], "--tables", strlen("--tables")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "t");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "t");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->num_of_tables = atoi(argv[++i]); arguments->num_of_tables = atoi(argv[++i]);
g_totalChildTables = arguments->num_of_tables; } else if (strlen("--tables") == strlen(argv[i])) {
} else if (strcmp(argv[i], "-n") == 0) { errorPrintReqArg3(argv[0], "--tables");
if ((argc == i+1) || exit(EXIT_FAILURE);
(!isStringNumber(argv[i+1]))) { } else if (0 == strncmp(argv[i], "--tables=", strlen("--tables="))) {
printHelp(); if (isStringNumber((char *)(argv[i] + strlen("--tables=")))) {
errorPrint("%s", "\n\t-n need a number following!\n"); arguments->num_of_tables = atoi((char *)(argv[i]+strlen("--tables=")));
} else {
errorPrintReqArg2(argv[0], "--tables");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-n") == 0)
|| (0 == strncmp(argv[i], "--records", strlen("--records")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "n");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->num_of_DPT = atoi(argv[++i]); arguments->num_of_DPT = atoi(argv[++i]);
} else if (strcmp(argv[i], "-d") == 0) { } else if (strlen("--records") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--records");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--records=", strlen("--records="))) {
if (isStringNumber((char *)(argv[i] + strlen("--records=")))) {
arguments->num_of_DPT = atoi((char *)(argv[i]+strlen("--records=")));
} else {
errorPrintReqArg2(argv[0], "--records");
exit(EXIT_FAILURE);
}
}
g_totalChildTables = arguments->num_of_DPT;
} else if ((strcmp(argv[i], "-d") == 0)
|| (0 == strncmp(argv[i], "--database", strlen("--database")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg3(argv[0], "d");
errorPrint("%s", "\n\t-d need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->database = argv[++i]; arguments->database = argv[++i];
} else if (strcmp(argv[i], "-l") == 0) { } else if (strlen("--database") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--database");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--database=", strlen("--database="))) {
arguments->output_file = (char *)(argv[i] + strlen("--database="));
}
} else if ((strcmp(argv[i], "-l") == 0)
|| (0 == strncmp(argv[i], "--columns", strlen("--columns")))) {
arguments->demo_mode = false; arguments->demo_mode = false;
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
if (!isStringNumber(argv[i+1])) { errorPrintReqArg(argv[0], "l");
printHelp(); exit(EXIT_FAILURE);
errorPrint("%s", "\n\t-l need a number following!\n"); } else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "l");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
}
} }
arguments->num_of_CPR = atoi(argv[++i]); arguments->num_of_CPR = atoi(argv[++i]);
} else if (strlen("--columns")== strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--columns");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--columns=", strlen("--columns="))) {
if (isStringNumber((char *)(argv[i] + strlen("--columns=")))) {
arguments->num_of_CPR = atoi((char *)(argv[i]+strlen("--columns")));
} else {
errorPrintReqArg2(argv[0], "--columns");
exit(EXIT_FAILURE);
}
}
if (arguments->num_of_CPR > MAX_NUM_COLUMNS) { if (arguments->num_of_CPR > MAX_NUM_COLUMNS) {
printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_COLUMNS); printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_COLUMNS);
...@@ -1005,36 +1251,46 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1005,36 +1251,46 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int col = arguments->num_of_CPR; col < MAX_NUM_COLUMNS; col++) { for (int col = arguments->num_of_CPR; col < MAX_NUM_COLUMNS; col++) {
arguments->datatype[col] = NULL; arguments->datatype[col] = NULL;
} }
} else if (strcmp(argv[i], "-b") == 0) { } else if ((strcmp(argv[i], "-b") == 0)
|| (0 == strncmp(argv[i], "--data-type", strlen("--data-type")))) {
arguments->demo_mode = false; arguments->demo_mode = false;
char *dataType;
if (2 == strlen(argv[i])) {
if (argc == i+1) { if (argc == i+1) {
printHelp(); errorPrintReqArg(argv[0], "b");
errorPrint("%s", "\n\t-b need valid string following!\n"); exit(EXIT_FAILURE);
}
dataType = argv[++i];
} else if (strlen("--data-type") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--data-type");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--data-type=", strlen("--data-type="))) {
dataType = (char *)(argv[i] + strlen("--data-type="));
} }
++i;
if (strstr(argv[i], ",") == NULL) { if (strstr(dataType, ",") == NULL) {
// only one col // only one col
if (strcasecmp(argv[i], "INT") if (strcasecmp(dataType, "INT")
&& strcasecmp(argv[i], "FLOAT") && strcasecmp(dataType, "FLOAT")
&& strcasecmp(argv[i], "TINYINT") && strcasecmp(dataType, "TINYINT")
&& strcasecmp(argv[i], "BOOL") && strcasecmp(dataType, "BOOL")
&& strcasecmp(argv[i], "SMALLINT") && strcasecmp(dataType, "SMALLINT")
&& strcasecmp(argv[i], "BIGINT") && strcasecmp(dataType, "BIGINT")
&& strcasecmp(argv[i], "DOUBLE") && strcasecmp(dataType, "DOUBLE")
&& strcasecmp(argv[i], "BINARY") && strcasecmp(dataType, "BINARY")
&& strcasecmp(argv[i], "TIMESTAMP") && strcasecmp(dataType, "TIMESTAMP")
&& strcasecmp(argv[i], "NCHAR")) { && strcasecmp(dataType, "NCHAR")) {
printHelp(); printHelp();
errorPrint("%s", "-b: Invalid data_type!\n"); errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->datatype[0] = argv[i]; arguments->datatype[0] = dataType;
arguments->datatype[1] = NULL; arguments->datatype[1] = NULL;
} else { } else {
// more than one col // more than one col
int index = 0; int index = 0;
g_dupstr = strdup(argv[i]); g_dupstr = strdup(dataType);
char *running = g_dupstr; char *running = g_dupstr;
char *token = strsep(&running, ","); char *token = strsep(&running, ",");
while(token != NULL) { while(token != NULL) {
...@@ -1059,75 +1315,155 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1059,75 +1315,155 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
arguments->datatype[index] = NULL; arguments->datatype[index] = NULL;
} }
} else if (strcmp(argv[i], "-w") == 0) { } else if ((strcmp(argv[i], "-w") == 0)
if ((argc == i+1) || || (0 == strncmp(argv[i], "--binwidth", strlen("--binwidth")))) {
(!isStringNumber(argv[i+1]))) { if (2 == strlen(argv[i])) {
printHelp(); if (argc == i+1) {
errorPrint("%s", "\n\t-w need a number following!\n"); errorPrintReqArg(argv[0], "w");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "w");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->len_of_binary = atoi(argv[++i]); arguments->binwidth = atoi(argv[++i]);
} else if (strcmp(argv[i], "-m") == 0) { } else if (strlen("--binwidth") == strlen(argv[i])) {
if ((argc == i+1) || errorPrintReqArg3(argv[0], "--binwidth");
(isStringNumber(argv[i+1]))) { exit(EXIT_FAILURE);
printHelp(); } else if (0 == strncmp(argv[i], "--binwidth=", strlen("--binwidth="))) {
errorPrint("%s", "\n\t-m need a letter-initial string following!\n"); if (isStringNumber((char *)(argv[i] + strlen("--binwidth=")))) {
arguments->binwidth = atoi((char *)(argv[i]+strlen("--binwidth=")));
} else {
errorPrintReqArg2(argv[0], "--binwidth");
exit(EXIT_FAILURE);
}
}
} else if ((strcmp(argv[i], "-m") == 0)
|| (0 == strncmp(argv[i], "--table-prefix", strlen("--table-prefix")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg3(argv[0], "m");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->tb_prefix = argv[++i]; arguments->tb_prefix = argv[++i];
} else if (strcmp(argv[i], "-N") == 0) { } else if (strlen("--table-prefix") == strlen(argv[i])
|| (strlen("--table-prefix=") == strlen(argv[i]))) {
errorPrintReqArg3(argv[0], "--table-prefix");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--table-prefix=", strlen("--table-prefix="))) {
arguments->tb_prefix = (char *)(argv[i] + strlen("--table-prefix="));
}
} else if ((strcmp(argv[i], "-N") == 0)
|| (0 == strcmp(argv[i], "--normal-table"))) {
arguments->use_metric = false; arguments->use_metric = false;
} else if (strcmp(argv[i], "-M") == 0) { } else if ((strcmp(argv[i], "-M") == 0)
|| (0 == strcmp(argv[i], "--random"))) {
arguments->demo_mode = false; arguments->demo_mode = false;
} else if (strcmp(argv[i], "-x") == 0) { } else if ((strcmp(argv[i], "-x") == 0)
|| (0 == strcmp(argv[i], "--no-insert"))) {
arguments->insert_only = false; arguments->insert_only = false;
} else if (strcmp(argv[i], "-y") == 0) { } else if ((strcmp(argv[i], "-y") == 0)
|| (0 == strcmp(argv[i], "--answer-yes"))) {
arguments->answer_yes = true; arguments->answer_yes = true;
} else if (strcmp(argv[i], "-g") == 0) { } else if ((strcmp(argv[i], "-g") == 0)
|| (0 == strcmp(argv[i], "--debug"))) {
arguments->debug_print = true; arguments->debug_print = true;
} else if (strcmp(argv[i], "-gg") == 0) { } else if (strcmp(argv[i], "-gg") == 0) {
arguments->verbose_print = true; arguments->verbose_print = true;
} else if (strcmp(argv[i], "-PP") == 0) { } else if (strcmp(argv[i], "-PP") == 0) {
arguments->performance_print = true; arguments->performance_print = true;
} else if (strcmp(argv[i], "-O") == 0) { } else if ((strcmp(argv[i], "-O") == 0)
if ((argc == i+1) || || (0 == strncmp(argv[i], "--disorder", strlen("--disorder")))) {
(!isStringNumber(argv[i+1]))) { if (2 == strlen(argv[i])) {
printHelp(); if (argc == i+1) {
errorPrint("%s", "\n\t-O need a number following!\n"); errorPrintReqArg(argv[0], "O");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "O");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->disorderRatio = atoi(argv[++i]); arguments->disorderRatio = atoi(argv[++i]);
} else if (strlen("--disorder") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--disorder");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--disorder=", strlen("--disorder="))) {
if (isStringNumber((char *)(argv[i] + strlen("--disorder=")))) {
arguments->disorderRatio = atoi((char *)(argv[i]+strlen("--disorder=")));
} else {
errorPrintReqArg2(argv[0], "--disorder");
exit(EXIT_FAILURE);
}
}
if (arguments->disorderRatio > 50) { if (arguments->disorderRatio > 50) {
errorPrint("Invalid disorder ratio %d, will be set to %d\n",
arguments->disorderRatio, 50);
arguments->disorderRatio = 50; arguments->disorderRatio = 50;
} }
if (arguments->disorderRatio < 0) { if (arguments->disorderRatio < 0) {
errorPrint("Invalid disorder ratio %d, will be set to %d\n",
arguments->disorderRatio, 0);
arguments->disorderRatio = 0; arguments->disorderRatio = 0;
} }
} else if ((strcmp(argv[i], "-R") == 0)
} else if (strcmp(argv[i], "-R") == 0) { || (0 == strncmp(argv[i], "--disorder-range",
if ((argc == i+1) || strlen("--disorder-range")))) {
(!isStringNumber(argv[i+1]))) { if (2 == strlen(argv[i])) {
printHelp(); if (argc == i+1) {
errorPrint("%s", "\n\t-R need a number following!\n"); errorPrintReqArg(argv[0], "R");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "R");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->disorderRange = atoi(argv[++i]); arguments->disorderRange = atoi(argv[++i]);
if (arguments->disorderRange < 0) } else if (strlen("--disorder-range") == strlen(argv[i])) {
arguments->disorderRange = 1000; errorPrintReqArg3(argv[0], "--disorder-range");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--disorder-range=",
strlen("--disorder-range="))) {
if (isStringNumber((char *)(argv[i] + strlen("--disorder-range=")))) {
arguments->disorderRange =
atoi((char *)(argv[i]+strlen("--disorder-rnage=")));
} else {
errorPrintReqArg2(argv[0], "--disorder-range");
exit(EXIT_FAILURE);
}
}
} else if (strcmp(argv[i], "-a") == 0) { if (arguments->disorderRange < 0) {
if ((argc == i+1) || errorPrint("Invalid disorder range %d, will be set to %d\n",
(!isStringNumber(argv[i+1]))) { arguments->disorderRange, 1000);
printHelp(); arguments->disorderRange = 1000;
errorPrint("%s", "\n\t-a need a number following!\n"); }
} else if ((strcmp(argv[i], "-a") == 0)
|| (0 == strncmp(argv[i], "--replica",
strlen("--replica")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "a");
exit(EXIT_FAILURE);
} else if (!isStringNumber(argv[i+1])) {
errorPrintReqArg2(argv[0], "a");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->replica = atoi(argv[++i]); arguments->replica = atoi(argv[++i]);
} else if (strlen("--replica") == strlen(argv[i])) {
errorPrintReqArg3(argv[0], "--replica");
exit(EXIT_FAILURE);
} else if (0 == strncmp(argv[i], "--replica=",
strlen("--replica="))) {
if (isStringNumber((char *)(argv[i] + strlen("--replica=")))) {
arguments->replica =
atoi((char *)(argv[i]+strlen("--replica=")));
} else {
errorPrintReqArg2(argv[0], "--replica");
exit(EXIT_FAILURE);
}
}
if (arguments->replica > 3 || arguments->replica < 1) { if (arguments->replica > 3 || arguments->replica < 1) {
errorPrint("Invalid replica value %d, will be set to %d\n",
arguments->replica, 1);
arguments->replica = 1; arguments->replica = 1;
} }
} else if (strcmp(argv[i], "-D") == 0) { } else if (strcmp(argv[i], "-D") == 0) {
...@@ -1136,16 +1472,32 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1136,16 +1472,32 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrint("%s", "\n\t-D need a valud (0~3) number following!\n"); errorPrint("%s", "\n\t-D need a valud (0~3) number following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if ((strcmp(argv[i], "--version") == 0) || } else if ((strcmp(argv[i], "--version") == 0)
(strcmp(argv[i], "-V") == 0)) { || (strcmp(argv[i], "-V") == 0)) {
printVersion(); printVersion();
exit(0); exit(0);
} else if (strcmp(argv[i], "--help") == 0) { } else if ((strcmp(argv[i], "--help") == 0)
|| (strcmp(argv[i], "-?") == 0)) {
printHelp(); printHelp();
exit(0); exit(0);
} else if (strcmp(argv[i], "--usage") == 0) {
printf(" Usage: taosdemo [-f JSONFILE] [-u USER] [-p PASSWORD] [-c CONFIG_DIR]\n\
[-h HOST] [-P PORT] [-I INTERFACE] [-d DATABASE] [-a REPLICA]\n\
[-m TABLEPREFIX] [-s SQLFILE] [-N] [-o OUTPUTFILE] [-q QUERYMODE]\n\
[-b DATATYPES] [-w WIDTH_OF_BINARY] [-l COLUNNS] [-T THREADNUMBER]\n\
[-i SLEEPTIME] [-S TIME_STEP] [-B INTERLACE_ROWS] [-t TABLES]\n\
[-n RECORDS] [-M] [-x] [-y] [-O ORDERMODE] [-R RANGE] [-a REPLIcA][-g]\n\
[--help] [--usage] [--version]\n");
exit(0);
} else { } else {
printHelp(); // to simulate argp_option output
errorPrint("%s", "ERROR: wrong options\n"); if (strlen(argv[i]) > 2) {
fprintf(stderr, "%s unrecognized options '%s'\n", argv[0], argv[i]);
} else {
fprintf(stderr, "%s invalid options -- '%s'\n", argv[0],
(char *)((char *)argv[i])+1);
}
fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
...@@ -1162,7 +1514,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1162,7 +1514,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
g_args.num_of_CPR = columnCount; g_args.num_of_CPR = columnCount;
if (((arguments->debug_print) && (arguments->metaFile == NULL)) if (((arguments->debug_print) && (NULL != arguments->metaFile))
|| arguments->verbose_print) { || arguments->verbose_print) {
printf("###################################################################\n"); printf("###################################################################\n");
printf("# meta file: %s\n", arguments->metaFile); printf("# meta file: %s\n", arguments->metaFile);
...@@ -1188,7 +1540,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1188,7 +1540,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->num_of_RPR); arguments->num_of_RPR);
printf("# Max SQL length: %"PRIu64"\n", printf("# Max SQL length: %"PRIu64"\n",
arguments->max_sql_len); arguments->max_sql_len);
printf("# Length of Binary: %d\n", arguments->len_of_binary); printf("# Length of Binary: %d\n", arguments->binwidth);
printf("# Number of Threads: %d\n", arguments->num_of_threads); printf("# Number of Threads: %d\n", arguments->num_of_threads);
printf("# Number of Tables: %"PRId64"\n", printf("# Number of Tables: %"PRId64"\n",
arguments->num_of_tables); arguments->num_of_tables);
...@@ -1644,7 +1996,7 @@ static int printfInsertMeta() { ...@@ -1644,7 +1996,7 @@ static int printfInsertMeta() {
printf("resultFile: \033[33m%s\033[0m\n", g_Dbs.resultFile); printf("resultFile: \033[33m%s\033[0m\n", g_Dbs.resultFile);
printf("thread num of insert data: \033[33m%d\033[0m\n", g_Dbs.threadCount); printf("thread num of insert data: \033[33m%d\033[0m\n", g_Dbs.threadCount);
printf("thread num of create table: \033[33m%d\033[0m\n", printf("thread num of create table: \033[33m%d\033[0m\n",
g_Dbs.threadCountByCreateTbl); g_Dbs.threadCountForCreateTbl);
printf("top insert interval: \033[33m%"PRIu64"\033[0m\n", printf("top insert interval: \033[33m%"PRIu64"\033[0m\n",
g_args.insert_interval); g_args.insert_interval);
printf("number of records per req: \033[33m%u\033[0m\n", printf("number of records per req: \033[33m%u\033[0m\n",
...@@ -1852,7 +2204,7 @@ static void printfInsertMetaToFile(FILE* fp) { ...@@ -1852,7 +2204,7 @@ static void printfInsertMetaToFile(FILE* fp) {
fprintf(fp, "configDir: %s\n", configDir); fprintf(fp, "configDir: %s\n", configDir);
fprintf(fp, "resultFile: %s\n", g_Dbs.resultFile); fprintf(fp, "resultFile: %s\n", g_Dbs.resultFile);
fprintf(fp, "thread num of insert data: %d\n", g_Dbs.threadCount); fprintf(fp, "thread num of insert data: %d\n", g_Dbs.threadCount);
fprintf(fp, "thread num of create table: %d\n", g_Dbs.threadCountByCreateTbl); fprintf(fp, "thread num of create table: %d\n", g_Dbs.threadCountForCreateTbl);
fprintf(fp, "number of records per req: %u\n", g_args.num_of_RPR); fprintf(fp, "number of records per req: %u\n", g_args.num_of_RPR);
fprintf(fp, "max sql length: %"PRIu64"\n", g_args.max_sql_len); fprintf(fp, "max sql length: %"PRIu64"\n", g_args.max_sql_len);
fprintf(fp, "database count: %d\n", g_Dbs.dbCount); fprintf(fp, "database count: %d\n", g_Dbs.dbCount);
...@@ -3451,7 +3803,7 @@ static void createChildTables() { ...@@ -3451,7 +3803,7 @@ static void createChildTables() {
startMultiThreadCreateChildTable( startMultiThreadCreateChildTable(
g_Dbs.db[i].superTbls[j].colsOfCreateChildTable, g_Dbs.db[i].superTbls[j].colsOfCreateChildTable,
g_Dbs.threadCountByCreateTbl, g_Dbs.threadCountForCreateTbl,
startFrom, startFrom,
g_Dbs.db[i].superTbls[j].childTblCount, g_Dbs.db[i].superTbls[j].childTblCount,
g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j])); g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j]));
...@@ -3465,7 +3817,7 @@ static void createChildTables() { ...@@ -3465,7 +3817,7 @@ static void createChildTables() {
|| (strncasecmp(g_args.datatype[j], || (strncasecmp(g_args.datatype[j],
"NCHAR", strlen("NCHAR")) == 0)) { "NCHAR", strlen("NCHAR")) == 0)) {
snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len, snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len,
",C%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary); ",C%d %s(%d)", j, g_args.datatype[j], g_args.binwidth);
} else { } else {
snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len, snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len,
",C%d %s", j, g_args.datatype[j]); ",C%d %s", j, g_args.datatype[j]);
...@@ -3480,7 +3832,7 @@ static void createChildTables() { ...@@ -3480,7 +3832,7 @@ static void createChildTables() {
g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf); g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf);
startMultiThreadCreateChildTable( startMultiThreadCreateChildTable(
tblColsBuf, tblColsBuf,
g_Dbs.threadCountByCreateTbl, g_Dbs.threadCountForCreateTbl,
0, 0,
g_args.num_of_tables, g_args.num_of_tables,
g_Dbs.db[i].dbName, g_Dbs.db[i].dbName,
...@@ -3837,9 +4189,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { ...@@ -3837,9 +4189,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON* threads2 = cJSON_GetObjectItem(root, "thread_count_create_tbl"); cJSON* threads2 = cJSON_GetObjectItem(root, "thread_count_create_tbl");
if (threads2 && threads2->type == cJSON_Number) { if (threads2 && threads2->type == cJSON_Number) {
g_Dbs.threadCountByCreateTbl = threads2->valueint; g_Dbs.threadCountForCreateTbl = threads2->valueint;
} else if (!threads2) { } else if (!threads2) {
g_Dbs.threadCountByCreateTbl = 1; g_Dbs.threadCountForCreateTbl = 1;
} else { } else {
errorPrint("%s", "failed to read json, threads2 not found\n"); errorPrint("%s", "failed to read json, threads2 not found\n");
goto PARSE_OVER; goto PARSE_OVER;
...@@ -4201,7 +4553,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { ...@@ -4201,7 +4553,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
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;
} else if (!batchCreateTbl) { } else if (!batchCreateTbl) {
g_Dbs.db[i].superTbls[j].batchCreateTableNum = 1000; g_Dbs.db[i].superTbls[j].batchCreateTableNum = 10;
} else { } else {
errorPrint("%s", "failed to read json, batch_create_tbl_num not found\n"); errorPrint("%s", "failed to read json, batch_create_tbl_num not found\n");
goto PARSE_OVER; goto PARSE_OVER;
...@@ -5429,7 +5781,7 @@ static int32_t generateDataTailWithoutStb( ...@@ -5429,7 +5781,7 @@ static int32_t generateDataTailWithoutStb(
int64_t retLen = 0; int64_t retLen = 0;
char **data_type = g_args.datatype; char **data_type = g_args.datatype;
int lenOfBinary = g_args.len_of_binary; int lenOfBinary = g_args.binwidth;
if (g_args.disorderRatio) { if (g_args.disorderRatio) {
retLen = generateData(data, data_type, retLen = generateData(data, data_type,
...@@ -6211,7 +6563,7 @@ static int32_t prepareStmtWithoutStb( ...@@ -6211,7 +6563,7 @@ static int32_t prepareStmtWithoutStb(
if ( -1 == prepareStmtBindArrayByType( if ( -1 == prepareStmtBindArrayByType(
bind, bind,
data_type[i], data_type[i],
g_args.len_of_binary, g_args.binwidth,
pThreadInfo->time_precision, pThreadInfo->time_precision,
NULL)) { NULL)) {
return -1; return -1;
...@@ -6245,7 +6597,7 @@ static int32_t prepareStbStmtBindTag( ...@@ -6245,7 +6597,7 @@ static int32_t prepareStbStmtBindTag(
char *tagsVal, char *tagsVal,
int32_t timePrec) int32_t timePrec)
{ {
char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.len_of_binary); char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.binwidth);
if (bindBuffer == NULL) { if (bindBuffer == NULL) {
errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n", errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n",
__func__, __LINE__, DOUBLE_BUFF_LEN); __func__, __LINE__, DOUBLE_BUFF_LEN);
...@@ -6277,7 +6629,7 @@ static int32_t prepareStbStmtBindRand( ...@@ -6277,7 +6629,7 @@ static int32_t prepareStbStmtBindRand(
int64_t startTime, int32_t recSeq, int64_t startTime, int32_t recSeq,
int32_t timePrec) int32_t timePrec)
{ {
char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.len_of_binary); char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.binwidth);
if (bindBuffer == NULL) { if (bindBuffer == NULL) {
errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n", errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n",
__func__, __LINE__, DOUBLE_BUFF_LEN); __func__, __LINE__, DOUBLE_BUFF_LEN);
...@@ -7388,7 +7740,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7388,7 +7740,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
} }
} }
} else { } else {
start_time = 1500000000000; start_time = DEFAULT_START_TIME;
} }
debugPrint("%s() LN%d, start_time= %"PRId64"\n", debugPrint("%s() LN%d, start_time= %"PRId64"\n",
__func__, __LINE__, start_time); __func__, __LINE__, start_time);
...@@ -7943,11 +8295,11 @@ static int insertTestProcess() { ...@@ -7943,11 +8295,11 @@ static int insertTestProcess() {
if (g_totalChildTables > 0) { if (g_totalChildTables > 0) {
fprintf(stderr, fprintf(stderr,
"creating %"PRId64" table(s) with %d thread(s)\n\n", "creating %"PRId64" table(s) with %d thread(s)\n\n",
g_totalChildTables, g_Dbs.threadCountByCreateTbl); g_totalChildTables, g_Dbs.threadCountForCreateTbl);
if (g_fpOfInsertResult) { if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult, fprintf(g_fpOfInsertResult,
"creating %"PRId64" table(s) with %d thread(s)\n\n", "creating %"PRId64" table(s) with %d thread(s)\n\n",
g_totalChildTables, g_Dbs.threadCountByCreateTbl); g_totalChildTables, g_Dbs.threadCountForCreateTbl);
} }
// create child tables // create child tables
...@@ -7958,12 +8310,12 @@ static int insertTestProcess() { ...@@ -7958,12 +8310,12 @@ static int insertTestProcess() {
fprintf(stderr, fprintf(stderr,
"\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n", "\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n",
(end - start)/1000.0, g_totalChildTables, (end - start)/1000.0, g_totalChildTables,
g_Dbs.threadCountByCreateTbl, g_actualChildTables); g_Dbs.threadCountForCreateTbl, g_actualChildTables);
if (g_fpOfInsertResult) { if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult, fprintf(g_fpOfInsertResult,
"\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n", "\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n",
(end - start)/1000.0, g_totalChildTables, (end - start)/1000.0, g_totalChildTables,
g_Dbs.threadCountByCreateTbl, g_actualChildTables); g_Dbs.threadCountForCreateTbl, g_actualChildTables);
} }
} }
...@@ -8878,7 +9230,7 @@ static void setParaFromArg() { ...@@ -8878,7 +9230,7 @@ static void setParaFromArg() {
} }
g_Dbs.threadCount = g_args.num_of_threads; g_Dbs.threadCount = g_args.num_of_threads;
g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; g_Dbs.threadCountForCreateTbl = g_args.num_of_threads;
g_Dbs.dbCount = 1; g_Dbs.dbCount = 1;
g_Dbs.db[0].drop = true; g_Dbs.db[0].drop = true;
...@@ -8910,7 +9262,7 @@ static void setParaFromArg() { ...@@ -8910,7 +9262,7 @@ static void setParaFromArg() {
tstrncpy(g_Dbs.db[0].superTbls[0].sTblName, "meters", TSDB_TABLE_NAME_LEN); tstrncpy(g_Dbs.db[0].superTbls[0].sTblName, "meters", TSDB_TABLE_NAME_LEN);
g_Dbs.db[0].superTbls[0].childTblCount = g_args.num_of_tables; g_Dbs.db[0].superTbls[0].childTblCount = g_args.num_of_tables;
g_Dbs.threadCount = g_args.num_of_threads; g_Dbs.threadCount = g_args.num_of_threads;
g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; g_Dbs.threadCountForCreateTbl = g_args.num_of_threads;
g_Dbs.asyncMode = g_args.async_mode; g_Dbs.asyncMode = g_args.async_mode;
g_Dbs.db[0].superTbls[0].autoCreateTable = PRE_CREATE_SUBTBL; g_Dbs.db[0].superTbls[0].autoCreateTable = PRE_CREATE_SUBTBL;
...@@ -8941,7 +9293,7 @@ static void setParaFromArg() { ...@@ -8941,7 +9293,7 @@ static void setParaFromArg() {
tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType, tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType,
data_type[i], min(DATATYPE_BUFF_LEN, strlen(data_type[i]) + 1)); data_type[i], min(DATATYPE_BUFF_LEN, strlen(data_type[i]) + 1));
g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.len_of_binary; g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.binwidth;
g_Dbs.db[0].superTbls[0].columnCount++; g_Dbs.db[0].superTbls[0].columnCount++;
} }
...@@ -8963,10 +9315,10 @@ static void setParaFromArg() { ...@@ -8963,10 +9315,10 @@ static void setParaFromArg() {
tstrncpy(g_Dbs.db[0].superTbls[0].tags[1].dataType, tstrncpy(g_Dbs.db[0].superTbls[0].tags[1].dataType,
"BINARY", min(DATATYPE_BUFF_LEN, strlen("BINARY") + 1)); "BINARY", min(DATATYPE_BUFF_LEN, strlen("BINARY") + 1));
g_Dbs.db[0].superTbls[0].tags[1].dataLen = g_args.len_of_binary; g_Dbs.db[0].superTbls[0].tags[1].dataLen = g_args.binwidth;
g_Dbs.db[0].superTbls[0].tagCount = 2; g_Dbs.db[0].superTbls[0].tagCount = 2;
} else { } else {
g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; g_Dbs.threadCountForCreateTbl = g_args.num_of_threads;
g_Dbs.db[0].superTbls[0].tagCount = 0; g_Dbs.db[0].superTbls[0].tagCount = 0;
} }
} }
...@@ -9088,7 +9440,7 @@ static void queryResult() { ...@@ -9088,7 +9440,7 @@ static void queryResult() {
pthread_t read_id; pthread_t read_id;
threadInfo *pThreadInfo = calloc(1, sizeof(threadInfo)); threadInfo *pThreadInfo = calloc(1, sizeof(threadInfo));
assert(pThreadInfo); assert(pThreadInfo);
pThreadInfo->start_time = 1500000000000; // 2017-07-14 10:40:00.000 pThreadInfo->start_time = DEFAULT_START_TIME; // 2017-07-14 10:40:00.000
pThreadInfo->start_table_from = 0; pThreadInfo->start_table_from = 0;
//pThreadInfo->do_aggreFunc = g_Dbs.do_aggreFunc; //pThreadInfo->do_aggreFunc = g_Dbs.do_aggreFunc;
......
...@@ -225,7 +225,6 @@ static struct argp_option options[] = { ...@@ -225,7 +225,6 @@ static struct argp_option options[] = {
{"password", 'p', 0, 0, "User password to connect to server. Default is taosdata.", 0}, {"password", 'p', 0, 0, "User password to connect to server. Default is taosdata.", 0},
#endif #endif
{"port", 'P', "PORT", 0, "Port to connect", 0}, {"port", 'P', "PORT", 0, "Port to connect", 0},
{"cversion", 'v', "CVERION", 0, "client version", 0},
{"mysqlFlag", 'q', "MYSQLFLAG", 0, "mysqlFlag, Default is 0", 0}, {"mysqlFlag", 'q', "MYSQLFLAG", 0, "mysqlFlag, Default is 0", 0},
// input/output file // input/output file
{"outpath", 'o', "OUTPATH", 0, "Output file path.", 1}, {"outpath", 'o', "OUTPATH", 0, "Output file path.", 1},
...@@ -244,7 +243,7 @@ static struct argp_option options[] = { ...@@ -244,7 +243,7 @@ static struct argp_option options[] = {
// dump format options // dump format options
{"schemaonly", 's', 0, 0, "Only dump schema.", 2}, {"schemaonly", 's', 0, 0, "Only dump schema.", 2},
{"without-property", 'N', 0, 0, "Dump schema without properties.", 2}, {"without-property", 'N', 0, 0, "Dump schema without properties.", 2},
{"avro", 'V', 0, 0, "Dump apache avro format data file. By default, dump sql command sequence.", 2}, {"avro", 'v', 0, 0, "Dump apache avro format data file. By default, dump sql command sequence.", 2},
{"start-time", 'S', "START_TIME", 0, "Start time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00:000+0800 or '2017-10-01 00:00:00.000+0800'", 4}, {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00:000+0800 or '2017-10-01 00:00:00.000+0800'", 4},
{"end-time", 'E', "END_TIME", 0, "End time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 5}, {"end-time", 'E', "END_TIME", 0, "End time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 5},
#if TSDB_SUPPORT_NANOSECOND == 1 #if TSDB_SUPPORT_NANOSECOND == 1
...@@ -267,7 +266,6 @@ typedef struct arguments { ...@@ -267,7 +266,6 @@ typedef struct arguments {
char *user; char *user;
char password[SHELL_MAX_PASSWORD_LEN]; char password[SHELL_MAX_PASSWORD_LEN];
uint16_t port; uint16_t port;
char cversion[12];
uint16_t mysqlFlag; uint16_t mysqlFlag;
// output file // output file
char outpath[MAX_FILE_NAME_LEN]; char outpath[MAX_FILE_NAME_LEN];
...@@ -338,7 +336,6 @@ struct arguments g_args = { ...@@ -338,7 +336,6 @@ struct arguments g_args = {
"taosdata", "taosdata",
#endif #endif
0, 0,
"",
0, 0,
// outpath and inpath // outpath and inpath
"", "",
...@@ -404,15 +401,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -404,15 +401,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'q': case 'q':
g_args.mysqlFlag = atoi(arg); g_args.mysqlFlag = atoi(arg);
break; break;
case 'v':
if (wordexp(arg, &full_path, 0) != 0) {
errorPrint("Invalid client vesion %s\n", arg);
return -1;
}
tstrncpy(g_args.cversion, full_path.we_wordv[0], 11);
wordfree(&full_path);
break;
// output file path
case 'o': case 'o':
if (wordexp(arg, &full_path, 0) != 0) { if (wordexp(arg, &full_path, 0) != 0) {
errorPrint("Invalid path %s\n", arg); errorPrint("Invalid path %s\n", arg);
...@@ -466,7 +454,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -466,7 +454,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'N': case 'N':
g_args.with_property = false; g_args.with_property = false;
break; break;
case 'V': case 'v':
g_args.avro = true; g_args.avro = true;
break; break;
case 'S': case 'S':
...@@ -673,6 +661,9 @@ static void parse_timestamp( ...@@ -673,6 +661,9 @@ static void parse_timestamp(
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
static char verType[32] = {0};
sprintf(verType, "version: %s\n", version);
argp_program_version = verType;
int ret = 0; int ret = 0;
/* Parse our arguments; every option seen by parse_opt will be /* Parse our arguments; every option seen by parse_opt will be
...@@ -699,7 +690,6 @@ int main(int argc, char *argv[]) { ...@@ -699,7 +690,6 @@ int main(int argc, char *argv[]) {
printf("user: %s\n", g_args.user); printf("user: %s\n", g_args.user);
printf("password: %s\n", g_args.password); printf("password: %s\n", g_args.password);
printf("port: %u\n", g_args.port); printf("port: %u\n", g_args.port);
printf("cversion: %s\n", g_args.cversion);
printf("mysqlFlag: %d\n", g_args.mysqlFlag); printf("mysqlFlag: %d\n", g_args.mysqlFlag);
printf("outpath: %s\n", g_args.outpath); printf("outpath: %s\n", g_args.outpath);
printf("inpath: %s\n", g_args.inpath); printf("inpath: %s\n", g_args.inpath);
...@@ -728,11 +718,6 @@ int main(int argc, char *argv[]) { ...@@ -728,11 +718,6 @@ int main(int argc, char *argv[]) {
} }
} }
printf("==============================\n"); printf("==============================\n");
if (g_args.cversion[0] != 0){
tstrncpy(version, g_args.cversion, 11);
}
if (taosCheckParam(&g_args) < 0) { if (taosCheckParam(&g_args) < 0) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -750,7 +735,6 @@ int main(int argc, char *argv[]) { ...@@ -750,7 +735,6 @@ int main(int argc, char *argv[]) {
fprintf(g_fpOfResult, "user: %s\n", g_args.user); fprintf(g_fpOfResult, "user: %s\n", g_args.user);
fprintf(g_fpOfResult, "password: %s\n", g_args.password); fprintf(g_fpOfResult, "password: %s\n", g_args.password);
fprintf(g_fpOfResult, "port: %u\n", g_args.port); fprintf(g_fpOfResult, "port: %u\n", g_args.port);
fprintf(g_fpOfResult, "cversion: %s\n", g_args.cversion);
fprintf(g_fpOfResult, "mysqlFlag: %d\n", g_args.mysqlFlag); fprintf(g_fpOfResult, "mysqlFlag: %d\n", g_args.mysqlFlag);
fprintf(g_fpOfResult, "outpath: %s\n", g_args.outpath); fprintf(g_fpOfResult, "outpath: %s\n", g_args.outpath);
fprintf(g_fpOfResult, "inpath: %s\n", g_args.inpath); fprintf(g_fpOfResult, "inpath: %s\n", g_args.inpath);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册