From 2d2a3a01f1d6828f37de15bd52a7bae6d64da117 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 25 Oct 2012 00:05:41 +0200 Subject: [PATCH] In bayeswf, dump aux_params before the others, since that is the order we read them in (ie., avoid deadlocks). --- bayeswf.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bayeswf.cpp b/bayeswf.cpp index c7aad7d..eee6882 100644 --- a/bayeswf.cpp +++ b/bayeswf.cpp @@ -422,6 +422,23 @@ int main(int argc, char **argv) pqxx::work txn(conn); txn.exec("SET client_min_messages TO WARNING"); + // Dump aux_params. + { + txn.exec("TRUNCATE aux_params"); + pqxx::tablewriter writer(txn, "aux_params"); + for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { + char str[128]; + snprintf(str, 128, "%f", it->second); + + vector tuple; + tuple.push_back(it->first.first); // locale + tuple.push_back(it->first.second); // parameter name + tuple.push_back(str); + writer.push_back(tuple); + } + writer.complete(); + } + // Dump ratings. { txn.exec("TRUNCATE ratings"); @@ -464,23 +481,6 @@ int main(int argc, char **argv) txn.exec("ALTER TABLE new_covariance ADD PRIMARY KEY ( player1, player2 );"); txn.exec("DROP TABLE IF EXISTS covariance"); txn.exec("ALTER TABLE new_covariance RENAME TO covariance"); - - // Dump aux_params. - { - txn.exec("TRUNCATE aux_params"); - pqxx::tablewriter writer(txn, "aux_params"); - for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { - char str[128]; - snprintf(str, 128, "%f", it->second); - - vector tuple; - tuple.push_back(it->first.first); // locale - tuple.push_back(it->first.second); // parameter name - tuple.push_back(str); - writer.push_back(tuple); - } - writer.complete(); - } #else //fprintf(stderr, "Optimal sigma: %f (two-player: %f)\n", sigma[0], sigma[0] * sqrt(2.0f)); for (map, float>::const_iterator it = aux_params.begin(); it != aux_params.end(); ++it) { -- 2.39.2