From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 04/11] search: move QueryParser mappings to xh_args
Date: Sat, 10 Aug 2024 09:00:05 +0000 [thread overview]
Message-ID: <20240810090012.23269-5-e@80x24.org> (raw)
In-Reply-To: <20240810090012.23269-1-e@80x24.org>
These are stable per-search instance. We'll also deduplicate
the strings in case multiple inboxes share the same mappings.
---
lib/PublicInbox/Search.pm | 23 ++++++++++++-----------
| 2 +-
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index bdf5591c..dfe0271b 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -476,16 +476,7 @@ sub xh_opt ($$) {
push @ret, '-t' if $opt->{threads};
push @ret, '-T', $opt->{threadid} if defined $opt->{threadid};
push @ret, '-O', $opt->{eidx_key} if defined $opt->{eidx_key};
- my $apfx = $self->{-alt_pfx} //= do {
- my @tmp;
- for my $x (@{$self->{-extra} // []}) {
- my $sym = $QPMETHOD_2_SYM{$x->query_parser_method};
- push @tmp, '-Q', $x->{prefix}.$sym.$x->{xprefix};
- }
- # TODO: arbitrary header indexing goes here
- \@tmp;
- };
- (@ret, @$apfx);
+ @ret;
}
# returns a true value if actually handled asynchronously,
@@ -730,7 +721,17 @@ sub all_terms {
}
sub xh_args { # prep getopt args to feed to xap_helper.h socket
- map { ('-d', $_) } shard_dirs($_[0]);
+ my ($self) = @_;
+ my $apfx = $self->{-alt_pfx} //= do {
+ my %dedupe;
+ for my $x (@{$self->{-extra} // []}) {
+ my $sym = $QPMETHOD_2_SYM{$x->query_parser_method};
+ $dedupe{$x->{prefix}.$sym.$x->{xprefix}} = undef;
+ }
+ # TODO: arbitrary header indexing goes here
+ [ sort keys %dedupe ];
+ };
+ ((map { ('-d', $_) } shard_dirs($self)), map { ('-Q', $_) } @$apfx);
}
sub docids_by_postlist ($$) {
--git a/t/watch_indexheader.t b/t/watch_indexheader.t
index e815fca9..623698e7 100644
--- a/t/watch_indexheader.t
+++ b/t/watch_indexheader.t
@@ -84,7 +84,7 @@ $cfg->each_inbox(sub {
my $eml = $ibx->smsg_eml($ibx->over->get_art($num->[0]));
is($eml->header_raw('X-Archives-Hash'), $h1,
'stored message with X-Archives-Hash');
- my @opt = $srch->xh_opt;
+ my @opt = $srch->xh_args;
is $opt[-2], '-Q', 'xap_helper -Q switch';
is $opt[-1], 'xarchiveshash=XXARCHIVESHASH', 'xap_helper -Q arg';
});
next prev parent reply other threads:[~2024-08-10 9:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-10 9:00 [PATCH 00/11] indexheader + altid enhancements Eric Wong
2024-08-10 9:00 ` [PATCH 01/11] search: support per-inbox indexheader directive Eric Wong
2024-08-10 9:00 ` [PATCH 02/11] indexheader: deduplicate common values Eric Wong
2024-08-10 9:00 ` [PATCH 03/11] search: help: avoid ':' in user prefixes Eric Wong
2024-08-10 9:00 ` Eric Wong [this message]
2024-08-10 9:00 ` [PATCH 05/11] www_text: show indexheader contents in help Eric Wong
2024-08-10 9:00 ` [PATCH 06/11] www: don't memoize ->user_help contents Eric Wong
2024-08-10 9:00 ` [PATCH 07/11] extindex: avoid branch in ->index_eml Eric Wong
2024-08-10 9:00 ` [PATCH 08/11] t/extsearch: use autodie to detect chmod failures Eric Wong
2024-08-10 9:00 ` [PATCH 09/11] t/extsearch: use xsys_e to detect errors Eric Wong
2024-08-10 9:00 ` [PATCH 10/11] extindex: support extindex.*.indexheader Eric Wong
2024-08-10 9:00 ` [PATCH 11/11] extindex: support per-inbox indexheader+altid Eric Wong
2024-08-12 13:55 ` [PATCH 00/11] indexheader + altid enhancements Konstantin Ryabitsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240810090012.23269-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).