unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/5] overidx: wrap eidx_key => ibx_id mapping
Date: Mon,  7 Dec 2020 07:40:50 +0000	[thread overview]
Message-ID: <20201207074053.14483-3-e@80x24.org> (raw)
In-Reply-To: <20201207074053.14483-1-e@80x24.org>

This makes things a little less noisy and will be
called by ExtSearchIdx.
---
 lib/PublicInbox/OverIdx.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 635aa314..38552247 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -79,6 +79,11 @@ SELECT $id_col FROM $tbl WHERE $val_col = ? LIMIT 1
 	}
 }
 
+sub ibx_id {
+	my ($self, $eidx_key) = @_;
+	id_for($self, 'inboxes', 'ibx_id', eidx_key => $eidx_key);
+}
+
 sub sid {
 	my ($self, $path) = @_;
 	return unless defined $path && $path ne '';
@@ -588,7 +593,7 @@ sub eidx_max {
 sub add_xref3 {
 	my ($self, $docid, $xnum, $oidhex, $eidx_key) = @_;
 	begin_lazy($self);
-	my $ibx_id = id_for($self, 'inboxes', 'ibx_id', eidx_key => $eidx_key);
+	my $ibx_id = ibx_id($self, $eidx_key);
 	my $oidbin = pack('H*', $oidhex);
 	my $sth = $self->{dbh}->prepare_cached(<<'');
 INSERT OR IGNORE INTO xref3 (docid, ibx_id, xnum, oidbin) VALUES (?, ?, ?, ?)
@@ -607,8 +612,7 @@ sub remove_xref3 {
 	my $oidbin = pack('H*', $oidhex);
 	my ($sth, $ibx_id);
 	if (defined $eidx_key) {
-		$ibx_id = id_for($self, 'inboxes', 'ibx_id',
-					eidx_key => $eidx_key);
+		$ibx_id = ibx_id($self, $eidx_key);
 		$sth = $self->{dbh}->prepare_cached(<<'');
 DELETE FROM xref3 WHERE docid = ? AND ibx_id = ? AND oidbin = ?
 

  parent reply	other threads:[~2020-12-07  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07  7:40 [PATCH 0/5] extindex: random cleanups Eric Wong
2020-12-07  7:40 ` [PATCH 1/5] over: gracefully show invalid ibx_id Eric Wong
2020-12-07  7:40 ` Eric Wong [this message]
2020-12-07  7:40 ` [PATCH 3/5] extsearchidx: remove needless SHA-1 check Eric Wong
2020-12-07  7:40 ` [PATCH 4/5] searchidx: remove $oid parameter from most calls Eric Wong
2020-12-07  7:40 ` [PATCH 5/5] shard_add_eidx_info: pass $eidx_key instead of $ibx object Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201207074053.14483-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).