about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-06-23 07:14:20 -0400
committerEric Wong <e@80x24.org>2021-06-23 19:24:48 +0000
commit4d594e98063aaad1ce9a90709af7edc5c44a0163 (patch)
tree50e8ac2cb3b74405ae66bf022f10001fe9c69d32 /lib/PublicInbox/LeiSearch.pm
parent2016078cefa7e4438217e54bb0421a5d5f0b151f (diff)
downloadpublic-inbox-4d594e98063aaad1ce9a90709af7edc5c44a0163.tar.gz
This allows us to simplify callers throughout, and exceptions are
can no longer be silently hidden.  MiscSearch now uses xap_terms
for looking up eidx_key terms for a code reduction.

We also simplify LeiStore->_msg_kw for runtime use by moving the
MsetIterator handling into t/lei_store.t test case.
Diffstat (limited to 'lib/PublicInbox/LeiSearch.pm')
-rw-r--r--lib/PublicInbox/LeiSearch.pm16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index d0963e92..06ea6299 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -19,16 +19,13 @@ sub num2docid ($$) {
 }
 
 sub _msg_kw { # retry_reopen callback
-        my ($self, $num) = @_; # num_or_mitem
-        my $xdb = $self->xdb; # set {nshard};
-        my $docid = ref($num) ? $num->get_docid : num2docid($self, $num);
-        my $kw = xap_terms('K', $xdb, $docid);
-        warn "E: #$docid ($num): $@\n" if $@;
-        wantarray ? sort(keys(%$kw)) : $kw;
+        my ($self, $num) = @_;
+        my $xdb = $self->xdb; # set {nshard} for num2docid;
+        xap_terms('K', $xdb, num2docid($self, $num));
 }
 
-sub msg_keywords {
-        my ($self, $num) = @_; # num_or_mitem
+sub msg_keywords { # array or hashref
+        my ($self, $num) = @_;
         $self->retry_reopen(\&_msg_kw, $num);
 }
 
@@ -138,7 +135,8 @@ sub kw_changed {
                 $docids //= [];
                 @$docids = sort { $a <=> $b } values %$xoids;
         }
-        my $cur_kw = msg_keywords($self, $docids->[0]);
+        my $cur_kw = eval { msg_keywords($self, $docids->[0]) };
+        die "E: #$docids->[0] keyword lookup failure: $@\n" if $@;
 
         # RFC 5550 sec 5.9 on the $Forwarded keyword states:
         # "Once set, the flag SHOULD NOT be cleared"