From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 340C81FC5A for ; Sat, 10 Aug 2024 09:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1723280414; bh=RS9IRabSXLZGfUQBxDxqHVcdVQ/wjZxLbMvGjOTccBc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SbC6GsHLhGev2wXYbl0kfDyomW9rkglo9lKFlPLew32giguOlFGuSHCwJrp/7NuZW dYw7PcapzePhovnGiMloXEAIZr/zxCl5+Qbk0F1psD3AV7cIdjVbWzSw1ajFUWaOEI WlAPs9N6vYJWOCXYtmjpHe12E5zolQa1xPNZ4+dQ= From: Eric Wong 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 Message-ID: <20240810090012.23269-5-e@80x24.org> In-Reply-To: <20240810090012.23269-1-e@80x24.org> References: <20240810090012.23269-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 ++++++++++++----------- t/watch_indexheader.t | 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 ($$) { diff --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'; });