From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8BF9D1FB0F for ; Tue, 21 Sep 2021 07:41:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/12] lei lcat: use single queue for ordering Date: Tue, 21 Sep 2021 07:41:52 +0000 Message-Id: <20210921074159.20052-6-e@80x24.org> In-Reply-To: <20210921074159.20052-1-e@80x24.org> References: <20210921074159.20052-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: If lcat-ing multiple argument types (blobs vs folders), maintain the original order of the arguments instead of dumping all blobs before folder contents. --- lib/PublicInbox/LeiLcat.pm | 13 ++++++------- lib/PublicInbox/LeiXSearch.pm | 16 ++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/LeiLcat.pm b/lib/PublicInbox/LeiLcat.pm index ccb1823d..1a4a988e 100644 --- a/lib/PublicInbox/LeiLcat.pm +++ b/lib/PublicInbox/LeiLcat.pm @@ -21,7 +21,7 @@ sub lcat_folder ($$$) { } else { for my $f (@$folders) { my $fid = $lms->fid_for($f); - push @{$lei->{lcat_fid}}, $fid; + push @{$lei->{lcat_todo}}, { fid => $fid }; } } } @@ -31,10 +31,9 @@ sub lcat_imap_uri ($$) { my $lms = $lei->lms or return; # cf. LeiXsearch->lcat_dump if (defined $uri->uid) { - my @oidhex = $lms->imap_oidhex($lei, $uri); - push @{$lei->{lcat_blob}}, @oidhex; + push @{$lei->{lcat_todo}}, $lms->imap_oidhex($lei, $uri); } elsif (defined(my $fid = $lms->fid_for($$uri))) { - push @{$lei->{lcat_fid}}, $fid; + push @{$lei->{lcat_todo}}, { fid => $fid }; } else { lcat_folder($lei, $lms, $$uri); } @@ -46,10 +45,10 @@ sub extract_1 ($$) { my $u = $1; require PublicInbox::URIimap; lcat_imap_uri($lei, PublicInbox::URIimap->new($u)); - '""'; # blank query, using {lcat_blob} or {lcat_fid} + '""'; # blank query, using {lcat_todo} } elsif ($x =~ m!\b(maildir:.+)!i) { lcat_folder($lei, undef, $1); - '""'; # blank query, using {lcat_blob} or {lcat_fid} + '""'; # blank query, using {lcat_todo} } elsif ($x =~ m!\b([a-z]+?://\S+)!i) { my $u = $1; $u =~ s/[\>\]\)\,\.\;]+\z//; @@ -82,7 +81,7 @@ sub extract_1 ($$) { } elsif ($x =~ /\bid:(\S+)/) { # notmuch convention "mid:$1"; } elsif ($x =~ /\bblob:([0-9a-f]{7,})\b/) { - push @{$lei->{lcat_blob}}, $1; # cf. LeiToMail->wq_atexit_child + push @{$lei->{lcat_todo}}, $1; # cf. LeiToMail->wq_atexit_child '""'; # blank query } else { undef; diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 756183a9..3ce8f32d 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -570,7 +570,7 @@ sub do_query { @$end = (); $self->{opt_threads} = $lei->{opt}->{threads}; $self->{opt_sort} = $lei->{opt}->{'sort'}; - $self->{-do_lcat} = $lei->{lcat_blob} // $lei->{lcat_fid}; + $self->{-do_lcat} = !!(delete $lei->{lcat_todo}); if ($l2m) { $l2m->net_merge_all_done unless $lei->{auth}; } else { @@ -646,13 +646,13 @@ sub lcat_dump { # via wq_io_do $git->cat_async($smsg->{blob}, \&_lcat2smsg, $smsg); }; } - for my $oid (@{$lei->{lcat_blob} // []}) { - $each_smsg->({ blob => $oid, pct => 100 }); - } - if (my $fids = delete $lei->{lcat_fid}) { - my $lms = $lei->{lse}->lms; - for my $fid (@$fids) { - $lms->each_src({fid => $fid}, \&_lcat_i, $each_smsg); + my $lms; + for my $ent (@{$lei->{lcat_todo}}) { + if (ref $ent eq 'HASH') { # { fid => $fid ,.. } + $lms //= $lei->{lse}->lms; + $lms->each_src($ent, \&_lcat_i, $each_smsg); + } else { # oidhex + $each_smsg->({ blob => $ent, pct => 100 }); } } $git->async_wait_all;