session_shared: resultset optimizesearch flag.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 24 Nov 2010 14:24:11 +0000 (15:24 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 24 Nov 2010 14:24:11 +0000 (15:24 +0100)
etc/config-shared1.xml
src/filter_session_shared.cpp
xml/schema/metaproxy.rnc
xml/schema/metaproxy.rng
xml/schema/metaproxy.xsd

index 0dc2b2d..9e6b77e 100644 (file)
@@ -20,7 +20,7 @@
         <limit bandwidth="50000" pdu="100" search="5" retrieve="50"/>
       </filter>
       <filter type="session_shared"> 
-       <resultset ttl="10" max="3"/>
+       <resultset ttl="10" max="3" optimizesearch="false"/>
        <session ttl="30"/>
       </filter>
       <filter type="log">
index f0f84f7..9ec7648 100644 (file)
@@ -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 *)
index 12990f0..d80c9e6 100644 (file)
@@ -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 }
index 3ffd1c4..1e7ae21 100644 (file)
         <attribute name="ttl">
           <data type="integer"/>
         </attribute>
+        <attribute name="optimizesearch">
+          <data type="boolean"/>
+        </attribute>
       </element>
     </optional>
     <optional>
index 1f1e86e..d893dd0 100644 (file)
     <xs:complexType>
       <xs:attribute name="max" use="required" type="xs:integer"/>
       <xs:attribute name="ttl" use="required" type="xs:integer"/>
+      <xs:attribute name="optimizesearch" use="required" type="xs:boolean"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="session">