From f4c9ee8ed00c352f4e1ebd2fc8f94d2928c8634b Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 18 Jul 2008 03:06:12 +0000 Subject: [PATCH] added support for configurable search page sizes and max pages git-svn-id: svn://svn.open-ils.org/ILS/trunk@10067 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 f940f9f1ef..a2431850be 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -275,6 +275,8 @@ vim:et:ts=4:sw=4: 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 367e3cdc25..0e123c92c8 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"); } @@ -744,8 +754,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) = @_; @@ -765,8 +773,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); @@ -778,7 +786,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; @@ -795,7 +803,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"); @@ -831,7 +839,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