[open-ils-commits] r10066 - in branches/rel_1_2/Open-ILS: examples src/perlmods/OpenILS/Application/Search

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 17 23:05:05 EDT 2008


Author: erickson
Date: 2008-07-17 23:05:04 -0400 (Thu, 17 Jul 2008)
New Revision: 10066

Modified:
   branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
   branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Log:
added support for configurable search page sizes and max pages

Modified: branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
===================================================================
--- branches/rel_1_2/Open-ILS/examples/opensrf.xml.example	2008-07-18 01:51:32 UTC (rev 10065)
+++ branches/rel_1_2/Open-ILS/examples/opensrf.xml.example	2008-07-18 03:05:04 UTC (rev 10066)
@@ -256,6 +256,8 @@
                     <marc_html_xsl>oilsMARC21slim2HTML.xsl</marc_html_xsl>
                     <!-- Default to using staged search -->
                     <use_staged_search>true</use_staged_search>
+                    <superpage_size>1000</superpage_size>
+                    <max_superpages>25</max_superpages>
                     <!-- zip code database file -->
                     <!--<zips_file>/openils/var/data/zips.txt</zips_file>-->
                 </app_settings>

Modified: branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2008-07-18 01:51:32 UTC (rev 10065)
+++ branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2008-07-18 03:05:04 UTC (rev 10066)
@@ -36,13 +36,23 @@
 
 my $cache;
 my $cache_timeout;
+my $superpage_size;
+my $max_superpages;
 
 sub initialize {
 	$cache = OpenSRF::Utils::Cache->new('global');
 	my $sclient = OpenSRF::Utils::SettingsClient->new();
 	$cache_timeout = $sclient->config_value(
 			"apps", "open-ils.search", "app_settings", "cache_timeout" ) || 300;
-	$logger->info("Search cache timeout is $cache_timeout");
+
+	$superpage_size = $sclient->config_value(
+			"apps", "open-ils.search", "app_settings", "superpage_size" ) || 1000;
+
+	$max_superpages = $sclient->config_value(
+			"apps", "open-ils.search", "app_settings", "max_superpages" ) || 25;
+
+	$logger->info("Search cache timeout is $cache_timeout, ".
+        " superpage_size is $superpage_size, max_superpages is $max_superpages");
 }
 
 
@@ -683,8 +693,6 @@
 	api_name	=> 'open-ils.search.metabib.multiclass.staged.staff',
 	signature	=> q/@see open-ils.search.biblio.multiclass.staged/);
 
-my $PAGE_SIZE = 1000;
-my $SEARCH_PAGES = 25;
 sub staged_search {
 	my($self, $conn, $search_hash, $docache) = @_;
 
@@ -704,8 +712,8 @@
     # we're grabbing results on a per-superpage basis, which means the 
     # limit and offset should coincide with superpage boundaries
     $search_hash->{offset} = 0;
-    $search_hash->{limit} = $PAGE_SIZE;
-    $search_hash->{check_limit} = $PAGE_SIZE; # force a well-known check_limit
+    $search_hash->{limit} = $superpage_size;
+    $search_hash->{check_limit} = $superpage_size; # force a well-known check_limit
 
     # pull any existing results from the cache
     my $key = search_cache_key($method, $search_hash);
@@ -717,7 +725,7 @@
     my $page; # current superpage
     my $est_hit_count = 0;
 
-    for($page = 0; $page < $SEARCH_PAGES; $page++) {
+    for($page = 0; $page < $max_superpages; $page++) {
 
         my $data = $cache_data->{$page};
         my $results;
@@ -734,7 +742,7 @@
         } else {
             # retrieve the window of results from the database
             $logger->debug("staged search: fetching results from the database");
-            $search_hash->{skip_check} = $page * $PAGE_SIZE;
+            $search_hash->{skip_check} = $page * $superpage_size;
             my $start = time;
             $results = $U->storagereq($method, %$search_hash);
             $logger->info("staged search: DB call took ".(time - $start)." seconds");
@@ -770,7 +778,7 @@
         last if $current_count >= ($user_limit + $user_offset);
 
         # we've scanned all possible hits
-        last if $summary->{checked} < $PAGE_SIZE;
+        last if $summary->{checked} < $superpage_size;
     }
 
     my @results = grep {defined $_} @$all_results[$user_offset..($user_offset + $user_limit - 1)];



More information about the open-ils-commits mailing list