From 3817746d6c53f74f74451d53f018e73db6ca6bb6 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 19 Feb 2018 16:48:33 -0500 Subject: [PATCH] LP#1744385: Parallelize highlight gathering with XML feed retrieval Signed-off-by: Mike Rylander Signed-off-by: Kathy Lussier Signed-off-by: Dan Wells --- .../lib/OpenILS/Application/Search/Biblio.pm | 3 ++- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 14 +++++++++++++- .../lib/OpenILS/WWW/EGCatLoader/Util.pm | 17 ++++++++++++++++- Open-ILS/src/templates/opac/parts/misc_util.tt2 | 2 -- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 96e6a18d96..ca3f85a27f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -1342,7 +1342,8 @@ sub fetch_display_fields { } __PACKAGE__->register_method( method => 'fetch_display_fields', - api_name => 'open-ils.search.fetch.metabib.display_field.highlight' + api_name => 'open-ils.search.fetch.metabib.display_field.highlight', + stream => 1 ); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index c243d728a6..e753057077 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -346,12 +346,24 @@ sub load_common { $ctx->{fetch_display_fields} = sub { my $id = shift; - return $U->simplereq( + + if (@$id == 1) { + return $ctx->{_hl_data}{''.$$id[0]} + if ($ctx->{_hl_data}{''.$$id[0]}); + } + + $self->timelog("HL data not cached, fetching from server."); + + my $rows = $U->simplereq( 'open-ils.search', 'open-ils.search.fetch.metabib.display_field.highlight', $ctx->{query_struct}{additional_data}{highlight_map}, map {int($_)} @$id ); + + $ctx->{_hl_data}{''.$$id[0]} = $rows if (@$id == 1); + + return $rows; }; return Apache2::Const::OK; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index c788761030..5505cd619f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -374,6 +374,7 @@ sub get_records_and_facets { ); my %tmp_data; + my %hl_tmp_data; my $outer_self = $self; my $sdepth = $unapi_args->{flesh_depth}; @@ -385,6 +386,7 @@ sub get_records_and_facets { $flesh =~ s/}$/,mmr.unapi}/g if $is_meta; my $ses = OpenSRF::AppSession->create('open-ils.cstore'); + my $hl_ses = OpenSRF::AppSession->create('open-ils.search'); my @loop_recs; for my $bid (@$rec_ids) { @@ -410,6 +412,13 @@ sub get_records_and_facets { ]} ); + my $hl_req = $hl_ses->request( + 'open-ils.search.fetch.metabib.display_field.highlight.atomic', + $self->ctx->{query_struct}{additional_data}{highlight_map}, + @$rec_ids + ) if (!$is_meta); + + my $facets = {}; if ($facet_req) { $self->timelog("get_records_and_facets():almost ready to fetch facets"); @@ -444,7 +453,13 @@ sub get_records_and_facets { my $data = $unapi_req->gather(1); - $outer_self->timelog("get_records_and_facets(): got response content"); + $outer_self->timelog("get_records_and_facets(): got feed content"); + + if (!$is_meta) { + my $hl_data = $hl_req->gather(1); # list of arrayref of hashrefs + $self->ctx->{_hl_data} = { map { ''.$$_[0]{source} => $_ } @$hl_data }; + $outer_self->timelog("get_records_and_facets(): got highlighting content (". keys(%{$self->ctx->{_hl_data}}).")"); + } # Protect against requests for non-existent records return unless $data->{$unapi_type}; diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index e8d48959b6..e4bf98c8ba 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -110,9 +110,7 @@ args.hl = {}; IF !CGI.param('no_highlight') && !search.no_highlight; - junk = ctx.timelog('Fetching of highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); args.display_field_list = ctx.fetch_display_fields(args.df_bib_list.list); - junk = ctx.timelog('Finished fetch of highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); junk = ctx.timelog('Mapping highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); FOR df IN args.display_field_list; -- 2.43.2