From 04f9345b15b019142ee13ce35076a60bd7a03ada Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 18 Jul 2008 03:05:04 +0000 Subject: [PATCH] added support for configurable search page sizes and max pages git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@10066 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/opensrf.xml.example | 2 ++ .../perlmods/OpenILS/Application/Search/Biblio.pm | 24 ++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 9a2abd5dc6..fcf89f603d 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -256,6 +256,8 @@ Example opensrf config file for OpenILS oilsMARC21slim2HTML.xsl true + 1000 + 25 diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 14ee02caba..1cf183c1e4 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -36,13 +36,23 @@ my $pfx = "open-ils.search_"; 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 @@ __PACKAGE__->register_method( 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 @@ sub staged_search { # 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 @@ sub staged_search { 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 @@ sub staged_search { } 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 @@ sub staged_search { 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)]; -- 2.11.0