user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/6] nntp: use Inbox->over directly
Date: Wed, 15 May 2019 06:33:50 +0000	[thread overview]
Message-ID: <20190515063354.52259-3-e@80x24.org> (raw)
In-Reply-To: <20190515063354.52259-1-e@80x24.org>

None of the NNTP code actually relies on Xapian, anymore.
---
 lib/PublicInbox/NNTP.pm   | 40 +++++++++++++++++++--------------------
 lib/PublicInbox/Search.pm | 11 -----------
 2 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 5c5df7b..8cb6c56 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -326,27 +326,27 @@ sub cmd_newnews ($$$$;$$) {
 	my ($keep, $skip) = split('!', $newsgroups, 2);
 	ngpat2re($keep);
 	ngpat2re($skip);
-	my @srch;
+	my @over;
 	foreach my $ng (@{$self->{nntpd}->{grouplist}}) {
 		$ng->{newsgroup} =~ $keep or next;
 		$ng->{newsgroup} =~ $skip and next;
-		my $srch = $ng->search or next;
-		push @srch, $srch;
+		my $over = $ng->over or next;
+		push @over, $over;
 	};
-	return '.' unless @srch;
+	return '.' unless @over;
 
 	my $prev = 0;
 	long_response($self, sub {
-		my $srch = $srch[0];
-		my $msgs = $srch->query_ts($ts, $prev);
+		my $over = $over[0];
+		my $msgs = $over->query_ts($ts, $prev);
 		if (scalar @$msgs) {
 			more($self, '<' .
 				join(">\r\n<", map { $_->mid } @$msgs ).
 				'>');
 			$prev = $msgs->[-1]->{num};
 		} else {
-			shift @srch;
-			if (@srch) { # continue onto next newsgroup
+			shift @over;
+			if (@over) { # continue onto next newsgroup
 				$prev = 0;
 				return 1;
 			} else { # break out of the long response.
@@ -483,7 +483,7 @@ find_mid:
 		defined $mid or return $err;
 	}
 found:
-	my $smsg = $ng->search->{over_ro}->get_art($n) or return $err;
+	my $smsg = $ng->over->get_art($n) or return $err;
 	my $msg = $ng->msg_by_smsg($smsg) or return $err;
 	my $s = Email::Simple->new($msg);
 	if ($set_headers) {
@@ -706,9 +706,9 @@ sub hdr_xref ($$$) { # optimize XHDR Xref [range] for rtin
 	}
 }
 
-sub search_header_for {
-	my ($srch, $num, $field) = @_;
-	my $smsg = $srch->{over_ro}->get_art($num) or return;
+sub over_header_for {
+	my ($over, $num, $field) = @_;
+	my $smsg = $over->get_art($num) or return;
 	return PublicInbox::SearchMsg::date($smsg) if $field eq 'date';
 	$smsg->{$field};
 }
@@ -718,11 +718,11 @@ sub hdr_searchmsg ($$$$) {
 	if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
 		my ($ng, $n) = mid_lookup($self, $1);
 		return r430 unless defined $n;
-		my $v = search_header_for($ng->search, $n, $field);
+		my $v = over_header_for($ng->over, $n, $field);
 		hdr_mid_response($self, $xhdr, $ng, $n, $range, $v);
 	} else { # numeric range
 		$range = $self->{article} unless defined $range;
-		my $srch = $self->{ng}->search;
+		my $over = $self->{ng}->over;
 		my $mm = $self->{ng}->mm;
 		my $r = get_range($self, $range);
 		return $r unless ref $r;
@@ -730,7 +730,7 @@ sub hdr_searchmsg ($$$$) {
 		more($self, $xhdr ? r221 : r225);
 		my $cur = $beg;
 		long_response($self, sub {
-			my $msgs = $srch->query_xover($cur, $end);
+			my $msgs = $over->query_xover($cur, $end);
 			my $nr = scalar @$msgs or return;
 			my $tmp = '';
 			foreach my $s (@$msgs) {
@@ -810,11 +810,11 @@ sub cmd_xrover ($;$) {
 	return $r unless ref $r;
 	my ($beg, $end) = @$r;
 	my $mm = $ng->mm;
-	my $srch = $ng->search;
+	my $over = $ng->over;
 	more($self, '224 Overview information follows');
 
 	long_response($self, sub {
-		my $h = search_header_for($srch, $beg, 'references');
+		my $h = over_header_for($over, $beg, 'references');
 		more($self, "$beg $h") if defined($h);
 		$beg++ < $end;
 	});
@@ -842,7 +842,7 @@ sub cmd_over ($;$) {
 	if ($range && $range =~ /\A<(.+)>\z/) {
 		my ($ng, $n) = mid_lookup($self, $1);
 		defined $n or return r430;
-		my $smsg = $ng->search->{over_ro}->get_art($n) or return r430;
+		my $smsg = $ng->over->get_art($n) or return r430;
 		more($self, '224 Overview information follows (multi-line)');
 
 		# Only set article number column if it's the current group
@@ -862,10 +862,10 @@ sub cmd_xover ($;$) {
 	return $r unless ref $r;
 	my ($beg, $end) = @$r;
 	more($self, "224 Overview information follows for $beg to $end");
-	my $srch = $self->{ng}->search;
+	my $over = $self->{ng}->over;
 	my $cur = $beg;
 	long_response($self, sub {
-		my $msgs = $srch->query_xover($cur, $end);
+		my $msgs = $over->query_xover($cur, $end);
 		my $nr = scalar @$msgs or return;
 
 		# OVERVIEW.FMT
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 090d998..760c660 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -293,17 +293,6 @@ EOF
 	$self->{query_parser} = $qp;
 }
 
-# only used for NNTP server
-sub query_xover {
-	my ($self, $beg, $end, $offset) = @_;
-	$self->{over_ro}->query_xover($beg, $end, $offset);
-}
-
-sub query_ts {
-	my ($self, $ts, $prev) = @_;
-	$self->{over_ro}->query_ts($ts, $prev);
-}
-
 sub lookup_article {
 	my ($self, $num) = @_;
 	$self->{over_ro}->get_art($num);
-- 
EW


  parent reply	other threads:[~2019-05-15  6:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15  6:33 [PATCH 0/6] make Search::Xapian optional for v2, NNTP, etc Eric Wong
2019-05-15  6:33 ` [PATCH 1/6] inbox: add ->over method to ease access Eric Wong
2019-05-15  6:33 ` Eric Wong [this message]
2019-05-15  6:33 ` [PATCH 3/6] www: use Inbox->over where appropriate Eric Wong
2019-05-15  6:33 ` [PATCH 4/6] lazy load Xapian and make it optional for v2 Eric Wong
2019-05-15  6:33 ` [PATCH 5/6] searchidx: do not create empty Xapian partitions for basic Eric Wong
2019-05-15  6:33 ` [PATCH 6/6] admin: improve warnings and errors for missing modules Eric Wong
2019-05-22  0:35 ` [PATCH 0/6] make Search::Xapian optional for v2, NNTP, etc 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=20190515063354.52259-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).