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: AS57860 185.129.62.0/23 X-Spam-Status: No, score=-1.1 required=3.0 tests=AWL,BAYES_00,KHOP_HELO_FCRDNS, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_ZBI, RCVD_IN_SBL_CSS,RCVD_IN_XBL,SPF_FAIL,SPF_HELO_FAIL, TO_EQ_FM_DOM_SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.6 Received: from 80x24.org (tor01.zencurity.com [185.129.62.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id EAA971F626 for ; Thu, 23 Feb 2023 18:26:53 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] search: relocate all_terms from lei_search Date: Thu, 23 Feb 2023 18:26:48 +0000 Message-Id: <20230223182648.926255-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will be used for code_search, too. --- lib/PublicInbox/LeiSearch.pm | 14 -------------- lib/PublicInbox/Search.pm | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm index 936c2751..ba4c4309 100644 --- a/lib/PublicInbox/LeiSearch.pm +++ b/lib/PublicInbox/LeiSearch.pm @@ -158,20 +158,6 @@ sub kw_changed { join("\0", @$new_kw_sorted) eq $cur_kw ? 0 : 1; } -sub all_terms { - my ($self, $pfx) = @_; - my $xdb = $self->xdb; - my $cur = $xdb->allterms_begin($pfx); - my $end = $xdb->allterms_end($pfx); - my %ret; - for (; $cur != $end; $cur++) { - my $tn = $cur->get_termname; - index($tn, $pfx) == 0 and - $ret{substr($tn, length($pfx))} = undef; - } - wantarray ? (sort keys %ret) : \%ret; -} - sub qparse_new { my ($self) = @_; my $qp = $self->SUPER::qparse_new; # PublicInbox::Search diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 1d77615a..fc868d8d 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -564,4 +564,18 @@ sub num2docid ($$) { ($num - 1) * $nshard + $num % $nshard + 1; } +sub all_terms { + my ($self, $pfx) = @_; + my $cur = xdb($self)->allterms_begin($pfx); + my $end = $self->{xdb}->allterms_end($pfx); + my %ret; + for (; $cur != $end; $cur++) { + my $tn = $cur->get_termname; + index($tn, $pfx) == 0 and + $ret{substr($tn, length($pfx))} = undef; + } + wantarray ? (sort keys %ret) : \%ret; +} + + 1;