From 7b476ef75f781703660adc31f5f2709181d651e5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 12 Jan 2021 18:52:35 +0800 Subject: [PATCH] [TD-2598] feature: C# taosdemo, support query command. --- tests/examples/C#/taosdemo/README.md | 44 +++-- tests/examples/C#/taosdemo/taosdemo.cs | 264 +++++++++++++++---------- 2 files changed, 185 insertions(+), 123 deletions(-) diff --git a/tests/examples/C#/taosdemo/README.md b/tests/examples/C#/taosdemo/README.md index 9bceb84cd0..2d125fb140 100644 --- a/tests/examples/C#/taosdemo/README.md +++ b/tests/examples/C#/taosdemo/README.md @@ -10,25 +10,27 @@ run C# version taosdemo === Usage: mono taosdemo.exe [OPTION...] - --help Show usage. + --help Show usage. - -h host, The host to connect to TDengine. Default is localhost. - -p port, The TCP/IP port number to use for the connection. Default is 0. - -u user, The user name to use when connecting to the server. Default is 'root'. - -P password, The password to use when connecting to the server. Default is 'taosdata'. - -d database, Destination database. Default is 'test'. - -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. - -m table_prefix, Table prefix name. Default is 't'. - -M stable, Use super table. - -s stable_prefix, STable prefix name. Default is 'st' - -T num_of_threads, The number of threads. Default is 10. - -r num_of_records_per_req, The number of records per request. Default is 1000. - -t num_of_tables, The number of tables. Default is 1. - -n num_of_records_per_table, The number of records per table. Default is 1. - -c config_directory, Configuration directory. Default is '/etc/taos/'. - -x flag, Insert only flag. - -O order, Insert mode--0: In order, 1: Out of order. Default is in order. - -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. - -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. - -v Print verbose output - -y Skip read key for continous test, default is not skip + -h host, The host to connect to TDengine. Default is localhost. + -p port, The TCP/IP port number to use for the connection. Default is 0. + -u user, The user name to use when connecting to the server. Default is 'root'. + -P password, The password to use when connecting to the server. Default is 'taosdata'. + -d database, Destination database. Default is 'test'. + -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. + -m table_prefix, Table prefix name. Default is 't'. + -M stable, Use super table. + -s stable_prefix, STable prefix name. Default is 'st' + -Q query, Execute query command. set 'DEFAULT' means select * from each table + -T num_of_threads, The number of threads. Default is 10. + -r num_of_records_per_req, The number of records per request. Default is 1000. + -t num_of_tables, The number of tables. Default is 1. + -n num_of_records_per_table, The number of records per table. Default is 1. + -c config_directory, Configuration directory. Default is '/etc/taos/'. + -x flag, Insert only flag. + -O order, Insert mode--0: In order, 1: Out of order. Default is in order. + -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. + -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. + -v Print verbose output + -g Print debug output + -y Skip read key for continous test, default is not skip diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 68eefdd161..6e1cbd2088 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -38,7 +38,8 @@ namespace TDengineDriver private string tablePrefix = "t"; private bool isInsertOnly = false; - private int queryMode = 1; + private string query = "NONE"; + private short queryMode = 1; private long recordsPerTable = 1; private int recordsPerRequest = 1; @@ -56,8 +57,15 @@ namespace TDengineDriver private bool order = true; private bool skipReadKey = false; private bool verbose = false; + private bool debug = false; + static void HelpPrint(string arg, string desc) + { + string indent = " "; + Console.WriteLine("{0}{1}", indent, arg.PadRight(25)+desc); + } + static void PrintHelp(String[] argv) { for (int i = 0; i < argv.Length; ++i) @@ -66,61 +74,38 @@ namespace TDengineDriver { Console.WriteLine("Usage: mono taosdemo.exe [OPTION...]"); Console.WriteLine(""); - string indent = " "; - Console.WriteLine("{0}{1}", indent, "--help Show usage."); + HelpPrint("--help", "Show usage."); Console.WriteLine(""); - Console.Write("{0}{1}", indent, "-h"); - Console.Write("{0}{1}{2}\n", indent, indent, "host, The host to connect to TDengine. Default is localhost."); - Console.Write("{0}{1}", indent, "-p"); - Console.Write("{0}{1}{2}\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0."); - Console.Write("{0}{1}", indent, "-u"); - Console.Write("{0}{1}{2}\n", indent, indent, "user, The user name to use when connecting to the server. Default is 'root'."); - Console.Write("{0}{1}", indent, "-P"); - Console.Write("{0}{1}{2}\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'."); - Console.Write("{0}{1}", indent, "-d"); - Console.Write("{0}{1}{2}\n", indent, indent, "database, Destination database. Default is 'test'."); - Console.Write("{0}{1}", indent, "-a"); - Console.Write("{0}{1}{2}\n", indent, indent, "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); - Console.Write("{0}{1}", indent, "-m"); - Console.Write("{0}{1}{2}\n", indent, indent, "table_prefix, Table prefix name. Default is 't'."); - Console.Write("{0}{1}", indent, "-M"); - Console.Write("{0}{1}{2}\n", indent, indent, "stable, Use super table."); - Console.Write("{0}{1}", indent, "-s"); - Console.Write("{0}{1}{2}\n", indent, indent, "stable_prefix, STable prefix name. Default is 'st'"); -/* NOT SUPPORT - Console.Write("{0}{1}", indent, "-o"); - Console.Write("{0}{1}{2}\n", indent, indent, "outputfile, Direct output to the named file. Default is './output.txt'."); - Console.Write("{0}{1}", indent, "-q"); - Console.Write("{0}{1}{2}\n", indent, indent, "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); - Console.Write("{0}{1}", indent, "-b"); - Console.Write("{0}{1}{2}\n", indent, indent, "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); - Console.Write("{0}{1}", indent, "-w"); - Console.Write("{0}{1}{2}\n", indent, indent, "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); - Console.Write("{0}{1}", indent, "-l"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_cols_per_record, The number of columns per record. Default is 3."); + + HelpPrint("-h ", "host, The host to connect to TDengine. Default is localhost."); + HelpPrint("-p ", "port, The TCP/IP port number to use for the connection. Default is 0."); + HelpPrint("-u ", "user, The user name to use when connecting to the server. Default is 'root'."); + HelpPrint("-P ", "password, The password to use when connecting to the server. Default is 'taosdata'."); + HelpPrint("-d ", "database, Destination database. Default is 'test'."); + HelpPrint("-a ", "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); + HelpPrint("-m
", "table_prefix, Table prefix name. Default is 't'."); + HelpPrint("-M", "stable, Use super table."); + HelpPrint("-s ", "stable_prefix, STable prefix name. Default is 'st'"); + HelpPrint("-Q ", "query, Execute query command. set 'DEFAULT' means select * from each table"); + /* NOT SUPPORT SO FAR + HelpPrint("-o", "outputfile, Direct output to the named file. Default is './output.txt'."); + HelpPrint("-q", "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); + HelpPrint("-b", "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); + HelpPrint("-w", "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); + HelpPrint("-l", "num_of_cols_per_record, The number of columns per record. Default is 3."); */ - Console.Write("{0}{1}", indent, "-T"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_threads, The number of threads. Default is 10."); - Console.Write("{0}{1}", indent, "-r"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_req, The number of records per request. Default is 1000."); - Console.Write("{0}{1}", indent, "-t"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_tables, The number of tables. Default is 1."); - Console.Write("{0}{1}", indent, "-n"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_table, The number of records per table. Default is 1."); - Console.Write("{0}{1}", indent, "-c"); - Console.Write("{0}{1}{2}\n", indent, indent, "config_directory, Configuration directory. Default is '/etc/taos/'."); - Console.Write("{0}{1}", indent, "-x"); - Console.Write("{0}{1}{2}\n", indent, indent, "flag, Insert only flag."); - Console.Write("{0}{1}", indent, "-O"); - Console.Write("{0}{1}{2}\n", indent, indent, "order, Insert mode--0: In order, 1: Out of order. Default is in order."); - Console.Write("{0}{1}", indent, "-R"); - Console.Write("{0}{1}{2}\n", indent, indent, "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); - Console.Write("{0}{1}", indent, "-D"); - Console.Write("{0}{1}{2}\n", indent, indent, "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); - Console.Write("{0}{1}", indent, "-v"); - Console.Write("{0}{1}{2}\n", indent, indent, "Print verbose output"); - Console.Write("{0}{1}", indent, "-y"); - Console.Write("{0}{1}{2}\n", indent, indent, "Skip read key for continous test, default is not skip"); + HelpPrint("-T ", "num_of_threads, The number of threads. Default is 10."); + HelpPrint("-r ", "num_of_records_per_req, The number of records per request. Default is 1000."); + HelpPrint("-t ", "num_of_tables, The number of tables. Default is 1."); + HelpPrint("-n ", "num_of_records_per_table, The number of records per table. Default is 1."); + HelpPrint("-c ", "config_directory, Configuration directory. Default is '/etc/taos/'."); + HelpPrint("-x", "flag, Insert only flag."); + HelpPrint("-O", "order, Insert mode--0: In order, 1: Out of order. Default is in order."); + HelpPrint("-R ", "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); + HelpPrint("-D ", "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); + HelpPrint("-v", "Print verbose output"); + HelpPrint("-g", "Print debug output"); + HelpPrint("-y", "Skip read key for continous test, default is not skip"); System.Environment.Exit(0); } @@ -136,24 +121,26 @@ namespace TDengineDriver dbName = this.GetArgumentAsString(argv, "-d", "db"); stablePrefix = this.GetArgumentAsString(argv, "-s", "st"); tablePrefix = this.GetArgumentAsString(argv, "-m", "t"); - isInsertOnly = this.GetArgumentAsFlag(argv, "-x"); - queryMode = (int)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); + isInsertOnly = this.GetArgumentAsFlag(argv, "-x", true); + query = this.GetArgumentAsString(argv, "-Q", "NONE"); + queryMode = (short)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); numOfTables = this.GetArgumentAsLong(argv, "-t", 1, 1000000000, 1); batchRows = this.GetArgumentAsLong(argv, "-r", 1, 10000, 1000); recordsPerTable = this.GetArgumentAsLong(argv, "-n", 1, 100000000000, 1); recordsPerRequest = (int)this.GetArgumentAsLong(argv, "-r", 1, 10000, 1); colsPerRecord = (int)this.GetArgumentAsLong(argv, "-l", 1, 1024, 3); configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - useStable = this.GetArgumentAsFlag(argv, "-M"); + useStable = this.GetArgumentAsFlag(argv, "-M", true); replica = (short)this.GetArgumentAsLong(argv, "-a", 1, 5, 1); methodOfDelete = (short)this.GetArgumentAsLong(argv, "-D", 0, 3, 0); numOfThreads = (short)this.GetArgumentAsLong(argv, "-T", 1, 10000, 1); - order = this.GetArgumentAsFlag(argv, "-O"); + order = this.GetArgumentAsFlag(argv, "-O", false); rateOfOutorder = (short)this.GetArgumentAsLong(argv, "-R", 0, 50, 10); - skipReadKey = this.GetArgumentAsFlag(argv, "-y"); - verbose = this.GetArgumentAsFlag(argv, "-v"); + skipReadKey = this.GetArgumentAsFlag(argv, "-y", true); + verbose = this.GetArgumentAsFlag(argv, "-v", true); + debug = this.GetArgumentAsFlag(argv, "-g", true); Console.Write("###################################################################\n"); Console.Write("# Server IP: {0}\n", host); @@ -162,7 +149,7 @@ namespace TDengineDriver Console.Write("# Number of Columns per record: {0}\n", colsPerRecord); Console.Write("# Number of Threads: {0}\n", numOfThreads); Console.Write("# Number of Tables: {0}\n", numOfTables); - Console.Write("# Number of Data per Table: {0}\n", recordsPerTable); + Console.Write("# Number of records per Table: {0}\n", recordsPerTable); Console.Write("# Records/Request: {0}\n", recordsPerRequest); Console.Write("# Database name: {0}\n", dbName); Console.Write("# Replica: {0}\n", replica); @@ -175,6 +162,7 @@ namespace TDengineDriver Console.Write("# Data order: {0}\n", order); Console.Write("# Data out of order rate: {0}\n", rateOfOutorder); Console.Write("# Delete method: {0}\n", methodOfDelete); + Console.Write("# Query command: {0}\n", query); Console.Write("# Query Mode: {0}\n", queryMode); Console.Write("# Insert Only: {0}\n", isInsertOnly); Console.Write("# Verbose output {0}\n", verbose); @@ -189,17 +177,17 @@ namespace TDengineDriver } } - public bool GetArgumentAsFlag(String[] argv, String argName) + public bool GetArgumentAsFlag(String[] argv, String argName, bool defaultValue) { int argc = argv.Length; for (int i = 0; i < argc; ++i) { if (argName == argv[i]) { - return true; + return defaultValue; } } - return false; + return !defaultValue; } public long GetArgumentAsLong(String[] argv, String argName, int minVal, long maxVal, int defaultValue) @@ -269,7 +257,7 @@ namespace TDengineDriver System.Environment.Exit(0); } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -277,7 +265,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -285,18 +273,34 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void InitTDengine() { TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); TDengine.Init(); - DebugPrint("TDengine Initialization finished\n"); + VerbosePrint("TDengine Initialization finished\n"); } public void ConnectTDengine() { string db = ""; - DebugPrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", + VerbosePrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", this.host, this.user, this.password, db, this.port); this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); if (this.conn == IntPtr.Zero) @@ -306,7 +310,7 @@ namespace TDengineDriver } else { - DebugPrint("Connect to TDengine success\n"); + VerbosePrint("Connect to TDengine success\n"); } } @@ -334,6 +338,7 @@ namespace TDengineDriver CreateTableThread createTableThread = new CreateTableThread(); createTableThread.id = i; createTableThread.verbose = verbose; + createTableThread.debug = debug; createTableThread.dbName = this.dbName; createTableThread.tablePrefix = this.tablePrefix; createTableThread.useStable = useStable; @@ -367,7 +372,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -384,7 +389,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -405,7 +410,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { @@ -442,6 +447,7 @@ namespace TDengineDriver insertThread.batchRows = batchRows; insertThread.numOfTables = numOfTables; insertThread.verbose = verbose; + insertThread.debug = debug; insertThread.dbName = this.dbName; insertThread.tablePrefix = this.tablePrefix; insertThread.order = this.order; @@ -471,15 +477,24 @@ namespace TDengineDriver public void ExecuteQuery() { - // System.DateTime start = new System.DateTime(); long queryRows = 0; - for (int i = 0; i < 1/*this.numOfTables*/; ++i) + for (int i = 0; i < this.numOfTables; ++i) { - String sql = "select * from " + this.dbName + "." + tablePrefix + i; - // Console.WriteLine(sql); + string sql; + + if (query == "DEFAULT") + { + sql = "select * from " + this.dbName + "." + tablePrefix + i; + } + else + { + sql = query; + } + DebugPrintFormat("query: {0}, sql:{1}\n", query, sql); IntPtr res = TDengine.Query(conn, sql); + DebugPrintFormat("res: {0}\n", res); if (res == IntPtr.Zero) { Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); @@ -487,17 +502,18 @@ namespace TDengineDriver } int fieldCount = TDengine.FieldCount(res); - // Console.WriteLine("field count: " + fieldCount); + DebugPrint("field count: " + fieldCount + "\n"); List metas = TDengine.FetchFields(res); for (int j = 0; j < metas.Count; j++) { TDengineMeta meta = (TDengineMeta)metas[j]; - // Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size); + DebugPrint("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size + "\n"); } IntPtr rowdata; StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) { queryRows++; @@ -561,10 +577,7 @@ namespace TDengineDriver } builder.Append("---"); - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } + VerbosePrint(builder.ToString() + "\n"); builder.Clear(); } @@ -576,13 +589,6 @@ namespace TDengineDriver TDengine.FreeResult(res); } - /* - System.DateTime end = new System.DateTime(); - TimeSpan ts = end - start; - - Console.Write("Total {0:G} rows inserted, {1:G} rows query, time spend {2:G} seconds.\n" - , this.rowsInserted, queryRows, ts.TotalSeconds); - */ } public void CloseConnection() @@ -629,7 +635,18 @@ namespace TDengineDriver tester.batchRows, (tester.recordsPerTable * tester.numOfTables * 1000) / elapsedMs); - tester.ExecuteQuery(); + tester.DebugPrintFormat("query command:{0}\n", tester.query); + if (tester.query != "NONE") + { + watch = Stopwatch.StartNew(); + tester.ExecuteQuery(); + watch.Stop(); + elapsedMs = watch.Elapsed.TotalMilliseconds; + Console.WriteLine("Spent {0} seconds to query {1} records.\n", + elapsedMs/1000, + tester.recordsPerTable * tester.numOfTables + ); + } tester.CloseConnection(); Console.WriteLine("End."); @@ -648,10 +665,11 @@ namespace TDengineDriver public long batchRows { set; get; } public long numOfTables { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } public bool order { set; get; } public short rateOfOutorder { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -659,7 +677,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -667,9 +685,25 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void ThreadMain() { - DebugPrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); DateTime now = DateTime.Now; @@ -678,12 +712,12 @@ namespace TDengineDriver int s = now.Second; long baseTimestamp = 1609430400000; // 2021/01/01 0:0:0 - DebugPrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); + VerbosePrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); long beginTimestamp = baseTimestamp + ((h*60 + m) * 60 + s) * 1000; + Random random = new Random(); long rowsInserted = 0; - // System.DateTime startTime = new System.DateTime(); long i = 0; while (i < recordsPerTable) { @@ -701,8 +735,25 @@ namespace TDengineDriver } for (int batch = 0; batch < batchRows; ++batch) { + long writeTimeStamp = beginTimestamp + i + batch; + int rnd = 100; + if (this.order == false) + { + rnd = random.Next(1, 100); + if (rnd <= this.rateOfOutorder) + { + writeTimeStamp = writeTimeStamp + rnd * 10000; + DebugPrint("### "); + } + DebugPrintFormat("order:{0} rnd:{1} timestamp:{2}\n", this.order, rnd, writeTimeStamp); + } + else + { + DebugPrintFormat("order:{0} timestamp:{1}\n", this.order, writeTimeStamp); + } + sql.Append("(") - .Append(beginTimestamp + i + batch) + .Append(writeTimeStamp) .Append(", 1, 2, 3,") .Append(i + batch) .Append(", 5, 6, 7, 'abc', 'def')"); @@ -711,7 +762,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res == IntPtr.Zero) { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); } inserted += this.batchRows; @@ -740,9 +791,10 @@ namespace TDengineDriver public string tablePrefix { set; get; } public string stablePrefix { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } public bool useStable { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -750,7 +802,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -758,9 +810,17 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + public void ThreadMain() { - DebugPrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); @@ -781,11 +841,11 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); CleanAndExitProgram(); } TDengine.FreeResult(res); -- GitLab