diff options
author | Eric Wong <e@yhbt.net> | 2020-07-24 05:55:48 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-07-25 20:48:18 +0000 |
commit | 4441a38481ed2c9472767a6387d8a2455ea34ad5 (patch) | |
tree | 0f0260510545e3ee85ffa0e29ba6ba5c17f8f63c /lib/PublicInbox/MultiMidQueue.pm | |
parent | b02c7a346bd36f1325518ca110a781c619082da1 (diff) | |
download | public-inbox-4441a38481ed2c9472767a6387d8a2455ea34ad5.tar.gz |
Since we'll need to expose THREADID to JMAP and IMAP users, index all messages in the order they were committed to ensure our `tid' (thread ID) column ascends in mirrors the same way they do in the source inbox. This drastically simplifies our code but increases memory usage of `git-log'. The next commit will bring memory use back down at the expense of $TMPDIR usage.
Diffstat (limited to 'lib/PublicInbox/MultiMidQueue.pm')
-rw-r--r-- | lib/PublicInbox/MultiMidQueue.pm | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/lib/PublicInbox/MultiMidQueue.pm b/lib/PublicInbox/MultiMidQueue.pm deleted file mode 100644 index eb2ecf2f..00000000 --- a/lib/PublicInbox/MultiMidQueue.pm +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2020 all contributors <meta@public-inbox.org> -# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> - -# temporary queue for public-inbox-index to support multi-Message-ID -# messages on mirrors of v2 inboxes -package PublicInbox::MultiMidQueue; -use strict; -use SDBM_File; # part of Perl standard library -use Fcntl qw(O_RDWR O_CREAT); -use File::Temp 0.19 (); # 0.19 for ->newdir -my %e = ( - freebsd => 0x100000, - linux => 0x80000, - netbsd => 0x400000, - openbsd => 0x10000, -); -my $O_CLOEXEC = $e{$^O} // 0; - -sub new { - my ($class) = @_; - my $tmpdir = File::Temp->newdir('multi-mid-q-XXXXXX', TMPDIR => 1); - my $base = $tmpdir->dirname . '/q'; - my %sdbm; - my $flags = O_RDWR|O_CREAT; - if (!tie(%sdbm, 'SDBM_File', $base, $flags|$O_CLOEXEC, 0600)) { - if (!tie(%sdbm, 'SDBM_File', $base, $flags, 0600)) { - die "could not tie ($base): $!"; - } - $O_CLOEXEC = 0; - } - - bless { - cur => 1, - min => 1, - max => 0, - sdbm => \%sdbm, - tmpdir => $tmpdir, - }, $class; -} - -sub set_oid { - my ($self, $i, $oid, $v2w) = @_; - $self->{max} = $i if $i > $self->{max}; - $self->{min} = $i if $i < $self->{min}; - $self->{sdbm}->{$i} = "$oid\t$v2w->{autime}\t$v2w->{cotime}"; -} - -sub get_oid { - my ($self, $i, $v2w) = @_; - my $rec = $self->{sdbm}->{$i} or return; - my ($oid, $autime, $cotime) = split(/\t/, $rec); - $v2w->{autime} = $autime; - $v2w->{cotime} = $cotime; - $oid -} - -sub push_oid { - my ($self, $oid, $v2w) = @_; - set_oid($self, $self->{cur}++, $oid, $v2w); -} - -1; |