Skip to content

Commit

Permalink
Trigger new routing algorithm only if hash table is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Mar 13, 2018
1 parent 6eeeb5c commit 64e0eef
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/Query_Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,15 +1147,18 @@ Query_Processor_Output * Query_Processor::process_mysql_query(MySQL_Session *ses
if (qr == NULL || qr->apply == false) {
// now it is time to check mysql_query_rules_fast_routing
// it is only check if "apply" is not true
string s = sess->client_myds->myconn->userinfo->username;
s.append(rand_del);
s.append(sess->client_myds->myconn->userinfo->schemaname);
s.append("---");
s.append(std::to_string(flagIN));
std::unordered_map<std::string, int>:: iterator it;
it = _thr_SQP_rules_fast_routing->find(s);
if (it != _thr_SQP_rules_fast_routing->end()) {
ret->destination_hostgroup = it->second;
size_t mapl = _thr_SQP_rules_fast_routing->size();
if (mapl) { // trigger new routing algorithm only if rules exists
string s = sess->client_myds->myconn->userinfo->username;
s.append(rand_del);
s.append(sess->client_myds->myconn->userinfo->schemaname);
s.append("---");
s.append(std::to_string(flagIN));
std::unordered_map<std::string, int>:: iterator it;
it = _thr_SQP_rules_fast_routing->find(s);
if (it != _thr_SQP_rules_fast_routing->end()) {
ret->destination_hostgroup = it->second;
}
}
}
// FIXME : there is too much data being copied around
Expand Down

0 comments on commit 64e0eef

Please sign in to comment.