+sub shard_commit {
+ my ($self) = @_;
+ if (my $w = $self->{w}) {
+ print $w "commit\n" or die "failed to write commit: $!";
+ } else {
+ $self->commit_txn_lazy;
+ }
+}
+
+sub shard_close {
+ my ($self) = @_;
+ if (my $w = delete $self->{w}) {
+ my $pid = delete $self->{pid} or die "no process to wait on\n";
+ print $w "close\n" or die "failed to write to pid:$pid: $!\n";
+ close $w or die "failed to close pipe for pid:$pid: $!\n";
+ waitpid($pid, 0) == $pid or die "remote process did not finish";
+ $? == 0 or die ref($self)." pid:$pid exited with: $?";
+ } else {
+ die "transaction in progress $self\n" if $self->{txn};
+ $self->idx_release if $self->{xdb};
+ }
+}
+
+sub shard_remove {
+ my ($self, $num) = @_;
+ if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child
+ print $w "D $num\n" or die "failed to write remove $!";
+ } else { # same process
+ $self->remove_by_docid($num);
+ }
+}
+
+sub shard_set_keywords {
+ my ($self, $docid, @kw) = @_;
+ if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child
+ print $w "=K $docid @kw\n" or die "failed to write: $!";
+ } else { # same process
+ $self->set_keywords($docid, @kw);
+ }
+}
+
+sub shard_remove_keywords {
+ my ($self, $docid, @kw) = @_;
+ if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child
+ print $w "-K $docid @kw\n" or die "failed to write: $!";
+ } else { # same process
+ $self->remove_keywords($docid, @kw);
+ }
+}
+
+sub shard_add_keywords {
+ my ($self, $docid, @kw) = @_;
+ if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child
+ print $w "+K $docid @kw\n" or die "failed to write: $!";
+ } else { # same process
+ $self->add_keywords($docid, @kw);
+ }
+}
+
+sub shard_over_check {
+ my ($self, $over) = @_;
+ if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child
+ my ($over_fn) = $over->{dbh}->sqlite_db_filename;
+ $over_fn =~ tr/\n/\0/;
+ print $w "O $over_fn\n" or die "failed to write over $!";
+ } else {
+ $self->over_check($over);
+ }
+}
+