]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/ExtSearch.pm
dd93cd32936d44a866ad82924e001255b513d846
[public-inbox.git] / lib / PublicInbox / ExtSearch.pm
1 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Read-only external (detached) index for cross inbox search.
5 # This is a read-only counterpart to PublicInbox::ExtSearchIdx
6 # and behaves like PublicInbox::Inbox AND PublicInbox::Search
7 package PublicInbox::ExtSearch;
8 use strict;
9 use v5.10.1;
10 use PublicInbox::Over;
11 use PublicInbox::Inbox;
12 use File::Spec ();
13 use PublicInbox::MiscSearch;
14
15 # for ->reopen, ->mset, ->mset_to_artnums
16 use parent qw(PublicInbox::Search);
17
18 sub new {
19         my (undef, $topdir) = @_;
20         $topdir = File::Spec->canonpath($topdir);
21         bless {
22                 topdir => $topdir,
23                 # xpfx => 'ei15'
24                 xpfx => "$topdir/ei".PublicInbox::Search::SCHEMA_VERSION
25         }, __PACKAGE__;
26 }
27
28 sub misc {
29         my ($self) = @_;
30         $self->{misc} //= PublicInbox::MiscSearch->new("$self->{xpfx}/misc");
31 }
32
33 sub search { $_[0] } # self
34
35 # overrides PublicInbox::Search::_xdb
36 sub _xdb {
37         my ($self) = @_;
38         $self->xdb_sharded;
39 }
40
41 # same as per-inbox ->over, for now...
42 sub over {
43         my ($self) = @_;
44         $self->{over} //= PublicInbox::Over->new("$self->{xpfx}/over.sqlite3");
45 }
46
47 sub git {
48         my ($self) = @_;
49         $self->{git} //= PublicInbox::Git->new("$self->{topdir}/ALL.git");
50 }
51
52 sub mm { undef }
53
54 sub altid_map { {} }
55
56 sub description {
57         my ($self) = @_;
58         ($self->{description} //=
59                 PublicInbox::Inbox::cat_desc("$self->{topdir}/description")) //
60                 '$EXTINDEX_DIR/description missing';
61 }
62
63 sub cloneurl { [] } # TODO
64
65 sub base_url { 'https://example.com/TODO/' }
66 sub nntp_url { [] }
67
68 no warnings 'once';
69 *smsg_eml = \&PublicInbox::Inbox::smsg_eml;
70 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
71 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
72 *modified = \&PublicInbox::Inbox::modified;
73 *recent = \&PublicInbox::Inbox::recent;
74
75 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
76
77 1;