]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search: xdb_sharded: make this a public method for ExtSearch
authorEric Wong <e@80x24.org>
Tue, 27 Oct 2020 07:54:08 +0000 (07:54 +0000)
committerEric Wong <e@80x24.org>
Sat, 7 Nov 2020 10:16:14 +0000 (10:16 +0000)
We can simplify callers by using $self->{xpfx} instead of
passing another arg on the stack.

lib/PublicInbox/ExtSearch.pm
lib/PublicInbox/Search.pm

index 9bbe785702a4142de855b3f0cc4af2eea802f6e6..8997cd54da4e25c1186b9be9cf320f15ac553854 100644 (file)
@@ -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...
index 5a57657ff4da5b1332afe8db5ed39b35c06f7d4e..71417d5e9ee471070468edb578e19343f2a72f12 100644 (file)
@@ -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);