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-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,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 3823720093 for ; Tue, 27 Oct 2020 07:54:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 34/52] extsearchidx: sync unit updates Date: Tue, 27 Oct 2020 07:54:35 +0000 Message-Id: <20201027075453.19163-35-e@80x24.org> In-Reply-To: <20201027075453.19163-1-e@80x24.org> References: <20201027075453.19163-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Now that the V2Writable code is more generic, we can sync with it to use `units' which represent either a v2 epoch or an entire v1 inbox. --- lib/PublicInbox/ExtSearchIdx.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 5e72d65d..32c57188 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -27,7 +27,7 @@ use PublicInbox::Eml; use File::Spec; sub new { - my (undef, $dir, $opt, $shard) = @_; + my (undef, $dir, $opt) = @_; my $l = $opt->{indexlevel} // 'full'; $l !~ $PublicInbox::SearchIdx::INDEXLEVELS and die "invalid indexlevel=$l\n"; @@ -249,15 +249,16 @@ sub _sync_inbox ($$$) { defined($ibx->git_dir_latest(\$epoch_max)) or return; $sync->{epoch_max} = $epoch_max; sync_prepare($self, $sync) or return; - index_epoch($self, $sync, $_) for (0..$epoch_max); } elsif ($v == 1) { my $uv = $ibx->uidvalidity; my $lc = $self->{oidx}->eidx_meta("lc-v1:$ekey//$uv"); - prepare_stack($sync, $lc ? "$lc..HEAD" : 'HEAD'); + my $stk = prepare_stack($sync, $lc ? "$lc..HEAD" : 'HEAD'); + my $unit = { stack => $stk, git => $ibx->git }; } else { warn "E: $ekey unsupported inbox version (v$v)\n"; return; } + index_todo($self, $sync, $_) for @{$sync->{todo}}; } sub eidx_sync { # main entry point @@ -266,6 +267,8 @@ sub eidx_sync { # main entry point $self->{oidx}->rethread_prepare($opt); _sync_inbox($self, $opt, $_) for (@{$self->{ibx_list}}); + $self->{oidx}->rethread_done($opt); + PublicInbox::V2Writable::done($self); } sub idx_init { # similar to V2Writable @@ -309,6 +312,8 @@ no warnings 'once'; *parallel_init = \&PublicInbox::V2Writable::parallel_init; *nproc_shards = \&PublicInbox::V2Writable::nproc_shards; *sync_prepare = \&PublicInbox::V2Writable::sync_prepare; -*index_epoch = \&PublicInbox::V2Writable::index_epoch; +*index_todo = \&PublicInbox::V2Writable::index_todo; +*count_shards = \&PublicInbox::V2Writable::count_shards; +*atfork_child = \&PublicInbox::V2Writable::atfork_child; 1;