diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-02 03:39:09 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-02 09:07:54 +0000 |
commit | faf36e5b451bd5dba0b1ae867f606ba0cb397af3 (patch) | |
tree | 67bea99b1ba855b13330a2156f894979052f99c0 /lib/PublicInbox/Search.pm | |
parent | c062644c64bf44b48bd6469e1d4e77d8b9cfdc87 (diff) | |
download | public-inbox-faf36e5b451bd5dba0b1ae867f606ba0cb397af3.tar.gz |
This is a bit expensive in a multi-process situation because we need to make our indices and packs visible to the read-only pieces.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r-- | lib/PublicInbox/Search.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 21c72b6f..c074410c 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -371,6 +371,22 @@ sub lookup_mail { # no ghosts! }); } +sub each_smsg_by_mid { + my ($self, $mid, $cb) = @_; + $mid = mid_clean($mid); + 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('XMID' . $mid); + for (; $head->nequal($tail); $head->inc) { + my $doc_id = $head->get_docid; + my $doc = $xdb->get_document($doc_id); + my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid); + $smsg->{doc_id} = $doc_id; + $cb->($smsg) or return; + } +} + sub find_unique_doc_id { my ($self, $termval) = @_; |