From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7D7741FFA7 for ; Tue, 27 Oct 2020 07:54:54 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 07/52] search: xdb_sharded: make this a public method for ExtSearch Date: Tue, 27 Oct 2020 07:54:08 +0000 Message-Id: <20201027075453.19163-8-e@80x24.org> In-Reply-To: <20201027075453.19163-1-e@80x24.org> References: <20201027075453.19163-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can simplify callers by using $self->{xpfx} instead of passing another arg on the stack. --- lib/PublicInbox/ExtSearch.pm | 2 +- lib/PublicInbox/Search.pm | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/ExtSearch.pm b/lib/PublicInbox/ExtSearch.pm index 9bbe7857..8997cd54 100644 --- a/lib/PublicInbox/ExtSearch.pm +++ b/lib/PublicInbox/ExtSearch.pm @@ -23,7 +23,7 @@ sub new { # overrides PublicInbox::Search::_xdb sub _xdb { my ($self) = @_; - $self->_xdb_sharded($self->{xpfx}); + $self->xdb_sharded; } # same as per-inbox ->over, for now... diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 5a57657f..71417d5e 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -190,9 +190,9 @@ sub xdir ($;$) { } } -sub _xdb_sharded { - my ($self, $xpfx) = @_; - opendir(my $dh, $xpfx) or return; # not initialized yet +sub xdb_sharded { + my ($self) = @_; + opendir(my $dh, $self->{xpfx}) or return; # not initialized yet # We need numeric sorting so shard[0] is first for reading # Xapian metadata, if needed @@ -200,7 +200,7 @@ sub _xdb_sharded { return if !defined($last); my (@xdb, $slow_phrase); for (0..$last) { - my $shard_dir = "$xpfx/$_"; + my $shard_dir = "$self->{xpfx}/$_"; if (-d $shard_dir && -r _) { push @xdb, $X{Database}->new($shard_dir); $slow_phrase ||= -f "$shard_dir/iamchert"; @@ -221,7 +221,7 @@ sub _xdb { my $dir = xdir($self, 1); $self->{qp_flags} //= $QP_FLAGS; if ($self->{ibx_ver} >= 2) { - _xdb_sharded($self, $dir); + xdb_sharded($self); } else { $self->{qp_flags} |= FLAG_PHRASE() if !-f "$dir/iamchert"; $X{Database}->new($dir);