From 9435e2f775f3b88c27734462c96c17b22b0f9d3d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 24 Nov 2010 15:24:11 +0100 Subject: [PATCH] session_shared: resultset optimizesearch flag. --- etc/config-shared1.xml | 2 +- src/filter_session_shared.cpp | 38 ++++++++++++++++++++++++-------------- xml/schema/metaproxy.rnc | 3 ++- xml/schema/metaproxy.rng | 3 +++ xml/schema/metaproxy.xsd | 1 + 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/etc/config-shared1.xml b/etc/config-shared1.xml index 0dc2b2d..9e6b77e 100644 --- a/etc/config-shared1.xml +++ b/etc/config-shared1.xml @@ -20,7 +20,7 @@ - + diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index f0f84f7..9ec7648 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -190,6 +190,7 @@ namespace metaproxy_1 { int m_resultset_ttl; int m_resultset_max; int m_session_ttl; + bool m_optimize_search; }; } } @@ -618,25 +619,28 @@ restart: BackendClassPtr bc = m_backend_class; { boost::mutex::scoped_lock lock(bc->m_mutex_backend_class); - // look at each backend and see if we have a similar search - BackendInstanceList::const_iterator it = bc->m_backend_list.begin(); - for (; it != bc->m_backend_list.end(); it++) + if (m_p->m_optimize_search) { - if (!(*it)->m_in_use) + // look at each backend and see if we have a similar search + BackendInstanceList::const_iterator it = bc->m_backend_list.begin(); + for (; it != bc->m_backend_list.end(); it++) { - BackendSetList::const_iterator set_it = (*it)->m_sets.begin(); - for (; set_it != (*it)->m_sets.end(); set_it++) + if (!(*it)->m_in_use) { - if ((*set_it)->m_databases == databases - && query.match(&(*set_it)->m_query)) + BackendSetList::const_iterator set_it = (*it)->m_sets.begin(); + for (; set_it != (*it)->m_sets.end(); set_it++) { - found_set = *set_it; - found_backend = *it; - bc->use_backend(found_backend); - found_set->timestamp(); - // found matching set. No need to search again - return; + if ((*set_it)->m_databases == databases + && query.match(&(*set_it)->m_query)) + { + found_set = *set_it; + found_backend = *it; + bc->use_backend(found_backend); + found_set->timestamp(); + // found matching set. No need to search again + return; + } } } } @@ -1018,6 +1022,7 @@ yf::SessionShared::Rep::Rep() m_resultset_ttl = 30; m_resultset_max = 10; m_session_ttl = 90; + m_optimize_search = true; } void yf::SessionShared::Rep::start() @@ -1173,6 +1178,11 @@ void yf::SessionShared::configure(const xmlNode *ptr, bool test_only) m_p->m_resultset_max = mp::xml::get_int(attr->children, 10); } + else if (!strcmp((const char *) attr->name, "optimizesearch")) + { + m_p->m_optimize_search = + mp::xml::get_bool(attr->children, true); + } else throw mp::filter::FilterException( "Bad attribute " + std::string((const char *) diff --git a/xml/schema/metaproxy.rnc b/xml/schema/metaproxy.rnc index 12990f0..d80c9e6 100644 --- a/xml/schema/metaproxy.rnc +++ b/xml/schema/metaproxy.rnc @@ -168,7 +168,8 @@ filter_session_shared = attribute name { xsd:NCName }?, element mp:resultset { attribute max { xsd:integer }, - attribute ttl { xsd:integer } + attribute ttl { xsd:integer }, + attribute optimizesearch { xsd:boolean } }?, element mp:session { attribute ttl { xsd:integer } diff --git a/xml/schema/metaproxy.rng b/xml/schema/metaproxy.rng index 3ffd1c4..1e7ae21 100644 --- a/xml/schema/metaproxy.rng +++ b/xml/schema/metaproxy.rng @@ -431,6 +431,9 @@ + + + diff --git a/xml/schema/metaproxy.xsd b/xml/schema/metaproxy.xsd index 1f1e86e..d893dd0 100644 --- a/xml/schema/metaproxy.xsd +++ b/xml/schema/metaproxy.xsd @@ -360,6 +360,7 @@ + -- 1.7.10.4