private static async Task ExecuteQueries() { string dbname = cliArgs[1]; string cname = cliArgs[2]; string infile = cliArgs[3]; cosmosClient = CosmosClientFactory.RegularClient(); CosmosQueryUtil util = new CosmosQueryUtil(cosmosClient, config.IsVerbose()); await util.SetCurrentDatabase(dbname); await util.SetCurrentContainer(cname); // Console.WriteLine("warming sdk client..."); for (int i = 0; i < 2; i++) { await util.CountDocuments(""); } foreach (string line in File.ReadLines(infile)) { string[] tokens = line.Split("|"); if (tokens.Length > 1) { string qname = tokens[0].Trim(); string sql = tokens[1].Trim(); if (qname.StartsWith("q")) { Console.WriteLine(""); Console.WriteLine("================================================================================"); Console.WriteLine($"executing qname: {qname}, db: {dbname}, cname: {cname}, sql: {sql}"); QueryResponse respObj = await util.ExecuteQuery(sql); respObj.queryName = qname; respObj.sql = sql; respObj.dbname = dbname; respObj.cname = cname; respObj.Finish(); Console.WriteLine(respObj.ToString()); string jstr = respObj.ToJson(); if (config.IsVerbose()) { Console.WriteLine(jstr); } await File.WriteAllTextAsync(respObj.filename, jstr); Console.WriteLine($"file written: {respObj.filename}"); } } } }
private static async Task CountDocuments() { string dbname = cliArgs[1]; string cname = cliArgs[2]; cosmosClient = CosmosClientFactory.RegularClient(); CosmosQueryUtil util = new CosmosQueryUtil(cosmosClient, config.IsVerbose()); await util.SetCurrentDatabase(dbname); await util.SetCurrentContainer(cname); int count = (await util.CountDocuments("")).items[0]; Console.WriteLine($"CountDocuments {dbname} {cname} -> {count}"); }