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:
sub mime2html {
my ($out, $mime, $ctx) = @_;
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;
}
print $out PublicInbox::View::index_entry($smsg, $ctx, 1) or die;
}
sub mime2atom {
my ($out, $astream, $mime, $ctx) = @_;
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;
}
if (defined(my $str = $astream->feed_entry($smsg))) {
print $out $str or die;
}
Our PublicInbox::V2Writable class may have two objects of this
type in memory at-a-time for deduplication.
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
Used by: PublicInbox::{NNTP,WWW,SearchIdx}
Common abbreviation: $smsg
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
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.
As with $smsg objects, there may be hundreds or thousands
of these objects in memory at-a-time.
lib/PublicInbox/Search.pm
lib/PublicInbox/SearchIdx.pm
lib/PublicInbox/SearchIdxShard.pm
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/SearchThread.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/Sigfd.pm
lib/PublicInbox/SolverGit.pm
lib/PublicInbox/Spamcheck.pm
lib/PublicInbox/Spamcheck/Spamc.pm
lib/PublicInbox/SolverGit.pm
lib/PublicInbox/Spamcheck.pm
lib/PublicInbox/Spamcheck/Spamc.pm
use warnings;
use PublicInbox::Hval qw(ascii_html prurl mid_href);
use PublicInbox::WwwStream;
use warnings;
use PublicInbox::Hval qw(ascii_html prurl mid_href);
use PublicInbox::WwwStream;
our $MIN_PARTIAL_LEN = 16;
# TODO: user-configurable
our $MIN_PARTIAL_LEN = 16;
# TODO: user-configurable
sub PARTIAL_MAX () { 100 }
sub mids_from_mset { # Search::retry_reopen callback
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 ($$) {
}
sub search_partial ($$) {
use PublicInbox::MIME;
use PublicInbox::View;
use PublicInbox::WwwAtomStream;
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) = @_;
sub generate_i {
my ($ctx) = @_;
}
$ctx->{next_page} = "r=$last_commit" if $last_commit;
}
$ctx->{next_page} = "r=$last_commit" if $last_commit;
- [ map { bless {blob => $_ }, 'PublicInbox::SearchMsg' } @oids ];
+ [ map { bless {blob => $_ }, 'PublicInbox::Smsg' } @oids ];
# 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;
# 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 ($$;$) {
}
sub msg_by_mid ($$;$) {
use warnings;
use PublicInbox::MID qw/mid_escape/;
use PublicInbox::Hval qw/to_filename/;
use warnings;
use PublicInbox::MID qw/mid_escape/;
use PublicInbox::Hval qw/to_filename/;
-use PublicInbox::SearchMsg;
use Email::Simple;
use Email::MIME::Encode;
use Email::Simple;
use Email::MIME::Encode;
my $srch = $ctx->{srch};
while (1) {
while (my $mi = (($mset->items)[$ctx->{iter}++])) {
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;
}
$srch) or next;
return $smsg;
}
sub over_header_for {
my ($over, $num, $field) = @_;
my $smsg = $over->get_art($num) or return;
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';
my ($self, $beg, $end, $field) = @_;
my $over = $self->{ng}->over;
my $msgs = $over->query_xover($$beg, $end);
my ($self, $beg, $end, $field) = @_;
my $over = $self->{ng}->over;
my $msgs = $over->query_xover($$beg, $end);
$$beg = $msgs->[-1]->{num} + 1;
}
$$beg = $msgs->[-1]->{num} + 1;
}
-sub hdr_searchmsg ($$$$) {
my ($self, $xhdr, $field, $range) = @_;
if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
my ($ng, $n) = mid_lookup($self, $1);
my ($self, $xhdr, $field, $range) = @_;
if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
my ($ng, $n) = mid_lookup($self, $1);
my $r = get_range($self, $range);
return $r unless ref $r;
more($self, $xhdr ? r221 : r225);
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);
hdr_xref($self, $xhdr, $range);
} elsif ($sub =~ /\A(?:subject|references|date|from|to|cc|
bytes|lines)\z/x) {
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/) {
} 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";
}
} else {
$xhdr ? (r221 . "\r\n.") : "503 HDR not permitted on $header";
}
my $s = join("\t", $num,
$smsg->{subject},
$smsg->{from},
my $s = join("\t", $num,
$smsg->{subject},
$smsg->{from},
- PublicInbox::SearchMsg::date($smsg),
+ PublicInbox::Smsg::date($smsg),
"<$smsg->{mid}>",
$smsg->{references},
$smsg->{bytes},
"<$smsg->{mid}>",
$smsg->{references},
$smsg->{bytes},
use warnings;
use DBI;
use DBD::SQLite;
use warnings;
use DBI;
use DBD::SQLite;
-use PublicInbox::SearchMsg;
use Compress::Zlib qw(uncompress);
use constant DEFAULT_LIMIT => 1000;
use Compress::Zlib qw(uncompress);
use constant DEFAULT_LIMIT => 1000;
sub load_from_row ($;$) {
my ($smsg, $cull) = @_;
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);
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
# saves over 600K for 1000+ message threads
- PublicInbox::SearchMsg::psgi_cull($smsg) if $cull;
+ PublicInbox::Smsg::psgi_cull($smsg) if $cull;
use IO::Handle;
use DBI qw(:sql_types); # SQL_BLOB
use PublicInbox::MID qw/id_compress mids_for_index references/;
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;
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
use Compress::Zlib qw(compress);
use PublicInbox::Search;
bytes => $bytes,
lines => $lines,
blob => $oid,
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);
my $hdr = $mime->header_obj;
my $mids = mids_for_index($hdr);
my $refs = parse_references($smsg, $mid0, $mids);
use constant YYYYMMDD => 1; # Date: header for searching in the WWW UI
use constant DT => 2; # Date: YYYYMMDDHHMMSS
use constant YYYYMMDD => 1; # Date: header for searching in the WWW UI
use constant DT => 2; # Date: YYYYMMDDHHMMSS
-use PublicInbox::SearchMsg;
use PublicInbox::Over;
my $QP_FLAGS;
our %X = map { $_ => 0 } qw(BoolWeight Database Enquire
use PublicInbox::Over;
my $QP_FLAGS;
our %X = map { $_ => 0 } qw(BoolWeight Database Enquire
$ENQ_ASCENDING = $x eq 'Xapian' ?
1 : Search::Xapian::ENQ_ASCENDING();
$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
$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
my $limit = $opts->{limit} || 50;
my $mset = $enquire->get_mset($offset, $limit);
return $mset if $opts->{mset};
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)
return \@msgs unless wantarray;
($mset->get_matches_estimated, \@msgs)
sub add_xapian ($$$$$$) {
my ($self, $mime, $num, $oid, $mids, $mid0) = @_;
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});
my $hdr = $mime->header_obj;
$smsg->{ds} = msg_datestamp($hdr, $self->{autime});
$smsg->{ts} = msg_timestamp($hdr, $self->{cotime});
for (; $head != $tail; $head++) {
my $docid = $head->get_docid;
my $doc = $db->get_document($docid);
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);
$smsg->load_expand($doc);
if ($smsg->{blob} eq $oid) {
push(@delete, $docid);
use strict;
use warnings;
use URI::Escape qw(uri_unescape uri_escape);
use strict;
use warnings;
use URI::Escape qw(uri_unescape uri_escape);
-use PublicInbox::SearchMsg;
use PublicInbox::Hval qw(ascii_html obfuscate_addrs mid_href);
use PublicInbox::View;
use PublicInbox::WwwAtomStream;
use PublicInbox::Hval qw(ascii_html obfuscate_addrs mid_href);
use PublicInbox::View;
use PublicInbox::WwwAtomStream;
foreach my $m ($mset->items) {
my $rank = sprintf("%${pad}d", $m->get_rank + 1);
my $pct = get_pct($m);
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";
unless ($smsg) {
eval {
$m = "$m ".$m->get_docid . " expired\n";
my ($mset) = @_;
[ map {
my $mi = $_;
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) ]
$smsg->{pct} = get_pct($mi);
$smsg;
} ($mset->items) ]
my ($ctx) = @_;
while (my $mi = shift @{$ctx->{items}}) {
my $smsg = eval {
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;
}
} or next;
$ctx->{-inbox}->smsg_mime($smsg) and return $smsg;
}
# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# 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);
use strict;
use warnings;
use base qw(Exporter);
# 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
# 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)
# path_a => pre-image path
# path_b => post-image path
# n => numeric path of the patch (relative to worktree)
use PublicInbox::ViewDiff qw(flush_diff);
use POSIX qw(strftime);
use Time::Local qw(timegm);
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 => '` ';
use constant COLS => 72;
use constant INDENT => ' ';
use constant TCHILD => '` ';
'References' => $msg->{references},
]);
push @simples, $simple;
'References' => $msg->{references},
]);
push @simples, $simple;
- bless $msg, 'PublicInbox::SearchMsg'
+ bless $msg, 'PublicInbox::Smsg'
} @_;
(\@simples, \@msgs);
}
} @_;
(\@simples, \@msgs);
}