From e24d15f7835c9cd0c924f817cb83cfcf94a7582e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 12 Dec 2024 10:10:38 +0000 Subject: [PATCH] searchidx: update_checkpoint: take bytes arg directly Passing $smsg limits flexibility in case we reuse it for deletes and/or commit search. --- lib/PublicInbox/ExtSearchIdx.pm | 2 +- lib/PublicInbox/SearchIdx.pm | 6 +++--- lib/PublicInbox/V2Writable.pm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index fe2f5d2e4..1c2a9a26d 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -125,7 +125,7 @@ sub attach_config { sub check_batch_limit ($) { my ($req) = @_; # set flag for PublicInbox::V2Writable::index_todo: - update_checkpoint $req->{self}, $req->{new_smsg} and + update_checkpoint $req->{self}, $req->{new_smsg}->{bytes} and ${$req->{need_checkpoint}} = 1; } diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 3a85f5521..0d9acd20b 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -788,8 +788,8 @@ sub is_bad_blob ($$$$) { } sub update_checkpoint ($$) { - my ($self, $smsg) = @_; - ($self->{transact_bytes} += $smsg->{bytes}) >= $self->{batch_bytes} and + my ($self, $bytes) = @_; + ($self->{transact_bytes} += $bytes) >= $self->{batch_bytes} and return 1; my $now = now; my $next = $self->{next_checkpoint} //= $now + $CHECKPOINT_INTVL; @@ -803,7 +803,7 @@ sub index_both { # git->cat_async callback my $smsg = bless { blob => $oid }, 'PublicInbox::Smsg'; $smsg->set_bytes($$bref, $size); my $self = $sync->{sidx}; - ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg; + ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg->{bytes}; local $self->{current_info} = "$self->{current_info}: $oid"; my $eml = PublicInbox::Eml->new($bref); $smsg->{num} = index_mm($self, $eml, $oid, $sync) or diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 5f3bfde54..c894b6482 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -107,7 +107,7 @@ sub do_idx ($$$) { my $idx = idx_shard($self, $smsg->{num}); $idx->index_eml($eml, $smsg); } - update_checkpoint $self, $smsg; + update_checkpoint $self, $smsg->{bytes}; } # returns undef on duplicate or spam -- 2.47.2