]> Sergey Matveev's repositories - public-inbox.git/commitdiff
rename PublicInbox::SearchMsg => PublicInbox::Smsg
authorEric Wong <e@yhbt.net>
Fri, 20 Mar 2020 08:18:15 +0000 (08:18 +0000)
committerEric Wong <e@yhbt.net>
Sun, 22 Mar 2020 09:00:23 +0000 (09:00 +0000)
Since the introduction of over.sqlite3, SearchMsg is not tied to
our search functionality in any way, so stop confusing ourselves
and future hackers by just calling it "PublicInbox::Smsg".

Add a missing "use" in ExtMsg while we're at it.

17 files changed:
Documentation/mknews.perl
Documentation/technical/data_structures.txt
MANIFEST
lib/PublicInbox/ExtMsg.pm
lib/PublicInbox/Feed.pm
lib/PublicInbox/Inbox.pm
lib/PublicInbox/Mbox.pm
lib/PublicInbox/NNTP.pm
lib/PublicInbox/Over.pm
lib/PublicInbox/OverIdx.pm
lib/PublicInbox/Search.pm
lib/PublicInbox/SearchIdx.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/Smsg.pm [moved from lib/PublicInbox/SearchMsg.pm with 93% similarity]
lib/PublicInbox/SolverGit.pm
lib/PublicInbox/View.pm
t/thread-cycle.t

index d803ca7753b1b716dc7cb05003194e419220eba8..adb83832d75d49f05f52c69fb1e21ce7593cfdd3 100755 (executable)
@@ -103,7 +103,7 @@ sub mime2txt {
 
 sub mime2html {
        my ($out, $mime, $ctx) = @_;
-       my $smsg = bless { mime => $mime }, 'PublicInbox::SearchMsg';
+       my $smsg = bless { mime => $mime }, 'PublicInbox::Smsg';
        print $out PublicInbox::View::index_entry($smsg, $ctx, 1) or die;
 }
 
@@ -147,7 +147,7 @@ EOF
 
 sub mime2atom  {
        my ($out, $astream, $mime, $ctx) = @_;
-       my $smsg = bless { mime => $mime }, 'PublicInbox::SearchMsg';
+       my $smsg = bless { mime => $mime }, 'PublicInbox::Smsg';
        if (defined(my $str = $astream->feed_entry($smsg))) {
                print $out $str or die;
        }
index 4de83a77b44d377c7f1a82c25664c4a08a533237..08dfc7ac0dbfb321eb1d8712b0ca9b792d1e75da 100644 (file)
@@ -47,7 +47,7 @@ Per-message classes
   Our PublicInbox::V2Writable class may have two objects of this
   type in memory at-a-time for deduplication.
 
-* PublicInbox::SearchMsg - small message skeleton
+* PublicInbox::Smsg - small message skeleton
   Used by: PublicInbox::{NNTP,WWW,SearchIdx}
   Common abbreviation: $smsg
 
@@ -69,7 +69,7 @@ Per-message classes
   JWZ's algorithm: <https://www.jwz.org/doc/threading.html>.
   This holds a $smsg and is only used for message threading.
   This wrapper class may go away in the future and handled
-  directly by PublicInbox::SearchMsg to save memory.
+  directly by PublicInbox::Smsg to save memory.
 
   As with $smsg objects, there may be hundreds or thousands
   of these objects in memory at-a-time.
index f9230cd32fa2c906e5917fd0a99d4094db7de8dd..ec80c90fae7bb5fcb48d82eebf706a506aece9c0 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -145,10 +145,10 @@ lib/PublicInbox/SaPlugin/ListMirror.pod
 lib/PublicInbox/Search.pm
 lib/PublicInbox/SearchIdx.pm
 lib/PublicInbox/SearchIdxShard.pm
-lib/PublicInbox/SearchMsg.pm
 lib/PublicInbox/SearchThread.pm
 lib/PublicInbox/SearchView.pm
 lib/PublicInbox/Sigfd.pm
+lib/PublicInbox/Smsg.pm
 lib/PublicInbox/SolverGit.pm
 lib/PublicInbox/Spamcheck.pm
 lib/PublicInbox/Spamcheck/Spamc.pm
index 44884ad286354aa9a95841fb5b3b171df0d19cc2..4d753a7e8f00feca8089d0e8f6caa469bcc6dc0b 100644 (file)
@@ -10,6 +10,7 @@ use strict;
 use warnings;
 use PublicInbox::Hval qw(ascii_html prurl mid_href);
 use PublicInbox::WwwStream;
+use PublicInbox::Smsg;
 our $MIN_PARTIAL_LEN = 16;
 
 # TODO: user-configurable
@@ -29,7 +30,7 @@ our @EXT_URL = map { ascii_html($_) } (
 sub PARTIAL_MAX () { 100 }
 
 sub mids_from_mset { # Search::retry_reopen callback
-       [ map { PublicInbox::SearchMsg::from_mitem($_)->mid } $_[0]->items ];
+       [ map { PublicInbox::Smsg::from_mitem($_)->mid } $_[0]->items ];
 }
 
 sub search_partial ($$) {
index ae69af368e4d38cc111e51a37ee1dcc1fd62997e..07347c63239f6af428241d12a23789c75ee99bed 100644 (file)
@@ -8,7 +8,7 @@ use warnings;
 use PublicInbox::MIME;
 use PublicInbox::View;
 use PublicInbox::WwwAtomStream;
-use PublicInbox::SearchMsg; # this loads w/o Search::Xapian
+use PublicInbox::Smsg; # this loads w/o Search::Xapian
 
 sub generate_i {
        my ($ctx) = @_;
@@ -142,7 +142,7 @@ sub recent_msgs {
        }
 
        $ctx->{next_page} = "r=$last_commit" if $last_commit;
-       [ map { bless {blob => $_ }, 'PublicInbox::SearchMsg' } @oids ];
+       [ map { bless {blob => $_ }, 'PublicInbox::Smsg' } @oids ];
 }
 
 1;
index 06ce9ebf8c464c3236760a17c60a686f430e8663..4f27d1bbb65f9aa5dee21b66aa5eb8202004f796 100644 (file)
@@ -346,7 +346,7 @@ sub smsg_by_mid ($$) {
        # favor the Message-ID we used for the NNTP article number:
        defined(my $num = mid2num($self, $mid)) or return;
        my $smsg = $over->get_art($num) or return;
-       PublicInbox::SearchMsg::psgi_cull($smsg);
+       PublicInbox::Smsg::psgi_cull($smsg);
 }
 
 sub msg_by_mid ($$;$) {
index 5693d30b1c5ab80ce08fe56f694ffd84b94d7522..4f632d63558935c62b5e0af1ea882c81e39768a0 100644 (file)
@@ -12,7 +12,7 @@ use strict;
 use warnings;
 use PublicInbox::MID qw/mid_escape/;
 use PublicInbox::Hval qw/to_filename/;
-use PublicInbox::SearchMsg;
+use PublicInbox::Smsg;
 use Email::Simple;
 use Email::MIME::Encode;
 
@@ -204,7 +204,7 @@ sub results_cb {
        my $srch = $ctx->{srch};
        while (1) {
                while (my $mi = (($mset->items)[$ctx->{iter}++])) {
-                       my $smsg = PublicInbox::SearchMsg::from_mitem($mi,
+                       my $smsg = PublicInbox::Smsg::from_mitem($mi,
                                                                $srch) or next;
                        return $smsg;
                }
index 84335d30c131f745c4a1a8143b6567696fd574aa..277657e602cb3feba30310d715608bf771747379 100644 (file)
@@ -714,11 +714,11 @@ sub hdr_xref ($$$) { # optimize XHDR Xref [range] for rtin
 sub over_header_for {
        my ($over, $num, $field) = @_;
        my $smsg = $over->get_art($num) or return;
-       return PublicInbox::SearchMsg::date($smsg) if $field eq 'date';
+       return PublicInbox::Smsg::date($smsg) if $field eq 'date';
        $smsg->{$field};
 }
 
-sub searchmsg_range_i {
+sub smsg_range_i {
        my ($self, $beg, $end, $field) = @_;
        my $over = $self->{ng}->over;
        my $msgs = $over->query_xover($$beg, $end);
@@ -732,7 +732,7 @@ sub searchmsg_range_i {
        $$beg = $msgs->[-1]->{num} + 1;
 }
 
-sub hdr_searchmsg ($$$$) {
+sub hdr_smsg ($$$$) {
        my ($self, $xhdr, $field, $range) = @_;
        if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
                my ($ng, $n) = mid_lookup($self, $1);
@@ -744,7 +744,7 @@ sub hdr_searchmsg ($$$$) {
                my $r = get_range($self, $range);
                return $r unless ref $r;
                more($self, $xhdr ? r221 : r225);
-               long_response($self, \&searchmsg_range_i, @$r, $field);
+               long_response($self, \&smsg_range_i, @$r, $field);
        }
 }
 
@@ -757,9 +757,9 @@ sub do_hdr ($$$;$) {
                hdr_xref($self, $xhdr, $range);
        } elsif ($sub =~ /\A(?:subject|references|date|from|to|cc|
                                bytes|lines)\z/x) {
-               hdr_searchmsg($self, $xhdr, $sub, $range);
+               hdr_smsg($self, $xhdr, $sub, $range);
        } elsif ($sub =~ /\A:(bytes|lines)\z/) {
-               hdr_searchmsg($self, $xhdr, $1, $range);
+               hdr_smsg($self, $xhdr, $1, $range);
        } else {
                $xhdr ? (r221 . "\r\n.") : "503 HDR not permitted on $header";
        }
@@ -831,7 +831,7 @@ sub over_line ($$$$) {
        my $s = join("\t", $num,
                $smsg->{subject},
                $smsg->{from},
-               PublicInbox::SearchMsg::date($smsg),
+               PublicInbox::Smsg::date($smsg),
                "<$smsg->{mid}>",
                $smsg->{references},
                $smsg->{bytes},
index b9b02f967b324173fe66caf5e02fbb9df864e892..286fb7f6b4f9b85062f0e5f39ab0c956000f9228 100644 (file)
@@ -9,7 +9,7 @@ use strict;
 use warnings;
 use DBI;
 use DBD::SQLite;
-use PublicInbox::SearchMsg;
+use PublicInbox::Smsg;
 use Compress::Zlib qw(uncompress);
 use constant DEFAULT_LIMIT => 1000;
 
@@ -41,14 +41,14 @@ sub connect { $_[0]->{dbh} ||= $_[0]->dbh_new }
 
 sub load_from_row ($;$) {
        my ($smsg, $cull) = @_;
-       bless $smsg, 'PublicInbox::SearchMsg';
+       bless $smsg, 'PublicInbox::Smsg';
        if (defined(my $data = delete $smsg->{ddd})) {
                $data = uncompress($data);
                utf8::decode($data);
-               PublicInbox::SearchMsg::load_from_data($smsg, $data);
+               PublicInbox::Smsg::load_from_data($smsg, $data);
 
                # saves over 600K for 1000+ message threads
-               PublicInbox::SearchMsg::psgi_cull($smsg) if $cull;
+               PublicInbox::Smsg::psgi_cull($smsg) if $cull;
        }
        $smsg
 }
index 9ee6d613a8c4ab636bc75015dcb225aa0a362b54..fd521bdd1e20a62f5a38e8c5308663b104fadb7f 100644 (file)
@@ -14,7 +14,7 @@ use base qw(PublicInbox::Over);
 use IO::Handle;
 use DBI qw(:sql_types); # SQL_BLOB
 use PublicInbox::MID qw/id_compress mids_for_index references/;
-use PublicInbox::SearchMsg qw(subject_normalized);
+use PublicInbox::Smsg qw(subject_normalized);
 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
 use Compress::Zlib qw(compress);
 use PublicInbox::Search;
@@ -255,7 +255,7 @@ sub add_overview {
                bytes => $bytes,
                lines => $lines,
                blob => $oid,
-       }, 'PublicInbox::SearchMsg';
+       }, 'PublicInbox::Smsg';
        my $hdr = $mime->header_obj;
        my $mids = mids_for_index($hdr);
        my $refs = parse_references($smsg, $mid0, $mids);
index 7f901125057275376041a59ecf5ec69eba6206b0..9a394404a734f117baf1471934447751013fd9d5 100644 (file)
@@ -12,7 +12,7 @@ use constant TS => 0;  # Received: header in Unix time
 use constant YYYYMMDD => 1; # Date: header for searching in the WWW UI
 use constant DT => 2; # Date: YYYYMMDDHHMMSS
 
-use PublicInbox::SearchMsg;
+use PublicInbox::Smsg;
 use PublicInbox::Over;
 my $QP_FLAGS;
 our %X = map { $_ => 0 } qw(BoolWeight Database Enquire
@@ -36,8 +36,8 @@ sub load_xapian () {
                $ENQ_ASCENDING = $x eq 'Xapian' ?
                                1 : Search::Xapian::ENQ_ASCENDING();
 
-               # for SearchMsg:
-               *PublicInbox::SearchMsg::sortable_unserialise =
+               # for Smsg:
+               *PublicInbox::Smsg::sortable_unserialise =
                                                $Xap.'::sortable_unserialise';
                # n.b. FLAG_PURE_NOT is expensive not suitable for a public
                # website as it could become a denial-of-service vector
@@ -279,7 +279,7 @@ sub _enquire_once { # retry_reopen callback
        my $limit = $opts->{limit} || 50;
        my $mset = $enquire->get_mset($offset, $limit);
        return $mset if $opts->{mset};
-       my @msgs = map { PublicInbox::SearchMsg::from_mitem($_) } $mset->items;
+       my @msgs = map { PublicInbox::Smsg::from_mitem($_) } $mset->items;
        return \@msgs unless wantarray;
 
        ($mset->get_matches_estimated, \@msgs)
index 261deb84fd67fbdf5d2e8aa628d01caa6e90539c..6e6c6424a2468e3e3051ee270aa72813d906c15a 100644 (file)
@@ -308,7 +308,7 @@ sub index_xapian { # msg_iter callback
 
 sub add_xapian ($$$$$$) {
        my ($self, $mime, $num, $oid, $mids, $mid0) = @_;
-       my $smsg = PublicInbox::SearchMsg->new($mime);
+       my $smsg = PublicInbox::Smsg->new($mime);
        my $hdr = $mime->header_obj;
        $smsg->{ds} = msg_datestamp($hdr, $self->{autime});
        $smsg->{ts} = msg_timestamp($hdr, $self->{cotime});
@@ -465,7 +465,7 @@ sub remove_by_oid {
        for (; $head != $tail; $head++) {
                my $docid = $head->get_docid;
                my $doc = $db->get_document($docid);
-               my $smsg = PublicInbox::SearchMsg->wrap($mid);
+               my $smsg = PublicInbox::Smsg->wrap($mid);
                $smsg->load_expand($doc);
                if ($smsg->{blob} eq $oid) {
                        push(@delete, $docid);
index 287b0a280575885f9c51678e80ed8b7ea277bc6d..4fbf59ef2ca080d22db624c393d0db1dcc9084d6 100644 (file)
@@ -6,7 +6,7 @@ package PublicInbox::SearchView;
 use strict;
 use warnings;
 use URI::Escape qw(uri_unescape uri_escape);
-use PublicInbox::SearchMsg;
+use PublicInbox::Smsg;
 use PublicInbox::Hval qw(ascii_html obfuscate_addrs mid_href);
 use PublicInbox::View;
 use PublicInbox::WwwAtomStream;
@@ -100,7 +100,7 @@ sub mset_summary {
        foreach my $m ($mset->items) {
                my $rank = sprintf("%${pad}d", $m->get_rank + 1);
                my $pct = get_pct($m);
-               my $smsg = PublicInbox::SearchMsg::from_mitem($m, $srch);
+               my $smsg = PublicInbox::Smsg::from_mitem($m, $srch);
                unless ($smsg) {
                        eval {
                                $m = "$m ".$m->get_docid . " expired\n";
@@ -260,7 +260,7 @@ sub load_msgs {
        my ($mset) = @_;
        [ map {
                my $mi = $_;
-               my $smsg = PublicInbox::SearchMsg::from_mitem($mi);
+               my $smsg = PublicInbox::Smsg::from_mitem($mi);
                $smsg->{pct} = get_pct($mi);
                $smsg;
        } ($mset->items) ]
@@ -338,7 +338,7 @@ sub adump_i {
        my ($ctx) = @_;
        while (my $mi = shift @{$ctx->{items}}) {
                my $smsg = eval {
-                       PublicInbox::SearchMsg::from_mitem($mi, $ctx->{srch});
+                       PublicInbox::Smsg::from_mitem($mi, $ctx->{srch});
                } or next;
                $ctx->{-inbox}->smsg_mime($smsg) and return $smsg;
        }
similarity index 93%
rename from lib/PublicInbox/SearchMsg.pm
rename to lib/PublicInbox/Smsg.pm
index 84fe48025e564be6b81325f1fa43a6d206d1f124..7a47703a25054158c4f1ef12f61cad87ef7a1627 100644 (file)
@@ -1,11 +1,13 @@
 # Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-# based on notmuch, but with no concept of folders, files or flags
 #
-# Wraps a document inside our Xapian search index.
-# There may be many of these objects loaded in memory at once
-# for large threads in our WWW UI.
-package PublicInbox::SearchMsg;
+# A small/skeleton/slim representation of a message.
+
+# This used to be "SearchMsg", but we split out overview
+# indexing into over.sqlite3 so it's not just "search".  There
+# may be many of these objects loaded in memory at once for
+# large threads in our WWW UI and the NNTP range responses.
+package PublicInbox::Smsg;
 use strict;
 use warnings;
 use base qw(Exporter);
index f881e16e41c89cfdd74515401ad2b164394dde22..c32a5baecdbc2a6366c64bb3ad79400e9eacdb34 100644 (file)
@@ -48,7 +48,7 @@ my %BAD_COMPONENT = ('' => 1, '.' => 1, '..' => 1);
 #      hdr_lines => string of various header lines for mode information
 #      mode_a => original mode of oid_a (string, not integer),
 #      ibx => PublicInbox::Inbox object containing the diff
-#      smsg => PublicInbox::SearchMsg object containing diff
+#      smsg => PublicInbox::Smsg object containing diff
 #      path_a => pre-image path
 #      path_b => post-image path
 #      n => numeric path of the patch (relative to worktree)
index 91443f55c177bc12d8578a7a4d95a4eae1814333..5baaffaf5deda70395a5078d47c09f9adff4eac7 100644 (file)
@@ -18,7 +18,7 @@ use PublicInbox::Reply;
 use PublicInbox::ViewDiff qw(flush_diff);
 use POSIX qw(strftime);
 use Time::Local qw(timegm);
-use PublicInbox::SearchMsg qw(subject_normalized);
+use PublicInbox::Smsg qw(subject_normalized);
 use constant COLS => 72;
 use constant INDENT => '  ';
 use constant TCHILD => '` ';
index 21309bd20cd8c365e42ef4366004766be35732b5..e9ea0a27223ba5c3c73f481a9bb4e8fcfcfde8c3 100644 (file)
@@ -24,7 +24,7 @@ sub make_objs {
                        'References' => $msg->{references},
                ]);
                push @simples, $simple;
-               bless $msg, 'PublicInbox::SearchMsg'
+               bless $msg, 'PublicInbox::Smsg'
        } @_;
        (\@simples, \@msgs);
 }