blob => $oid,
}, 'PublicInbox::Smsg';
$new_smsg->set_bytes($$bref, $size);
- ++${$req->{nr}};
+ ++$self->{nrec};
my $mismatch = [];
$req->{xnum} = cur_ibx_xnum($req, $bref, $mismatch) // do {
warn "# deleted\n";
return "W: skipping $ekey ($err)";
}
$sync->{ibx} = $ibx;
- $sync->{nr} = \(my $nr = 0);
+ $self->{nrec} = 0;
my $v = $ibx->version;
if ($v == 2) {
$sync->{epoch_max} = $ibx->max_git_epoch // return;
$opt->{-idx_gc} = 1;
local $self->{checkpoint_unlocks} = 1;
local $self->{need_checkpoint} = 0;
- my $sync = {
- -opt => $opt,
- self => $self,
- };
+ local $self->{nrec};
+ my $sync = { -opt => $opt, self => $self };
$self->idx_init($opt); # acquire lock via V2Writable::_idx_init
eidx_gc_scan_inboxes($self, $sync);
eidx_gc_scan_shards($self, $sync);
return unless ($self->{cfg} && eidxq_lock_acquire($self));
my $dbh = $self->{oidx}->dbh;
my $tot = $dbh->selectrow_array('SELECT COUNT(*) FROM eidxq') or return;
- ${$sync->{nr}} = 0;
+ $self->{nrec} = 0;
local $sync->{-regen_fmt} = "%u/$tot\n";
my $pr = $sync->{-opt}->{-progress};
if ($pr) {
warn "E: #$docid does not exist in over\n";
}
$del->execute($docid);
- ++${$sync->{nr}};
+ ++$self->{nrec};
if (update_checkpoint $self) {
$dbh = $del = $iter = undef;
}
}
$self->git->async_wait_all;
- $pr->("reindexed ${$sync->{nr}}/$tot\n") if $pr;
+ $pr->("reindexed $self->{nrec}/$tot\n") if $pr;
}
sub _reindex_unseen { # git->cat_async callback
my $msgs;
my $pr = $sync->{-opt}->{-progress};
local $sync->{-regen_fmt} = "$ekey checking %u/$max\n";
- ${$sync->{nr}} = 0;
+ $self->{nrec} = 0;
my $fast = $sync->{-opt}->{fast};
my $usr; # _unref_stale_range (< $lo) called
my ($lo, $hi);
while (scalar(@{$msgs = $ibx->over->query_xover($beg, $end, $opt)})) {
- ${$sync->{nr}} = $beg;
+ $self->{nrec} = $beg;
$beg = $msgs->[-1]->{num} + 1;
$end = $beg + $slice;
$end = $max if $end > $max;
while (my ($mid, $id) = $iter->fetchrow_array) {
last if $sync->{quit};
$self->{current_info} = "dedupe $mid";
- ${$sync->{nr}} = $min_id = $id;
+ $self->{nrec} = $min_id = $id;
my ($prv, @smsg);
while (my $x = $self->{oidx}->next_by_mid($mid, \$id, \$prv)) {
push @smsg, $x;
if (my $pr = $sync->{-opt}->{-progress}) {
$pr->("culled $n/$candidates candidates ($nr_mid msgids)\n");
}
- ${$sync->{nr}} = 0;
+ $self->{nrec} = 0;
}
sub eidx_sync { # main entry point
$self->idx_init($opt); # acquire lock via V2Writable::_idx_init
$self->{oidx}->rethread_prepare($opt);
local $self->{need_checkpoint} = 0;
+ local $self->{nrec} = 0;
my $sync = {
-opt => $opt,
# DO NOT SET {reindex} here, it's incompatible with reused
sub index_both { # git->cat_async callback
my ($bref, $oid, $type, $size, $sync) = @_;
return if is_bad_blob($oid, $type, $size, $sync->{oid});
- ++${$sync->{nr}};
my $smsg = bless { blob => $oid }, 'PublicInbox::Smsg';
$smsg->set_bytes($$bref, $size);
my $self = $sync->{sidx};
die "E: could not generate NNTP article number for $oid";
add_message($self, $eml, $smsg, $sync);
++$self->{nidx};
+ ++$self->{nrec};
my $cur_cmt = $sync->{cur_cmt} // die 'BUG: {cur_cmt} missing';
${$sync->{latest_cmt}} = $cur_cmt;
}
}
commit_txn_lazy($self);
$sync->{ibx}->git->cleanup;
- my $nr = ${$sync->{nr}};
- idx_release($self, $nr);
+ my $nrec = $self->{nrec};
+ idx_release($self, $nrec);
# let another process do some work...
if (my $pr = $sync->{-opt}->{-progress}) {
- $pr->("indexed $nr/$sync->{ntodo}\n") if $nr;
+ $pr->("indexed $nrec/$sync->{ntodo}\n") if $nrec;
}
if (!$stk && !$sync->{quit}) { # more to come
begin_txn_lazy($self);
sub process_stack {
my ($self, $sync, $stk) = @_;
my $git = $sync->{ibx}->git;
- my $nr = 0;
- $sync->{nr} = \$nr;
+ $self->{nrec} = 0;
$sync->{sidx} = $self;
local $self->{need_checkpoint} = 0;
$sync->{latest_cmt} = \(my $latest_cmt);
}
if (my $pr = $sync->{-regen_fmt} ? $sync->{-opt}->{-progress} : undef) {
- $pr->(sprintf($sync->{-regen_fmt}, ${$sync->{nr}}));
+ $pr->(sprintf $sync->{-regen_fmt}, $self->{nrec});
}
# allow -watch or -mda to write...
warn "E: $oid <", join('> <', @$mids), "> is a duplicate\n";
return;
}
- ++${$arg->{nr}};
+ ++$self->{nrec};
my $smsg = bless {
num => $num,
blob => $oid,
# it's a problem and we need to notice it via die()
my $pad = length($regen_max) + 1;
$sync->{-regen_fmt} = "% ${pad}u/$regen_max\n";
- $sync->{nr} = \(my $nr = 0);
+ $self->{nrec} = 0;
return -1 if $sync->{reindex};
$regen_max + $self->artnum_max || 0;
}
# have timeout problems like SQLite
my $n = $self->{transact_bytes} += $smsg->{bytes};
if ($n >= $self->{batch_bytes}) {
- ${$sync->{nr}} = $num;
+ $self->{nrec} = $num;
reindex_checkpoint($self, $sync);
}
}
$sync //= {
-opt => $opt,
self => $self,
- nr => \(my $nr = 0),
-regen_fmt => "%u/?\n",
};
$sync->{art_end} = $art_end;
my ($self, $opt) = @_;
$opt //= {};
local $self->{need_checkpoint} = 0;
+ local $self->{nrec} = 0;
return xapian_only($self, $opt) if $opt->{xapian_only};
my $epoch_max = $self->{ibx}->max_git_epoch // return;
$self->{oidx}->rethread_done($opt) unless $sync->{quit};
$self->done;
- if (my $nr = $sync->{nr}) {
+ if (my $nrec = $self->{nrec}) {
my $pr = $sync->{-opt}->{-progress};
- $pr->('all.git '.sprintf($sync->{-regen_fmt}, $$nr)) if $pr;
+ $pr->('all.git '.sprintf($sync->{-regen_fmt}, $nrec)) if $pr;
}
my $quit_warn;