]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxShard.pm
init+index: support --skip-docdata for Xapian
[public-inbox.git] / lib / PublicInbox / SearchIdxShard.pm
index fd34e487bc6065f6d1a5d5d6623637cf04fbd025..20077e08fa2edc13ef17926d7bc55789559f628d 100644 (file)
@@ -15,9 +15,9 @@ sub new {
        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->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) {
+                       $$msgref = undef;
+               } else { # --xapian-only + --sequential-shard:
+                       $eml = PublicInbox::Eml->new($msgref);
+               }
                $self->begin_txn_lazy;
-               $self->add_message($mime, $smsg);
+               $self->add_message($eml, $smsg);
        }
 }