X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchIdxShard.pm;h=75521b43a4087badcc5daa2bccc5adcd9323956d;hb=a279d43a0a9fce97936ebb9facd89662bfcd5a23;hp=544268819070c675bfa9d3e2a3edc92c11ffb2a2;hpb=592f8239dceb6604e538fd51e62bcce50d6e1972;p=public-inbox.git diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 54426881..75521b43 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -11,14 +11,14 @@ use IO::Handle (); # autoflush use PublicInbox::Eml; sub new { - my ($class, $v2writable, $shard) = @_; - my $ibx = $v2writable->{-inbox}; + my ($class, $v2w, $shard) = @_; + my $ibx = $v2w->{ibx}; my $self = $class->SUPER::new($ibx, 1, $shard); # create the DB before forking: - $self->_xdb_acquire; - $self->set_indexlevel; - $self->_xdb_release; - $self->spawn_worker($v2writable, $shard) if $v2writable->{parallel}; + $self->idx_acquire; + $self->set_metadata_once; + $self->idx_release; + $self->spawn_worker($v2w, $shard) if $v2w->{parallel}; $self; } @@ -56,7 +56,7 @@ sub shard_worker_loop ($$$$$) { if ($line eq "commit\n") { $self->commit_txn_lazy; } elsif ($line eq "close\n") { - $self->_xdb_release; + $self->idx_release; } elsif ($line eq "barrier\n") { $self->commit_txn_lazy; # no need to lock < 512 bytes is atomic under POSIX @@ -89,16 +89,20 @@ sub shard_worker_loop ($$$$$) { # called by V2Writable sub index_raw { - my ($self, $msgref, $mime, $smsg) = @_; + my ($self, $msgref, $eml, $smsg) = @_; if (my $w = $self->{w}) { # mid must be last, it can contain spaces (but not LF) print $w join(' ', @$smsg{qw(raw_bytes bytes num blob ds ts mid)}), "\n", $$msgref or die "failed to write shard $!\n"; } else { - $$msgref = undef; + if ($eml) { + undef $$msgref; + } else { # --xapian-only + --sequential-shard: + $eml = PublicInbox::Eml->new($msgref); + } $self->begin_txn_lazy; - $self->add_message($mime, $smsg); + $self->add_message($eml, $smsg); } }