]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Msgmap.pm
v2writable: allow tracking parallel versions
[public-inbox.git] / lib / PublicInbox / Msgmap.pm
index 26565d456b6c5d4b5d0ce320297dcb8e4ee5d7e2..f5f88431bbfa82d1e7af847126d14441f6409864 100644 (file)
@@ -92,6 +92,14 @@ sub last_commit {
        $self->meta_accessor('last_commit', $commit);
 }
 
+# v2 uses this to keep track of how up-to-date Xapian is
+# old versions may be automatically GC'ed away in the future,
+# but it's a trivial amount of storage.
+sub last_commit_xap {
+       my ($self, $version, $i, $commit) = @_;
+       $self->meta_accessor("last_xap$version-$i", $commit);
+}
+
 sub created_at {
        my ($self, $second) = @_;
        $self->meta_accessor('created_at', $second);
@@ -196,6 +204,18 @@ ORDER BY num ASC LIMIT 1000
        $ids;
 }
 
+sub msg_range {
+       my ($self, $beg, $end) = @_;
+       my $dbh = $self->{dbh};
+       my $attr = { Columns => [] };
+       my $mids = $dbh->selectall_arrayref(<<'', $attr, $$beg, $end);
+SELECT num,mid FROM msgmap WHERE num >= ? AND num <= ?
+ORDER BY num ASC
+
+       $$beg = $mids->[-1]->[0] + 1 if @$mids;
+       $mids
+}
+
 # only used for mapping external serial numbers (e.g. articles from gmane)
 # see scripts/xhdr-num2mid or PublicInbox::Filter::RubyLang for usage
 sub mid_set {