summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2b52961)
We'll use {oidx} as the common field name for the read-write
OverIdx, here, to disambiguate it from the read-only {over}
field. This hopefully makes it clearer which code paths are
read-only and which are read-write.
if ($version == 1) {
$self->{lock_path} = "$inboxdir/ssoma.lock";
my $dir = $self->xdir;
if ($version == 1) {
$self->{lock_path} = "$inboxdir/ssoma.lock";
my $dir = $self->xdir;
- $self->{over} = PublicInbox::OverIdx->new("$dir/over.sqlite3");
- $self->{over}->{-no_fsync} = 1 if $ibx->{-no_fsync};
+ $self->{oidx} = PublicInbox::OverIdx->new("$dir/over.sqlite3");
+ $self->{oidx}->{-no_fsync} = 1 if $ibx->{-no_fsync};
} elsif ($version == 2) {
defined $shard or die "shard is required for v2\n";
# shard is a number
} elsif ($version == 2) {
defined $shard or die "shard is required for v2\n";
# shard is a number
# of the fields which exist in over.sqlite3. We may stop
# storing doc_data in Xapian sometime after we get multi-inbox
# search working.
# of the fields which exist in over.sqlite3. We may stop
# storing doc_data in Xapian sometime after we get multi-inbox
# search working.
- if (my $over = $self->{over}) { # v1 only
- $over->add_overview($mime, $smsg);
+ if (my $oidx = $self->{oidx}) { # v1 only
+ $oidx->add_overview($mime, $smsg);
}
if (need_xapian($self)) {
add_xapian($self, $mime, $smsg, $mids);
}
if (need_xapian($self)) {
add_xapian($self, $mime, $smsg, $mids);
sub remove_by_oid {
my ($self, $oid, $num) = @_;
sub remove_by_oid {
my ($self, $oid, $num) = @_;
- die "BUG: remove_by_oid is v2-only\n" if $self->{over};
+ die "BUG: remove_by_oid is v2-only\n" if $self->{oidx};
$self->begin_txn_lazy;
xdb_remove($self, $oid, $num) if need_xapian($self);
}
$self->begin_txn_lazy;
xdb_remove($self, $oid, $num) if need_xapian($self);
}
my $nr = 0;
my %tmp;
for my $mid (@$mids) {
my $nr = 0;
my %tmp;
for my $mid (@$mids) {
- my @removed = eval { $self->{over}->remove_oid($oid, $mid) };
- if ($@) {
- warn "E: failed to remove <$mid> from overview: $@\n";
- } else {
- $nr += scalar @removed;
- $tmp{$_}++ for @removed;
- }
+ my @removed = $self->{oidx}->remove_oid($oid, $mid);
+ $nr += scalar @removed;
+ $tmp{$_}++ for @removed;
}
if (!$nr) {
$mids = join('> <', @$mids);
}
if (!$nr) {
$mids = join('> <', @$mids);
my $mids = mids($mime);
my $mm = $self->{mm};
if ($sync->{reindex}) {
my $mids = mids($mime);
my $mm = $self->{mm};
if ($sync->{reindex}) {
- my $over = $self->{over};
+ my $oidx = $self->{oidx};
- my ($num, undef) = $over->num_mid0_for_oid($oid, $mid);
+ my ($num, undef) = $oidx->num_mid0_for_oid($oid, $mid);
return $num if defined $num;
}
$mm->num_for($mids->[0]) // $mm->mid_insert($mids->[0]);
return $num if defined $num;
}
$mm->num_for($mids->[0]) // $mm->mid_insert($mids->[0]);
- $self->{over}->rethread_done($sync->{-opt}) if $newest; # all done
+ $self->{oidx}->rethread_done($sync->{-opt}) if $newest; # all done
commit_txn_lazy($self);
$self->{ibx}->git->cleanup;
my $nr = ${$sync->{nr}};
commit_txn_lazy($self);
$self->{ibx}->git->cleanup;
my $nr = ${$sync->{nr}};
my $pr = $opt->{-progress};
my $sync = { reindex => $opt->{reindex}, -opt => $opt };
my $xdb = $self->begin_txn_lazy;
my $pr = $opt->{-progress};
my $sync = { reindex => $opt->{reindex}, -opt => $opt };
my $xdb = $self->begin_txn_lazy;
- $self->{over}->rethread_prepare($opt);
+ $self->{oidx}->rethread_prepare($opt);
my $mm = _msgmap_init($self);
if ($sync->{reindex}) {
my $last = $mm->last_commit;
my $mm = _msgmap_init($self);
if ($sync->{reindex}) {
my $last = $mm->last_commit;
sub _begin_txn {
my ($self) = @_;
my $xdb = $self->{xdb} || idx_acquire($self);
sub _begin_txn {
my ($self) = @_;
my $xdb = $self->{xdb} || idx_acquire($self);
- $self->{over}->begin_lazy if $self->{over};
+ $self->{oidx}->begin_lazy if $self->{oidx};
$xdb->begin_transaction if $xdb;
$self->{txn} = 1;
$xdb;
$xdb->begin_transaction if $xdb;
$self->{txn} = 1;
$xdb;
set_metadata_once($self);
$xdb->commit_transaction;
}
set_metadata_once($self);
$xdb->commit_transaction;
}
- $self->{over}->commit_lazy if $self->{over};
+ $self->{oidx}->commit_lazy if $self->{oidx};
total_bytes => 0,
current_info => '',
xpfx => $xpfx,
total_bytes => 0,
current_info => '',
xpfx => $xpfx,
- over => PublicInbox::OverIdx->new("$xpfx/over.sqlite3"),
+ oidx => PublicInbox::OverIdx->new("$xpfx/over.sqlite3"),
lock_path => "$dir/inbox.lock",
# limit each git repo (epoch) to 1GB or so
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
last_commit => [], # git epoch -> commit
};
lock_path => "$dir/inbox.lock",
# limit each git repo (epoch) to 1GB or so
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
last_commit => [], # git epoch -> commit
};
- $self->{over}->{-no_fsync} = 1 if $v2ibx->{-no_fsync};
+ $self->{oidx}->{-no_fsync} = 1 if $v2ibx->{-no_fsync};
$self->{shards} = count_shards($self) || nproc_shards($creat);
bless $self, $class;
}
$self->{shards} = count_shards($self) || nproc_shards($creat);
bless $self, $class;
}
sub do_idx ($$$$) {
my ($self, $msgref, $mime, $smsg) = @_;
$smsg->{bytes} = $smsg->{raw_bytes} + crlf_adjust($$msgref);
sub do_idx ($$$$) {
my ($self, $msgref, $mime, $smsg) = @_;
$smsg->{bytes} = $smsg->{raw_bytes} + crlf_adjust($$msgref);
- $self->{over}->add_overview($mime, $smsg);
+ $self->{oidx}->add_overview($mime, $smsg);
my $idx = idx_shard($self, $smsg->{num} % $self->{shards});
$idx->index_raw($msgref, $mime, $smsg);
my $n = $self->{transact_bytes} += $smsg->{raw_bytes};
my $idx = idx_shard($self, $smsg->{num} % $self->{shards});
$idx->index_raw($msgref, $mime, $smsg);
my $n = $self->{transact_bytes} += $smsg->{raw_bytes};
if ($altid && grep(/:file=msgmap\.sqlite3\z/, @$altid)) {
my $num = $self->{mm}->num_for($mid);
if ($altid && grep(/:file=msgmap\.sqlite3\z/, @$altid)) {
my $num = $self->{mm}->num_for($mid);
- if (defined $num && !$self->{over}->get_art($num)) {
+ if (defined $num && !$self->{oidx}->get_art($num)) {
sub _idx_init { # with_umask callback
my ($self, $opt) = @_;
$self->lock_acquire unless $opt && $opt->{-skip_lock};
sub _idx_init { # with_umask callback
my ($self, $opt) = @_;
$self->lock_acquire unless $opt && $opt->{-skip_lock};
# xcpdb can change shard count while -watch is idle
my $nshards = count_shards($self);
# xcpdb can change shard count while -watch is idle
my $nshards = count_shards($self);
} else {
$im = $self->importer;
}
} else {
$im = $self->importer;
}
- my $over = $self->{over};
+ my $oidx = $self->{oidx};
my $chashes = content_hashes($old_eml);
my $removed = [];
my $mids = mids($old_eml);
my $chashes = content_hashes($old_eml);
my $removed = [];
my $mids = mids($old_eml);
foreach my $mid (@$mids) {
my %gone; # num => [ smsg, $mime, raw ]
my ($id, $prev);
foreach my $mid (@$mids) {
my %gone; # num => [ smsg, $mime, raw ]
my ($id, $prev);
- while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) {
+ while (my $smsg = $oidx->next_by_mid($mid, \$id, \$prev)) {
my $msg = get_blob($self, $smsg);
if (!defined($msg)) {
warn "broken smsg for $mid\n";
my $msg = get_blob($self, $smsg);
if (!defined($msg)) {
warn "broken smsg for $mid\n";
$dbh->commit;
# SQLite overview is third
$dbh->commit;
# SQLite overview is third
- $self->{over}->commit_lazy;
+ $self->{oidx}->commit_lazy;
# Now deal with Xapian
if ($wait) {
# Now deal with Xapian
if ($wait) {
$err .= "shard close: $@\n" if $@;
}
}
$err .= "shard close: $@\n" if $@;
}
}
- eval { $self->{over}->dbh_close };
+ eval { $self->{oidx}->dbh_close };
$err .= "over close: $@\n" if $@;
delete $self->{bnote};
my $nbytes = $self->{total_bytes};
$err .= "over close: $@\n" if $@;
delete $self->{bnote};
my $nbytes = $self->{total_bytes};
sub content_exists ($$$) {
my ($self, $mime, $mid) = @_;
sub content_exists ($$$) {
my ($self, $mime, $mid) = @_;
- my $over = $self->{over};
+ my $oidx = $self->{oidx};
my $chashes = content_hashes($mime);
my ($id, $prev);
my $chashes = content_hashes($mime);
my ($id, $prev);
- while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) {
+ while (my $smsg = $oidx->next_by_mid($mid, \$id, \$prev)) {
my $msg = get_blob($self, $smsg);
if (!defined($msg)) {
warn "broken smsg for $mid\n";
my $msg = get_blob($self, $smsg);
if (!defined($msg)) {
warn "broken smsg for $mid\n";
}
}
if (!defined($num)) { # reuse if reindexing (or duplicates)
}
}
if (!defined($num)) { # reuse if reindexing (or duplicates)
- my $over = $self->{over};
+ my $oidx = $self->{oidx};
- ($num, $mid0) = $over->num_mid0_for_oid($oid, $mid);
+ ($num, $mid0) = $oidx->num_mid0_for_oid($oid, $mid);
last if defined $num;
}
}
last if defined $num;
}
}
sub unindex_oid_remote ($$$) {
my ($self, $oid, $mid) = @_;
sub unindex_oid_remote ($$$) {
my ($self, $oid, $mid) = @_;
- my @removed = $self->{over}->remove_oid($oid, $mid);
+ my @removed = $self->{oidx}->remove_oid($oid, $mid);
for my $num (@removed) {
my $idx = idx_shard($self, $num % $self->{shards});
$idx->shard_remove($oid, $num);
for my $num (@removed) {
my $idx = idx_shard($self, $num % $self->{shards});
$idx->shard_remove($oid, $num);
my $mm = $self->{mm};
my $mids = mids(PublicInbox::Eml->new($bref));
undef $$bref;
my $mm = $self->{mm};
my $mids = mids(PublicInbox::Eml->new($bref));
undef $$bref;
- my $over = $self->{over};
+ my $oidx = $self->{oidx};
foreach my $mid (@$mids) {
my %gone;
my ($id, $prev);
foreach my $mid (@$mids) {
my %gone;
my ($id, $prev);
- while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) {
+ while (my $smsg = $oidx->next_by_mid($mid, \$id, \$prev)) {
$gone{$smsg->{num}} = 1 if $oid eq $smsg->{blob};
}
my $n = scalar(keys(%gone)) or next;
$gone{$smsg->{num}} = 1 if $oid eq $smsg->{blob};
}
my $n = scalar(keys(%gone)) or next;
$self->idx_init($opt); # acquire lock
fill_alternates($self, $epoch_max);
$self->idx_init($opt); # acquire lock
fill_alternates($self, $epoch_max);
- $self->{over}->rethread_prepare($opt);
+ $self->{oidx}->rethread_prepare($opt);
my $sync = {
need_checkpoint => \(my $bool = 0),
unindex_range => {}, # EPOCH => oid_old..oid_new
my $sync = {
need_checkpoint => \(my $bool = 0),
unindex_range => {}, # EPOCH => oid_old..oid_new
}
# work forwards through history
index_epoch($self, $sync, $_) for (0..$epoch_max);
}
# work forwards through history
index_epoch($self, $sync, $_) for (0..$epoch_max);
- $self->{over}->rethread_done($opt);
+ $self->{oidx}->rethread_done($opt);
$self->done;
if (my $nr = $sync->{nr}) {
$self->done;
if (my $nr = $sync->{nr}) {
-my $dbh = $rw->{over}->dbh;
+my $dbh = $rw->{oidx}->dbh;
foreach my $mid (@mids) {
foreach my $mid (@mids) {
- my $msgs = $rw->{over}->get_thread($mid);
+ my $msgs = $rw->{oidx}->get_thread($mid);
is(3, scalar(@$msgs), "got all messages from $mid");
foreach my $m (@$msgs) {
my $tid = $dbh->selectrow_array(<<'', undef, $m->{num});
is(3, scalar(@$msgs), "got all messages from $mid");
foreach my $m (@$msgs) {
my $tid = $dbh->selectrow_array(<<'', undef, $m->{num});
From: bw@g
To: git@vger.kernel.org
From: bw@g
To: git@vger.kernel.org
- my $dbh = $rw->{over}->dbh;
+ my $dbh = $rw->{oidx}->dbh;
- my $reidx = $rw->{over}->next_by_mid('1-bw@g', \$id, \$prev);
+ my $reidx = $rw->{oidx}->next_by_mid('1-bw@g', \$id, \$prev);
ok(defined $reidx);
my $num = $reidx->{num};
my $tid0 = $dbh->selectrow_array(<<'', undef, $num);
ok(defined $reidx);
my $num = $reidx->{num};
my $tid0 = $dbh->selectrow_array(<<'', undef, $num);
EOF
my $ghost_id = $rw->add_message($was_ghost);
is($ghost_id, int($ghost_id), "ghost_id is an integer: $ghost_id");
EOF
my $ghost_id = $rw->add_message($was_ghost);
is($ghost_id, int($ghost_id), "ghost_id is an integer: $ghost_id");
- my $msgs = $rw->{over}->get_thread('ghost-message@s');
+ my $msgs = $rw->{oidx}->get_thread('ghost-message@s');
is(scalar(@$msgs), 2, 'got both messages in ghost thread');
foreach (qw(sid tid)) {
is($msgs->[0]->{$_}, $msgs->[1]->{$_}, "{$_} match");
is(scalar(@$msgs), 2, 'got both messages in ghost thread');
foreach (qw(sid tid)) {
is($msgs->[0]->{$_}, $msgs->[1]->{$_}, "{$_} match");