sub eidx_key { $_[0]->{newsgroup} // $_[0]->{inboxdir} }
+# only used by NNTP, so we need ->mm anyways
+sub art_min { $_[0]->{-art_min} //= eval { $_[0]->mm(1)->min } }
+
+# used by IMAP, too, which tries to avoid ->mm (but ->{mm} is likely
+# faster since it's smaller iff available)
+sub art_max {
+ $_[0]->{-art_max} //= eval { $_[0]->{mm}->max } //
+ eval { $_[0]->over(1)->max };
+}
+
sub mailboxid { # rfc 8474, 8620, 8621
my ($self, $imap_slice) = @_;
my $pfx = defined($imap_slice) ? $self->{newsgroup} : $self->{name};
$doc->add_boolean_term('Q'.$eidx_key); # uniQue id
$doc->add_boolean_term('T'.'inbox'); # Type
+ # force reread from disk, {description} could be loaded from {misc}
+ delete @$ibx{qw(-art_min -art_max description)};
if (defined($ibx->{newsgroup}) && $ibx->nntp_usable) {
$doc->add_boolean_term('T'.'newsgroup'); # additional Type
+ my $n = $ibx->art_min;
+ add_val($doc, $PublicInbox::MiscSearch::ART_MIN, $n) if $n;
+ $n = $ibx->art_max;
+ add_val($doc, $PublicInbox::MiscSearch::ART_MAX, $n) if $n;
}
- # force reread from disk, {description} could be loaded from {misc}
- delete $ibx->{description};
my $desc = $ibx->description;
# description = S/Subject (or title)
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# read-only counterpart to MiscIdx
# Xapian value columns:
our $MODIFIED = 0;
our $UIDVALIDITY = 1; # (created time)
+our $ART_MIN = 2; # NNTP article number
+our $ART_MAX = 3; # NNTP article number
# avoid conflicting with message Search::prob_prefix for UI/UX reasons
my %PROB_PREFIX = (
my $term = 'Q'.$ibx->eidx_key; # may be {inboxdir}, so private
my $head = $xdb->postlist_begin($term);
my $tail = $xdb->postlist_end($term);
- if ($head != $tail) {
- my $doc = $xdb->get_document($head->get_docid);
- $ibx->{uidvalidity} //= int_val($doc, $UIDVALIDITY);
- $ibx->{-modified} = int_val($doc, $MODIFIED);
- $doc->get_data;
- } else {
- undef;
- }
+ return if $head == $tail;
+ my $doc = $xdb->get_document($head->get_docid);
+ $ibx->{uidvalidity} //= int_val($doc, $UIDVALIDITY);
+ $ibx->{-modified} = int_val($doc, $MODIFIED);
+ $ibx->{-art_min} = int_val($doc, $ART_MIN);
+ $ibx->{-art_max} = int_val($doc, $ART_MAX);
+ $doc->get_data;
}
sub doc2ibx_cache_ent { # @_ == ($self, $doc) OR ($doc)
{
uidvalidity => int_val($doc, $UIDVALIDITY),
-modified => int_val($doc, $MODIFIED),
+ -art_min => int_val($doc, $ART_MIN), # may be undef
+ -art_max => int_val($doc, $ART_MAX), # may be undef
# extract description from manifest.js.gz epoch description
description => $d
};
$sth->fetchrow_array // 0;
}
-sub minmax {
- # breaking MIN and MAX into separate queries speeds up from 250ms
- # to around 700us with 2.7million messages.
+sub min {
my $sth = $_[0]->{dbh}->prepare_cached('SELECT MIN(num) FROM msgmap',
undef, 1);
$sth->execute;
- ($sth->fetchrow_array // 0, max($_[0]));
+ $sth->fetchrow_array // 0;
+}
+
+sub minmax {
+ # breaking MIN and MAX into separate queries speeds up from 250ms
+ # to around 700us with 2.7million messages.
+ (min($_[0]), max($_[0]));
}
sub mid_delete {
\@ret;
}
+# always returns a scalar value
sub int_val ($$) {
my ($doc, $col) = @_;
- my $val = $doc->get_value($col) or return; # undefined is '' in Xapian
+ my $val = $doc->get_value($col) or return undef; # undef is '' in Xapian
sortable_unserialise($val) + 0; # PV => IV conversion
}