user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
blob b7e337de38d7b870d1045ba417de28fedb1f010a 981 bytes (raw)
name: lib/PublicInbox/LeiSearch.pm 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

package PublicInbox::LeiSearch;
use strict;
use v5.10.1;
use parent qw(PublicInbox::ExtSearch);
use PublicInbox::Search;

# get combined docid from over.num:
# (not generic Xapian, only works with our sharding scheme)
sub num2docid ($$) {
	my ($self, $num) = @_;
	my $nshard = $self->{nshard};
	($num - 1) * $nshard + $num % $nshard + 1;
}

sub msg_keywords {
	my ($self, $num) = @_; # num_or_mitem
	my $xdb = $self->xdb; # set {nshard};
	my $docid = ref($num) ? $num->get_docid : num2docid($self, $num);
	my %kw;
	eval {
		my $end = $xdb->termlist_end($docid);
		my $cur = $xdb->termlist_begin($docid);
		for (; $cur != $end; $cur++) {
			$cur->skip_to('K');
			last if $cur == $end;
			my $kw = $cur->get_termname;
			$kw =~ s/\AK//s and $kw{$kw} = undef;
		}
	};
	warn "E: #$docid ($num): $@\n" if $@;
	wantarray ? sort(keys(%kw)) : \%kw;
}

1;

debug log:

solving b7e337de ...
found b7e337de in https://80x24.org/public-inbox.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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