This article is deprecated.
Wait on worker processes and return the vector of query results.
Prototype
Vector<Table> *waitMany();Arguments
void No arguments Description
This method waits on the worker processes and returns a vector containing the results of each query launched by
executeMany()
.Returns
A vector containing the results of each query launched by
executeMany()
.Example
The following snippet defines a vector of query strings and 9 arguments to be substituted into the queries; then calls
executeMany()
to process these queries in parallel. The query results are then returned bywaitMany()
and the first result is printed out:const size_t nWorkers = 4; const char *nodes[] = { "localhost:5001", "localhost:5002" }; int main(int argc, char** argv) { try { McoSql::Allocator my_allocator; McoSql::AsyncDistributedSqlEngine engine(nWorkers); if (!engine.open(nodes, sizeof(nodes) / sizeof(nodes[0]))) { printf("Open failed: %s\n", engine.getError()->cstr()); return 1; } ... McoSql::Vector<McoSql::String> *queries = McoSql::Vector<McoSql::String>::create(&my_allocator, nWorkers); for (size_t i = 0; i < nWorkers; i++) { queries->items[i] = McoSql::String::create( &my_allocator, "INSERT INTO MyTable(pk, value, u2, i1, i2, i4, i8, flt, dbl) VALUES (%v, %v, %v, %v, %v, %v, %v, %v, %v)"); } McoSql::Vector<McoSql::ConnectionArgs> *args = McoSql::Vector<McoSql::ConnectionArgs>::create(&my_allocator, nWorkers); for (size_t i = 0; i < nWorkers; i++) { McoSql::ConnectionArgs *ca = new McoSql::ConnectionArgs(&my_allocator, 9 /*nParams*/); ca->args[0] = McoSql::IntValue::create(&my_allocator, i*100); ca->args[1] = McoSql::String::format(&my_allocator, "str%d", i); ca->args[2] = McoSql::IntValue::create(&my_allocator, i); ca->args[3] = McoSql::IntValue::create(&my_allocator, i); ca->args[4] = McoSql::IntValue::create(&my_allocator, i); ca->args[5] = McoSql::IntValue::create(&my_allocator, i); ca->args[6] = McoSql::IntValue::create(&my_allocator, i); ca->args[7] = McoSql::RealValue::create(&my_allocator, i*100); ca->args[8] = McoSql::RealValue::create(&my_allocator, i*100); args->items[i] = ca; } McoSql::Allocator ret_allocator; engine.executeMany(queries, args, &ret_allocator); McoSql::Vector< McoSql::Table> *vret = engine.waitMany(); McoSql::Table *sret = vret->at(0); printf (" Single query Fields are:\n"); for (size_t fno = 0; fno < sret->fields()->length; fno++) { printf (" %s - %d\n", sret->fields()->at(fno)->name()->cstr(), sret->fields()->at(fno)->type()); } printf ("\n"); } }