From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 03D1B1FA12 for ; Mon, 7 Dec 2020 07:40:54 +0000 (UTC) From: Eric Wong 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 Message-Id: <20201207074053.14483-3-e@80x24.org> In-Reply-To: <20201207074053.14483-1-e@80x24.org> References: <20201207074053.14483-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 = ?