X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2FPublicInbox%2FSearch.pm;h=7175ddc5a2e06c078ef10f1d7875e3eebd62d709;hb=fad9acd35e56a289ade90a62d056b2a6663d448c;hp=34ebd1a6e7d59b02eaa0931fd1c39413d96e0e56;hpb=8f2999546c9447ce2aed48ba4d1192e0058e28a2;p=public-inbox.git diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 34ebd1a6..7175ddc5 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -304,58 +304,14 @@ sub query_ts { $self->{over_ro}->query_ts($ts, $prev); } -sub first_smsg_by_mid { - my ($self, $mid) = @_; - my $smsg; - retry_reopen($self, sub { - each_smsg_by_mid($self, $mid, sub { $smsg = $_[0]; undef }); - }); - $smsg; -} - sub lookup_article { my ($self, $num) = @_; - my $term = 'XNUM'.$num; - my $db = $self->{xdb}; - retry_reopen($self, sub { - my $head = $db->postlist_begin($term); - my $tail = $db->postlist_end($term); - return if $head->equal($tail); - my $doc_id = $head->get_docid; - return unless defined $doc_id; - $head->inc; - if ($head->nequal($tail)) { - warn "article #$num is not unique\n"; - } - # raises on error: - my $doc = $db->get_document($doc_id); - my $smsg = PublicInbox::SearchMsg->wrap($doc); - $smsg->{doc_id} = $doc_id; - $smsg->load_expand; - }); + $self->{over_ro}->get_art($num); } -sub each_smsg_by_mid { - my ($self, $mid, $cb) = @_; - # XXX retry_reopen isn't necessary for V2Writable, but the PSGI - # interface will need it... - my $db = $self->{xdb}; - my $term = 'Q' . $mid; - my $head = $db->postlist_begin($term); - my $tail = $db->postlist_end($term); - if ($head == $tail) { - $db->reopen; - $head = $db->postlist_begin($term); - $tail = $db->postlist_end($term); - } - return ($head, $tail, $db) if wantarray; - for (; $head->nequal($tail); $head->inc) { - my $doc_id = $head->get_docid; - my $doc = $db->get_document($doc_id); - my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid); - $smsg->{doc_id} = $doc_id; - $cb->($smsg) or return; - } +sub next_by_mid { + my ($self, $mid, $id, $prev) = @_; + $self->{over_ro}->next_by_mid($mid, $id, $prev); } # normalize subjects so they are suitable as pathnames for URLs