]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search: each_smsg_by_mid uses skeleton if available
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 5 Mar 2018 23:13:47 +0000 (23:13 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 6 Mar 2018 04:51:14 +0000 (04:51 +0000)
We do not need the large DBs for MID scans.

lib/PublicInbox/Search.pm

index dc46ead0e6b0166ea2d0e6febf3e8fa442ea2fbb..7cad31a711d5fa300ec16a030ad22288cfdb79cf 100644 (file)
@@ -409,13 +409,15 @@ sub lookup_article {
 
 sub each_smsg_by_mid {
        my ($self, $mid, $cb) = @_;
-       my $xdb = $self->{xdb};
        # XXX retry_reopen isn't necessary for V2Writable, but the PSGI
        # interface will need it...
-       my ($head, $tail) = $self->find_doc_ids('Q' . $mid);
+       my $db = $self->{skel} || $self->{xdb};
+       my $term = 'Q' . $mid;
+       my $head = $db->postlist_begin($term);
+       my $tail = $db->postlist_end($term);
        for (; $head->nequal($tail); $head->inc) {
                my $doc_id = $head->get_docid;
-               my $doc = $xdb->get_document($doc_id);
+               my $doc = $db->get_document($doc_id);
                my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
                $smsg->{doc_id} = $doc_id;
                $cb->($smsg) or return;