diff options
author | Eric Wong <e@80x24.org> | 2020-10-27 07:54:04 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-07 09:55:05 +0000 |
commit | 2694d5ca09c96f6b51f50d94d92a13ba4abd0c79 (patch) | |
tree | 31423b061238e19c26800d74165b2cc9b5a0e63c /lib/PublicInbox | |
parent | e3568a793bbca13f04c5ec8361f6729b19c325ac (diff) | |
download | public-inbox-2694d5ca09c96f6b51f50d94d92a13ba4abd0c79.tar.gz |
This will provide a similar API to PublicInbox::Inbox for read-only WWW, -imapd, and -nntpd interfaces.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/ExtSearch.pm | 40 | ||||
-rw-r--r-- | lib/PublicInbox/Search.pm | 4 |
2 files changed, 42 insertions, 2 deletions
diff --git a/lib/PublicInbox/ExtSearch.pm b/lib/PublicInbox/ExtSearch.pm new file mode 100644 index 00000000..9bbe7857 --- /dev/null +++ b/lib/PublicInbox/ExtSearch.pm @@ -0,0 +1,40 @@ +# Copyright (C) 2020 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> + +# Read-only external (detached) index for cross inbox search. +# This is a read-only counterpart to PublicInbox::ExtSearchIdx +package PublicInbox::ExtSearch; +use strict; +use v5.10.1; +use PublicInbox::Over; + +# for ->reopen, ->mset, ->mset_to_artnums +use parent qw(PublicInbox::Search); + +sub new { + my (undef, $topdir) = @_; + bless { + topdir => $topdir, + # xpfx => 'ei15' + xpfx => "$topdir/ei".PublicInbox::Search::SCHEMA_VERSION + }, __PACKAGE__; +} + +# overrides PublicInbox::Search::_xdb +sub _xdb { + my ($self) = @_; + $self->_xdb_sharded($self->{xpfx}); +} + +# same as per-inbox ->over, for now... +sub over { + my ($self) = @_; + $self->{over} //= PublicInbox::Over->new("$self->{xpfx}/over.sqlite3"); +} + +sub git { + my ($self) = @_; + $self->{git} //= PublicInbox::Git->new("$self->{topdir}/ALL.git"); +} + +1; diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 6346d788..5a57657f 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -245,9 +245,9 @@ sub mset_to_artnums { sub xdb ($) { my ($self) = @_; - $self->{xdb} ||= do { + $self->{xdb} //= do { load_xapian(); - _xdb($self); + $self->_xdb; }; } |