about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchView.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-08-20 20:24:51 +0000
committerEric Wong <e@yhbt.net>2020-08-20 21:11:19 +0000
commit69db106e1eedb0468ccff85e9304667471bc042b (patch)
treecf97feb2d8c42d870c50dec52d36a29d4fb9469f /lib/PublicInbox/SearchView.pm
parent5a69dffc4155c8810dd8f2f3474f7a8a5c6d16a2 (diff)
downloadpublic-inbox-69db106e1eedb0468ccff85e9304667471bc042b.tar.gz
git blob retrieval dominates on these, "&x=t" (nested) is
roughly the same due to increased overhead for ->get_percent
storage balancing out the mass-loading from SQLite.

Atom "&x=A" is sped up slightly and uses less memory in the
long-lived response.
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r--lib/PublicInbox/SearchView.pm25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index a3527057..ef1b9767 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -255,20 +255,13 @@ sub get_pct ($) {
         $n > 99 ? 99 : $n;
 }
 
-sub load_msgs {
-        my ($mset) = @_;
-        [ map {
-                my $mi = $_;
-                my $smsg = PublicInbox::Smsg::from_mitem($mi);
-                $smsg->{pct} = get_pct($mi);
-                $smsg;
-        } ($mset->items) ]
-}
-
 sub mset_thread {
         my ($ctx, $mset, $q) = @_;
         my $ibx = $ctx->{-inbox};
-        my $msgs = $ibx->search->retry_reopen(\&load_msgs, $mset);
+        my $nshard = $ibx->search->{nshard} // 1;
+        my %pct = map { mdocid($nshard, $_) => get_pct($_) } $mset->items;
+        my $msgs = $ibx->over->get_all(keys %pct);
+        $_->{pct} = $pct{$_->{num}} for @$msgs;
         my $r = $q->{r};
         my $rootset = PublicInbox::SearchThread::thread($msgs,
                 $r ? \&sort_relevance : \&PublicInbox::View::sort_ds,
@@ -323,7 +316,8 @@ sub ctx_prepare {
 
 sub adump {
         my ($cb, $mset, $q, $ctx) = @_;
-        $ctx->{items} = [ $mset->items ];
+        my $nshard = $ctx->{-inbox}->search->{nshard} // 1;
+        $ctx->{ids} = [ map { mdocid($nshard, $_) } $mset->items ];
         $ctx->{search_query} = $q; # used by WwwAtomStream::atom_header
         PublicInbox::WwwAtomStream->response($ctx, 200, \&adump_i);
 }
@@ -331,11 +325,8 @@ sub adump {
 # callback for PublicInbox::WwwAtomStream::getline
 sub adump_i {
         my ($ctx) = @_;
-        while (my $mi = shift @{$ctx->{items}}) {
-                my $srch = $ctx->{-inbox}->search(undef, $ctx) or return;
-                my $smsg = eval {
-                        PublicInbox::Smsg::from_mitem($mi, $srch);
-                } or next;
+        while (my $num = shift @{$ctx->{ids}}) {
+                my $smsg = eval { $ctx->{-inbox}->over->get_art($num) } or next;
                 return $smsg;
         }
 }