Merge "db-campaign: load completed pilots in one query"
This commit is contained in:
@ -79,12 +79,14 @@ bool DatabaseCampaign::run() {
|
|||||||
boost::thread collect_thread(&DatabaseCampaign::collect_result_thread, this);
|
boost::thread collect_thread(&DatabaseCampaign::collect_result_thread, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
||||||
|
|
||||||
|
|
||||||
|
// Which Pilots were already processed?
|
||||||
|
load_completed_pilots(variants);
|
||||||
|
|
||||||
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
||||||
it != variants.end(); ++it) {
|
it != variants.end(); ++it) {
|
||||||
// Which Pilots were already processed?
|
|
||||||
load_completed_pilots(*it);
|
|
||||||
|
|
||||||
// Push all other variants to the queue
|
// Push all other variants to the queue
|
||||||
if (!run_variant(*it)) {
|
if (!run_variant(*it)) {
|
||||||
@ -219,15 +221,27 @@ bool DatabaseCampaign::run_variant(Database::Variant variant) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseCampaign::load_completed_pilots(Database::Variant variant)
|
void DatabaseCampaign::load_completed_pilots(std::vector<Database::Variant> &variants)
|
||||||
{
|
{
|
||||||
|
// If no variants were given, do nothing
|
||||||
|
if (variants.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// load list of partially or completely finished pilots
|
// load list of partially or completely finished pilots
|
||||||
log_send << "loading completed pilot IDs ... (" << variant.variant << "/"
|
std::stringstream variant_str;
|
||||||
<< variant.benchmark << ")" << std::endl;
|
bool comma = false;
|
||||||
|
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
||||||
|
it != variants.end(); ++it) {
|
||||||
|
if (comma) variant_str << ", ";
|
||||||
|
variant_str << it->id;
|
||||||
|
comma = true; // Next time we need a comma
|
||||||
|
}
|
||||||
|
log_send << "loading completed pilot IDs ..." << std::endl;
|
||||||
|
|
||||||
std::stringstream sql;
|
std::stringstream sql;
|
||||||
sql << "SELECT pilot_id, COUNT(*) FROM fsppilot p"
|
sql << "SELECT pilot_id, COUNT(*) FROM fsppilot p"
|
||||||
<< " JOIN " << db_connect.result_table() << " r ON r.pilot_id = p.id"
|
<< " JOIN " << db_connect.result_table() << " r ON r.pilot_id = p.id"
|
||||||
<< " WHERE variant_id = " << variant.id
|
<< " WHERE variant_id in (" << variant_str.str() << ")"
|
||||||
<< " GROUP BY pilot_id ";
|
<< " GROUP BY pilot_id ";
|
||||||
MYSQL_RES *ids = db->query_stream(sql.str().c_str());
|
MYSQL_RES *ids = db->query_stream(sql.str().c_str());
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class DatabaseCampaign : public Campaign {
|
|||||||
int fspmethod_id; // !< Which fspmethod should be put out to the clients
|
int fspmethod_id; // !< Which fspmethod should be put out to the clients
|
||||||
|
|
||||||
void collect_result_thread();
|
void collect_result_thread();
|
||||||
void load_completed_pilots(fail::Database::Variant);
|
void load_completed_pilots(std::vector<fail::Database::Variant> &);
|
||||||
unsigned existing_results_for_pilot(unsigned pilot_id);
|
unsigned existing_results_for_pilot(unsigned pilot_id);
|
||||||
|
|
||||||
#ifndef __puma
|
#ifndef __puma
|
||||||
|
|||||||
Reference in New Issue
Block a user